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/IrzTjRqRT1pNRXalTwMQKQXJi2gAAAAMAAAABaQEAAAAFcmVzZXQAAAAACQAETAAAAAIJAQAAAAtEZWxldGVFbnRyeQAAAAEJAAJYAAAAAQgIBQAAAAFpAAAABmNhbGxlcgAAAAVieXRlcwkABEwAAAACCQEAAAAMSW50ZWdlckVudHJ5AAAAAgIAAAAFYnVybnQAAAAAAAAAAAAJAARMAAAAAgkBAAAADEludGVnZXJFbnRyeQAAAAICAAAAB2Ryb3BwZWQAAAAAAAAAAAAJAARMAAAAAgkBAAAADEludGVnZXJFbnRyeQAAAAICAAAACHRlYW1naWZ0AAAAAAAAAAAACQAETAAAAAIJAQAAAAxJbnRlZ2VyRW50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Complexity": 0 } View: original | compacted Prev: CLjMd9tz5CyXzsaQfYCdFeBE5Job8UrBqTtQ4rfkzxEU Next: 4yKUCEDhXTrgnyNCrHCc4gU2f2ahsfcE2sNLEr7R3z4p Diff:
OldNewDifferences
55
66 let airdrop = Address(base58'3N7Gg64FJ3ESaqn41qu1ete7zmzbmoP1AAV')
77
8+let teamAdress = Address(base58'3MovsLjXpJr9HD2vBqmAf7Gze6jwuRxX1fX')
9+
810 @Callable(i)
9-func reset () = [DeleteEntry(toBase58String(i.caller.bytes)), DeleteEntry((toBase58String(i.caller.bytes) + "_result")), IntegerEntry("burningstage", 0)]
11+func reset () = [DeleteEntry(toBase58String(i.caller.bytes)), IntegerEntry("burnt", 0), IntegerEntry("dropped", 0), IntegerEntry("teamgift", 0), IntegerEntry("burningstage", 0)]
1012
1113
1214
3032 throw("no burningstage")
3133 }
3234 let dropamount = 1000
35+ let teamgift = 10
36+ let trid = fromBase58String(id58)
37+ let callerAdress = Address(i.caller.bytes)
38+ let deadline = 1639230864311
3339 let isenough = if ((balance > dropamount))
3440 then true
3541 else throw("not enough")
3642 if ((isenough == isenough))
3743 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) {
4245 case ttx: TransferTransaction =>
4346 true
4447 case _ =>
4548 false
4649 }
47- let trtime = match transferTransactionById(id) {
50+ let trtime = match transferTransactionById(trid) {
4851 case ttx: TransferTransaction =>
4952 ttx.timestamp
5053 case _ =>
5154 9999999999999
5255 }
53- let trsender = match transferTransactionById(id) {
56+ let trsender = match transferTransactionById(trid) {
5457 case ttx: TransferTransaction =>
5558 ttx.sender
5659 case _ =>
5962 let received = if ((take(valueOrElse(getString(toBase58String(i.caller.bytes)), ""), 8) == "received"))
6063 then true
6164 else false
62- let isprooved = if (if (if ((trtime > time))
65+ let isprooved = if (if (if ((trtime > deadline))
6366 then true
6467 else (callerAdress != trsender))
6568 then true
6770 then false
6871 else true
6972 let result = if (trexists)
70- then if ((trtime > time))
73+ then if ((trtime > deadline))
7174 then ("transaction is out of time range: " + toString(trtime))
7275 else ("" + (if ((callerAdress != trsender))
7376 then ((("it is incorrect sender: " + toString(callerAdress)) + " / ") + toString(trsender))
7982 else "cant find transaction"
8083 if (isprooved)
8184 then if ((burnamount > 0))
82- then [ScriptTransfer(callerAdress, dropamount, token), StringEntry(toBase58String(i.caller.bytes), result)]
83- else [StringEntry(toBase58String(i.caller.bytes), result), ScriptTransfer(callerAdress, dropamount, token)]
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))]
8487 else [StringEntry(toBase58String(i.caller.bytes), result)]
8588 }
8689 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)]
87158 }
88159
89160
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 5 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let token = base58'GZc7eKnq2KJwqetRmUzSqr2ZaCGseDZufSocz83sUNoo'
55
66 let airdrop = Address(base58'3N7Gg64FJ3ESaqn41qu1ete7zmzbmoP1AAV')
77
8+let teamAdress = Address(base58'3MovsLjXpJr9HD2vBqmAf7Gze6jwuRxX1fX')
9+
810 @Callable(i)
9-func reset () = [DeleteEntry(toBase58String(i.caller.bytes)), DeleteEntry((toBase58String(i.caller.bytes) + "_result")), IntegerEntry("burningstage", 0)]
11+func reset () = [DeleteEntry(toBase58String(i.caller.bytes)), IntegerEntry("burnt", 0), IntegerEntry("dropped", 0), IntegerEntry("teamgift", 0), IntegerEntry("burningstage", 0)]
1012
1113
1214
1315 @Callable(i)
1416 func call (id58) = {
1517 let currenttime = match blockInfoByHeight(height) {
1618 case block: BlockInfo =>
1719 block.timestamp
1820 case _ =>
1921 throw("Can't find block")
2022 }
2123 let balance = assetBalance(airdrop, token)
2224 let burnamount = match getInteger("burningstage") {
2325 case a: Int =>
2426 if (if ((getIntegerValue("burningstage") == 0))
2527 then (currenttime > 1639131654752)
2628 else false)
2729 then fraction(balance, 10, 100)
2830 else 0
2931 case _ =>
3032 throw("no burningstage")
3133 }
3234 let dropamount = 1000
35+ let teamgift = 10
36+ let trid = fromBase58String(id58)
37+ let callerAdress = Address(i.caller.bytes)
38+ let deadline = 1639230864311
3339 let isenough = if ((balance > dropamount))
3440 then true
3541 else throw("not enough")
3642 if ((isenough == isenough))
3743 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) {
4245 case ttx: TransferTransaction =>
4346 true
4447 case _ =>
4548 false
4649 }
47- let trtime = match transferTransactionById(id) {
50+ let trtime = match transferTransactionById(trid) {
4851 case ttx: TransferTransaction =>
4952 ttx.timestamp
5053 case _ =>
5154 9999999999999
5255 }
53- let trsender = match transferTransactionById(id) {
56+ let trsender = match transferTransactionById(trid) {
5457 case ttx: TransferTransaction =>
5558 ttx.sender
5659 case _ =>
5760 airdrop
5861 }
5962 let received = if ((take(valueOrElse(getString(toBase58String(i.caller.bytes)), ""), 8) == "received"))
6063 then true
6164 else false
62- let isprooved = if (if (if ((trtime > time))
65+ let isprooved = if (if (if ((trtime > deadline))
6366 then true
6467 else (callerAdress != trsender))
6568 then true
6669 else received)
6770 then false
6871 else true
6972 let result = if (trexists)
70- then if ((trtime > time))
73+ then if ((trtime > deadline))
7174 then ("transaction is out of time range: " + toString(trtime))
7275 else ("" + (if ((callerAdress != trsender))
7376 then ((("it is incorrect sender: " + toString(callerAdress)) + " / ") + toString(trsender))
7477 else ("" + (if (received)
7578 then getStringValue(toBase58String(i.caller.bytes))
7679 else ("" + (if (isprooved)
7780 then ("received in " + toString(currenttime))
7881 else ""))))))
7982 else "cant find transaction"
8083 if (isprooved)
8184 then if ((burnamount > 0))
82- then [ScriptTransfer(callerAdress, dropamount, token), StringEntry(toBase58String(i.caller.bytes), result)]
83- else [StringEntry(toBase58String(i.caller.bytes), result), ScriptTransfer(callerAdress, dropamount, token)]
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))]
8487 else [StringEntry(toBase58String(i.caller.bytes), result)]
8588 }
8689 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)]
87158 }
88159
89160

github/deemru/w8io/026f985 
31.83 ms