tx · 8g6cLM8gBeo4CTSUvYNAiDwxFh1SodqncDLQNhyKKsjD 3N5jpkcHiH5R36y9cYnoXhVHe4pxRkS3peF: -0.01400000 Waves 2020.03.10 03:02 [902288] smart account 3N5jpkcHiH5R36y9cYnoXhVHe4pxRkS3peF > SELF 0.00000000 Waves
{ "type": 13, "id": "8g6cLM8gBeo4CTSUvYNAiDwxFh1SodqncDLQNhyKKsjD", "fee": 1400000, "feeAssetId": null, "timestamp": 1583798524284, "version": 1, "sender": "3N5jpkcHiH5R36y9cYnoXhVHe4pxRkS3peF", "senderPublicKey": "9v3cUhWaBqFKLuHQTbz2osNsxRANDcpaRZja43mFNkR3", "proofs": [ "322AxzisuuEz9BnStpRSm8xV6mraUYoNyWqmbBq55WXe29CrH8hA4NVVVVRsbNggNPQCFt6L1zacpyn6zJE2b77U" ], "script": "base64:AAIDAAAAAAAAAA0IARIAEgASABIDCgEBAAAAAwAAAAAGRVVDb2luAQAAACDJofoUphCC2vgdQrn0R0tQm4QOreBLRVolNScltI/WUQAAAAAGVVNDb2luAQAAACCWpimiLpI8FZFaHXIW3ZwI74bEgcPecoAv5ODcRcQ7/QAAAAAOb3duZXJQdWJsaWNLZXkBAAAAIIR0OzhzTJc1ozXjp3CfISpQxO2vbrCrTGSiFABFRe8mAAAABAAAAAFpAQAAAAdkZXBvc2l0AAAAAAQAAAADcG10CQEAAAAHZXh0cmFjdAAAAAEIBQAAAAFpAAAAB3BheW1lbnQDCQEAAAAJaXNEZWZpbmVkAAAAAQgFAAAAA3BtdAAAAAdhc3NldElkAwkAAAAAAAACCAUAAAADcG10AAAAB2Fzc2V0SWQFAAAABlVTQ29pbgQAAAAKY3VycmVudEtleQkAAlgAAAABCAgFAAAAAWkAAAAGY2FsbGVyAAAABWJ5dGVzBAAAAA1jdXJyZW50QW1vdW50BAAAAAckbWF0Y2gwCQAEGgAAAAIFAAAABHRoaXMJAAEsAAAAAgUAAAAKY3VycmVudEtleQIAAAAHX3VzY29pbgMJAAABAAAA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AAAANuaWwAAAABAAAAAnR4AQAAAAZ2ZXJpZnkAAAAABAAAAAckbWF0Y2gwBQAAAAJ0eAMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAAUU2V0U2NyaXB0VHJhbnNhY3Rpb24EAAAAAWQFAAAAByRtYXRjaDAJAAH0AAAAAwgFAAAAAnR4AAAACWJvZHlCeXRlcwkAAZEAAAACCAUAAAACdHgAAAAGcHJvb2ZzAAAAAAAAAAAABQAAAA5vd25lclB1YmxpY0tleQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAAPRGF0YVRyYW5zYWN0aW9uBAAAAAFkBQAAAAckbWF0Y2gwBgeMfdyW", "chainId": 84, "height": 902288, "spentComplexity": 0 } View: original | compacted Prev: CQZ5DUYy7TYDzQWinGESEPHpUKHiBRoAuMFmzYwzTv8L Next: A6A9x5vkBwtWGJH4chRb8GTtoLHeFDKzLDFB6SFoA2wr Diff:
Old | New | Differences | |
---|---|---|---|
92 | 92 | ||
93 | 93 | ||
94 | 94 | @Callable(i) | |
95 | - | func getFaucet (amount) = if ((0 > amount)) | |
96 | - | then throw("Can't withdraw negative amount") | |
97 | - | else TransferSet([ScriptTransfer(i.caller, amount, EUCoin)]) | |
95 | + | func getFaucet (amount) = { | |
96 | + | let currentKey = toBase58String(i.caller.bytes) | |
97 | + | let currentAmount = match getInteger(this, (currentKey + "_faucet")) { | |
98 | + | case a: Int => | |
99 | + | a | |
100 | + | case _ => | |
101 | + | 0 | |
102 | + | } | |
103 | + | if ((0 > amount)) | |
104 | + | then throw("Can't withdraw negative amount") | |
105 | + | else if ((currentAmount > 0)) | |
106 | + | then throw("Faucet already taken") | |
107 | + | else ScriptResult(WriteSet([DataEntry((currentKey + "_faucet"), amount)]), TransferSet([ScriptTransfer(i.caller, amount, EUCoin)])) | |
108 | + | } | |
98 | 109 | ||
99 | 110 | ||
100 | 111 | @Verifier(tx) |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let EUCoin = base58'Ea6CdDfumo8ZFecxUSWKAjZpQXmkRC79WB4ktu3KffPn' | |
5 | 5 | ||
6 | 6 | let USCoin = base58'B957NA5BEM8quCDhe1fUPkqBSdCZdJunNxjGE8FRJkWx' | |
7 | 7 | ||
8 | 8 | let ownerPublicKey = base58'9v3cUhWaBqFKLuHQTbz2osNsxRANDcpaRZja43mFNkR3' | |
9 | 9 | ||
10 | 10 | @Callable(i) | |
11 | 11 | func deposit () = { | |
12 | 12 | let pmt = extract(i.payment) | |
13 | 13 | if (isDefined(pmt.assetId)) | |
14 | 14 | then if ((pmt.assetId == USCoin)) | |
15 | 15 | then { | |
16 | 16 | let currentKey = toBase58String(i.caller.bytes) | |
17 | 17 | let currentAmount = match getInteger(this, (currentKey + "_uscoin")) { | |
18 | 18 | case a: Int => | |
19 | 19 | a | |
20 | 20 | case _ => | |
21 | 21 | 0 | |
22 | 22 | } | |
23 | 23 | let newAmount = (currentAmount + pmt.amount) | |
24 | 24 | ScriptResult(WriteSet([DataEntry((currentKey + "_uscoin"), newAmount)]), TransferSet([ScriptTransfer(i.caller, pmt.amount, EUCoin)])) | |
25 | 25 | } | |
26 | 26 | else throw("can hodl USCoin only at the moment") | |
27 | 27 | else { | |
28 | 28 | let currentKey = toBase58String(i.caller.bytes) | |
29 | 29 | let currentAmount = match getInteger(this, (currentKey + "_waves")) { | |
30 | 30 | case a: Int => | |
31 | 31 | a | |
32 | 32 | case _ => | |
33 | 33 | 0 | |
34 | 34 | } | |
35 | 35 | let newAmount = (currentAmount + (pmt.amount / 100)) | |
36 | 36 | ScriptResult(WriteSet([DataEntry((currentKey + "_waves"), newAmount)]), TransferSet([ScriptTransfer(i.caller, (pmt.amount / 100), EUCoin)])) | |
37 | 37 | } | |
38 | 38 | } | |
39 | 39 | ||
40 | 40 | ||
41 | 41 | ||
42 | 42 | @Callable(i) | |
43 | 43 | func withdrawUSCoin () = { | |
44 | 44 | let pmt = extract(i.payment) | |
45 | 45 | if (isDefined(pmt.assetId)) | |
46 | 46 | then if ((pmt.assetId == EUCoin)) | |
47 | 47 | then { | |
48 | 48 | let currentKey = toBase58String(i.caller.bytes) | |
49 | 49 | let currentAmount = match getInteger(this, (currentKey + "_uscoin")) { | |
50 | 50 | case a: Int => | |
51 | 51 | a | |
52 | 52 | case _ => | |
53 | 53 | 0 | |
54 | 54 | } | |
55 | 55 | let newAmount = (currentAmount - pmt.amount) | |
56 | 56 | if ((0 > pmt.amount)) | |
57 | 57 | then throw("Can't withdraw negative amount") | |
58 | 58 | else if ((0 > newAmount)) | |
59 | 59 | then throw("Not enough USCoin Deposited") | |
60 | 60 | else ScriptResult(WriteSet([DataEntry((currentKey + "_uscoin"), newAmount)]), TransferSet([ScriptTransfer(i.caller, pmt.amount, USCoin)])) | |
61 | 61 | } | |
62 | 62 | else throw("You Can Withdraw with EUCoin only") | |
63 | 63 | else throw("You Can Withdraw with EUCoin only") | |
64 | 64 | } | |
65 | 65 | ||
66 | 66 | ||
67 | 67 | ||
68 | 68 | @Callable(i) | |
69 | 69 | func withdrawWaves () = { | |
70 | 70 | let pmt = extract(i.payment) | |
71 | 71 | if (isDefined(pmt.assetId)) | |
72 | 72 | then if ((pmt.assetId == EUCoin)) | |
73 | 73 | then { | |
74 | 74 | let currentKey = toBase58String(i.caller.bytes) | |
75 | 75 | let currentAmount = match getInteger(this, (currentKey + "_waves")) { | |
76 | 76 | case a: Int => | |
77 | 77 | a | |
78 | 78 | case _ => | |
79 | 79 | 0 | |
80 | 80 | } | |
81 | 81 | let newAmount = (currentAmount - pmt.amount) | |
82 | 82 | if ((0 > pmt.amount)) | |
83 | 83 | then throw("Can't withdraw negative amount") | |
84 | 84 | else if ((0 > newAmount)) | |
85 | 85 | then throw("Not enough Waves Deposited") | |
86 | 86 | else ScriptResult(WriteSet([DataEntry((currentKey + "_waves"), newAmount)]), TransferSet([ScriptTransfer(i.caller, (pmt.amount * 100), unit)])) | |
87 | 87 | } | |
88 | 88 | else throw("You Can Withdraw with EUCoin only") | |
89 | 89 | else throw("You Can Withdraw with EUCoin only") | |
90 | 90 | } | |
91 | 91 | ||
92 | 92 | ||
93 | 93 | ||
94 | 94 | @Callable(i) | |
95 | - | func getFaucet (amount) = if ((0 > amount)) | |
96 | - | then throw("Can't withdraw negative amount") | |
97 | - | else TransferSet([ScriptTransfer(i.caller, amount, EUCoin)]) | |
95 | + | func getFaucet (amount) = { | |
96 | + | let currentKey = toBase58String(i.caller.bytes) | |
97 | + | let currentAmount = match getInteger(this, (currentKey + "_faucet")) { | |
98 | + | case a: Int => | |
99 | + | a | |
100 | + | case _ => | |
101 | + | 0 | |
102 | + | } | |
103 | + | if ((0 > amount)) | |
104 | + | then throw("Can't withdraw negative amount") | |
105 | + | else if ((currentAmount > 0)) | |
106 | + | then throw("Faucet already taken") | |
107 | + | else ScriptResult(WriteSet([DataEntry((currentKey + "_faucet"), amount)]), TransferSet([ScriptTransfer(i.caller, amount, EUCoin)])) | |
108 | + | } | |
98 | 109 | ||
99 | 110 | ||
100 | 111 | @Verifier(tx) | |
101 | 112 | func verify () = match tx { | |
102 | 113 | case d: SetScriptTransaction => | |
103 | 114 | sigVerify(tx.bodyBytes, tx.proofs[0], ownerPublicKey) | |
104 | 115 | case d: DataTransaction => | |
105 | 116 | true | |
106 | 117 | case _ => | |
107 | 118 | false | |
108 | 119 | } | |
109 | 120 |
github/deemru/w8io/169f3d6 43.62 ms ◑