tx · H4czz8zV9pKUxx3qasL2hFopqamAJ67uuFLGWomJLtSh 3MxfEq17wZjAWQfckWycU9o4oTkvf9nfNQX: -0.01000000 Waves 2021.12.12 15:20 [1831027] smart account 3MxfEq17wZjAWQfckWycU9o4oTkvf9nfNQX > SELF 0.00000000 Waves
{ "type": 13, "id": "H4czz8zV9pKUxx3qasL2hFopqamAJ67uuFLGWomJLtSh", "fee": 1000000, "feeAssetId": null, "timestamp": 1639311616574, "version": 2, "chainId": 84, "sender": "3MxfEq17wZjAWQfckWycU9o4oTkvf9nfNQX", "senderPublicKey": "HUca7AqRs4Zs9sU1AFcufmBC4XpT4sN79aFScNRT4LxQ", "proofs": [ "3wwUELyDZzHJVWhghQwVmyXxFGLX5nKQeFsL4du5dYMubpiEeDry1Xr1gQ4EgUGUxo1NirAxYpFnKZS7MJMWmzCS" ], "script": "base64:AAIFAAAAAAAAAAsIAhIAEgMKAQgSAAAAAAQAAAAABXRva2VuAQAAACA7Jny2nzFIkOmS/dy/eTheDQdpxX81oDDtGoXKk37pSwAAAAAGdG9rZW5kAAAAAAAAAAAIAAAAAAdhaXJkcm9wCQEAAAAHQWRkcmVzcwAAAAEBAAAAGgFUX+pzJtA2DV6Pr0xhS8z4foIVUAfq2c0IAAAAAAp0ZWFtQWRyZXNzCQEAAAAHQWRkcmVzcwAAAAEBAAAAGgFUACYJT8ivNONGpFPWk1FdqVPAxApBcmLaAAAAAwAAAAFpAQAAAAVyZXNldAAAAAAJAARMAAAAAgkBAAAAC0RlbGV0ZUVudHJ5AAAAAQkAAlgAAAABCAgFAAAAAWkAAAAGY2FsbGVyAAAABWJ5dGVzCQAETAAAAAIJAQAAAAxJbnRlZ2VyRW50cnkAAAACAgAAAAVidXJudAAAAAAAAAAAAAkABEwAAAACCQEAAAAMSW50ZWdlckVudHJ5AAAAAgIAAAAHZHJvcHBlZAAAAAAAAAAAAAkABEwAAAACCQEAAAAMSW50ZWdlckVudHJ5AAAAAgIAAAAIdGVhbWdpZnQAAAA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": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: none Next: H2Qb16yZueCHFHZqtQ88TQURV9rcADCPhDGGRGSgEsy2 Full:
Old | New | Differences | |
---|---|---|---|
1 | - | # no script | |
1 | + | {-# STDLIB_VERSION 5 #-} | |
2 | + | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | + | {-# CONTENT_TYPE DAPP #-} | |
4 | + | let token = base58'4yu6Ms41FW8T9ABJ724ZUBKA1QrA8LQskK6csQiC8ynJ' | |
5 | + | ||
6 | + | let tokend = 8 | |
7 | + | ||
8 | + | let airdrop = Address(base58'3MxfEq17wZjAWQfckWycU9o4oTkvf9nfNQX') | |
9 | + | ||
10 | + | let teamAdress = Address(base58'3MovsLjXpJr9HD2vBqmAf7Gze6jwuRxX1fX') | |
11 | + | ||
12 | + | @Callable(i) | |
13 | + | func reset () = [DeleteEntry(toBase58String(i.caller.bytes)), IntegerEntry("burnt", 0), IntegerEntry("dropped", 0), IntegerEntry("teamgift", 0), IntegerEntry("burningstage", 0), DeleteEntry((toBase58String(i.caller.bytes) + "_error"))] | |
14 | + | ||
15 | + | ||
16 | + | ||
17 | + | @Callable(i) | |
18 | + | func call (id58) = { | |
19 | + | let dropamount = (1000 * tokend) | |
20 | + | let teamgift = (10 * tokend) | |
21 | + | let trid = fromBase58String(id58) | |
22 | + | let callerAdress = Address(i.caller.bytes) | |
23 | + | let deadline = 1639310400000 | |
24 | + | let burndeadline = 1639314000000 | |
25 | + | let currenttime = match blockInfoByHeight(height) { | |
26 | + | case block: BlockInfo => | |
27 | + | block.timestamp | |
28 | + | case _ => | |
29 | + | throw("Can't find block") | |
30 | + | } | |
31 | + | let balance = assetBalance(airdrop, token) | |
32 | + | let burnamount = match getInteger("burningstage") { | |
33 | + | case a: Int => | |
34 | + | if (if ((getIntegerValue("burningstage") == 0)) | |
35 | + | then (currenttime > burndeadline) | |
36 | + | else false) | |
37 | + | then fraction(balance, 10, 100) | |
38 | + | else 0 | |
39 | + | case _ => | |
40 | + | throw("no burningstage") | |
41 | + | } | |
42 | + | let isenough = if ((balance > dropamount)) | |
43 | + | then true | |
44 | + | else throw("not enough") | |
45 | + | if ((isenough == isenough)) | |
46 | + | then { | |
47 | + | let trexists = match transferTransactionById(trid) { | |
48 | + | case ttx: TransferTransaction => | |
49 | + | true | |
50 | + | case _ => | |
51 | + | false | |
52 | + | } | |
53 | + | let trtime = match transferTransactionById(trid) { | |
54 | + | case ttx: TransferTransaction => | |
55 | + | ttx.timestamp | |
56 | + | case _ => | |
57 | + | 9999999999999 | |
58 | + | } | |
59 | + | let trsender = match transferTransactionById(trid) { | |
60 | + | case ttx: TransferTransaction => | |
61 | + | ttx.sender | |
62 | + | case _ => | |
63 | + | airdrop | |
64 | + | } | |
65 | + | let received = if ((take(valueOrElse(getString(toBase58String(i.caller.bytes)), ""), 8) == "received")) | |
66 | + | then true | |
67 | + | else false | |
68 | + | let isprooved = if (if (if ((trtime > deadline)) | |
69 | + | then true | |
70 | + | else (callerAdress != trsender)) | |
71 | + | then true | |
72 | + | else received) | |
73 | + | then false | |
74 | + | else true | |
75 | + | let result = if (trexists) | |
76 | + | then if ((trtime > deadline)) | |
77 | + | then ("transaction is out of time range: " + toString(trtime)) | |
78 | + | else ("" + (if ((callerAdress != trsender)) | |
79 | + | then ((("it is incorrect sender: " + toString(callerAdress)) + " / ") + toString(trsender)) | |
80 | + | else ("" + (if (received) | |
81 | + | then getStringValue(toBase58String(i.caller.bytes)) | |
82 | + | else ("" + (if (isprooved) | |
83 | + | then "received" | |
84 | + | else "")))))) | |
85 | + | else "can`t find transaction" | |
86 | + | if (isprooved) | |
87 | + | then if ((burnamount > 0)) | |
88 | + | then [ScriptTransfer(callerAdress, dropamount, token), ScriptTransfer(teamAdress, teamgift, token), StringEntry(toBase58String(i.caller.bytes), result), IntegerEntry("dropped", (getIntegerValue("dropped") + dropamount)), IntegerEntry("teamgift", (getIntegerValue("teamgift") + teamgift)), DeleteEntry((toBase58String(i.caller.bytes) + "_error")), Burn(token, burnamount), IntegerEntry("burningstage", (getIntegerValue("burningstage") + burnamount))] | |
89 | + | else [ScriptTransfer(callerAdress, dropamount, token), ScriptTransfer(teamAdress, teamgift, token), StringEntry(toBase58String(i.caller.bytes), result), IntegerEntry("dropped", (getIntegerValue("dropped") + dropamount)), IntegerEntry("teamgift", (getIntegerValue("teamgift") + teamgift)), DeleteEntry((toBase58String(i.caller.bytes) + "_error"))] | |
90 | + | else [StringEntry((toBase58String(i.caller.bytes) + "_error"), result)] | |
91 | + | } | |
92 | + | else throw("Strict value is not equal to itself.") | |
93 | + | } | |
94 | + | ||
95 | + | ||
96 | + | ||
97 | + | @Callable(i) | |
98 | + | func buy () = { | |
99 | + | let currenttime = match blockInfoByHeight(height) { | |
100 | + | case block: BlockInfo => | |
101 | + | block.timestamp | |
102 | + | case _ => | |
103 | + | throw("Can't find block") | |
104 | + | } | |
105 | + | let balance = assetBalance(airdrop, token) | |
106 | + | let sellamount = (1000 * tokend) | |
107 | + | let price1 = (1 * 100000000) | |
108 | + | let price2 = (2 * 100000000) | |
109 | + | let callerAdress = Address(i.caller.bytes) | |
110 | + | let balanceok = if ((balance >= sellamount)) | |
111 | + | then true | |
112 | + | else false | |
113 | + | let callerData = valueOrElse(getString(toBase58String(i.caller.bytes)), "") | |
114 | + | let callerReceived = if ((take(callerData, 8) == "received")) | |
115 | + | then true | |
116 | + | else false | |
117 | + | let callerBuylevel = if (if (callerReceived) | |
118 | + | then (size(split(callerData, "|")) == 1) | |
119 | + | else false) | |
120 | + | then 0 | |
121 | + | else if (if (callerReceived) | |
122 | + | then (size(split(callerData, "|")) == 2) | |
123 | + | else false) | |
124 | + | then 1 | |
125 | + | else 99 | |
126 | + | let callerCanBuy = if (if (callerReceived) | |
127 | + | then if ((callerBuylevel == 0)) | |
128 | + | then true | |
129 | + | else (callerBuylevel == 1) | |
130 | + | else false) | |
131 | + | then true | |
132 | + | else false | |
133 | + | let callerPrice = if ((callerBuylevel == 0)) | |
134 | + | then price1 | |
135 | + | else if ((callerBuylevel == 1)) | |
136 | + | then price2 | |
137 | + | else 0 | |
138 | + | let pmtok = if ((size(i.payments) == 1)) | |
139 | + | then if (if (!(isDefined(i.payments[0].assetId))) | |
140 | + | then (i.payments[0].amount >= callerPrice) | |
141 | + | else false) | |
142 | + | then true | |
143 | + | else false | |
144 | + | else false | |
145 | + | let mess = if (!(callerCanBuy)) | |
146 | + | then "not prooved for buy" | |
147 | + | else ("" + (if (!(pmtok)) | |
148 | + | then "not enough payment" | |
149 | + | else ("" + (if (!(balanceok)) | |
150 | + | then "ballance empty " | |
151 | + | else "")))) | |
152 | + | let datarecs = split(callerData, "|") | |
153 | + | let newdata = if ((callerBuylevel == 0)) | |
154 | + | then (datarecs[0] + "|bought1") | |
155 | + | else if ((callerBuylevel == 1)) | |
156 | + | then (datarecs[0] + "|bought1|bought2") | |
157 | + | else "" | |
158 | + | let deal = if (if (if (balanceok) | |
159 | + | then callerCanBuy | |
160 | + | else false) | |
161 | + | then pmtok | |
162 | + | else false) | |
163 | + | then true | |
164 | + | else false | |
165 | + | if (deal) | |
166 | + | then [StringEntry(toBase58String(i.caller.bytes), newdata), ScriptTransfer(teamAdress, callerPrice, unit), ScriptTransfer(callerAdress, sellamount, token), DeleteEntry((toBase58String(i.caller.bytes) + "_error"))] | |
167 | + | else [StringEntry((toBase58String(i.caller.bytes) + "_error"), mess)] | |
168 | + | } | |
169 | + | ||
170 | + |
github/deemru/w8io/169f3d6 24.74 ms ◑