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