tx · EaRcG4nb1WzmggqDbJSKxF55veTm9rfk7m1ZquczE8Fw

3MpNtiPSRSq6NnaQYk38BfWSzZcgAYTyrQ9:  -0.01400000 Waves

2022.01.10 18:24 [1873000] smart account 3MpNtiPSRSq6NnaQYk38BfWSzZcgAYTyrQ9 > SELF 0.00000000 Waves

{ "type": 13, "id": "EaRcG4nb1WzmggqDbJSKxF55veTm9rfk7m1ZquczE8Fw", "fee": 1400000, "feeAssetId": null, "timestamp": 1641828339850, "version": 2, "chainId": 84, "sender": "3MpNtiPSRSq6NnaQYk38BfWSzZcgAYTyrQ9", "senderPublicKey": "HwnFy5MZJ9eyVKF9GSXN8nuA5uT2rcvnVqHw9vCv3DNn", "proofs": [ "33cJih4zuETrhRyfpqyrAB6uKZtV82ckz9BTaqD4zW7GfjCEkgLBQPZgC6MbCo1UWqXo4QLwv8morsfDxYNYmsNL" ], "script": "base64:AAIFAAAAAAAAAh0IAhIAEgMKAQgSAwoBBBIAEgAaFAoBQRIPcmVtYWluaW5nVG9rZW5zGg8KAUISCnJlc2VydmFibGUaFQoBQxIQcmVtYWluaW5nVG9rZW5zMhoNCgFEEghyZWRlZW1lZBoNCgFFEgh0b1JlZGVlbRoOCgFGEglyZW1haW5pbmcaDwoBYRIKc2hpbnl3Z2dpZBoRCgFiEgxhZG1pbkFkZHJlc3MaFwoBYxIScHJlc2FsZXRva2VuYW1vdW50GhgKAWQSE21heFRva2Vuc3BlckFkZHJlc3MaCQoBZRIEdXNkThoSCgFmEg10cnlHZXRJbnRlZ2VyGggKAWcSA2tleRoMCgFoEgckbWF0Y2gwGgYKAWkSAWIaEgoBahINdHJ5R2V0Qm9vbGVhbhoSCgFrEg1pc0dhbWVTdGFydGVkGhIKAWwSDWlzV2hpdGVMaXN0ZWQaDwoBbRIKYWRkcmVzc1N0choWCgFuEhFjYWxjVG9rZW50b1JlZGVlbRoJCgFvEgRhbW50Gg4KAXASCWVuZGhlaWdodBoLCgFxEgZwYXNzZWQaCwoBchIGcGVyZ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AAAAkU3RyaWN0IHZhbHVlIGlzIG5vdCBlcXVhbCB0byBpdHNlbGYuCQAAAgAAAAECAAAAJFN0cmljdCB2YWx1ZSBpcyBub3QgZXF1YWwgdG8gaXRzZWxmLgkAAAIAAAABAgAAACRTdHJpY3QgdmFsdWUgaXMgbm90IGVxdWFsIHRvIGl0c2VsZi4JAAACAAAAAQIAAAAkU3RyaWN0IHZhbHVlIGlzIG5vdCBlcXVhbCB0byBpdHNlbGYuAAAAAXMBAAAABnJlZGVlbQAAAAADCQEAAAABIQAAAAEJAQAAAAFrAAAAAAkAAAIAAAABAgAAAC5DYW5ub3QgcmVkZWVtIGFueXRoaW5nIGJlZm9yZSB0aGUgZ2FtZSBzdGFydHMhBAAAAAFtCQAEJQAAAAEIBQAAAAFzAAAABmNhbGxlcgQAAAABeQkBAAAAAWYAAAABCQABLAAAAAIFAAAAAW0CAAAACV9SZXNlcnZlZAQAAAABRAkBAAAAAWYAAAABCQABLAAAAAIFAAAAAW0CAAAACV9SZWRlZW1lZAMJAAAAAAAAAgUAAAABeQAAAAAAAAAAAAkAAAIAAAABAgAAABFOb3RoaW5nIHRvIHJlZGVlbQQAAAABRQkBAAAAAW4AAAABBQAAAAF5BAAAAAFGCQAAZQAAAAIFAAAAAXkFAAAAAUQDCQAAZwAAAAIFAAAAAUUFAAAAAUYJAARMAAAAAgkBAAAADEludGVnZXJFbnRyeQAAAAIJAAEsAAAAAgUAAAABbQIAAAAJX1JlZGVlbWVkCQAAZAAAAAIFAAAAAUQFAAAAAUUJAARMAAAAAgkBAAAADlNjcmlwdFRyYW5zZmVyAAAAAwgFAAAAAXMAAAAGY2FsbGVyBQAAAAFEBQAAAAFhBQAAAANuaWwJAAACAAAAAQkAASwAAAACCQABLAAAAAICAAAAE3lvdSBjYW4gcmVkZWVtIG1heCAJAAGkAAAAAQUAAAABRgIAAAAGIFNIRUdHAAAAAKObB8A=", "height": 1873000, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 24T724h9MUjHFmPvtz9cBbWGrvuzFVmSyf6P9V9oTX5J Next: 3tRD2kAddgKNrytVnVoi34vvRXNYXURj4i7rW77UksbD Diff:
OldNewDifferences
3333 func isWhiteListed (addressStr) = tryGetBoolean((addressStr + "_whiteListed"))
3434
3535
36+func calcTokentoRedeem (amnt) = {
37+ let endheight = tryGetInteger("End_Height")
38+ if ((endheight == 0))
39+ then 0
40+ else {
41+ let passed = fraction((endheight - lastBlock.height), 1, 1440)
42+ let perday = fraction(amnt, 1, 180)
43+ (passed * perday)
44+ }
45+ }
46+
47+
3648 @Callable(i)
3749 func init () = [IntegerEntry("Remaining_Tokens", presaletokenamount)]
3850
4860 @Callable(i)
4961 func setStartGame (start) = if ((i.caller != this))
5062 then throw("you are not authorized to perform this operation")
51- else [BooleanEntry("Game_Started", start)]
63+ else [BooleanEntry("Game_Started", start), IntegerEntry("End_Height", (lastBlock.height + (1440 * 180)))]
5264
5365
5466
111123 else {
112124 let addressStr = toString(i.caller)
113125 let reservedAmount = tryGetInteger((addressStr + "_Reserved"))
126+ let redeemed = tryGetInteger((addressStr + "_Redeemed"))
114127 if ((reservedAmount == 0))
115128 then throw("Nothing to redeem")
116129 else {
117- let redeemed = reservedAmount
118-[IntegerEntry((addressStr + "_Reserved"), (reservedAmount - redeemed)), ScriptTransfer(i.caller, redeemed, shinywggid)]
130+ let toRedeem = calcTokentoRedeem(reservedAmount)
131+ let remaining = (reservedAmount - redeemed)
132+ if ((toRedeem >= remaining))
133+ then [IntegerEntry((addressStr + "_Redeemed"), (redeemed + toRedeem)), ScriptTransfer(i.caller, redeemed, shinywggid)]
134+ else throw((("you can redeem max " + toString(remaining)) + " SHEGG"))
119135 }
120136 }
121137
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 5 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let shinywggid = base58'AFQS5E4ELtxex3iANtWtUU2V2oWJZSo8VVnK8z3VFmqf'
55
66 let adminAddress = addressFromStringValue("3N2fmsxjTetfnJBXEUpnALKcAQeNR4EizQQ")
77
88 let presaletokenamount = 50000000000000
99
1010 let maxTokensperAddress = 10000
1111
1212 let usdN = unit
1313
1414 func tryGetInteger (key) = match getInteger(this, key) {
1515 case b: Int =>
1616 b
1717 case _ =>
1818 0
1919 }
2020
2121
2222 func tryGetBoolean (key) = match getBoolean(this, key) {
2323 case b: Boolean =>
2424 b
2525 case _ =>
2626 false
2727 }
2828
2929
3030 func isGameStarted () = tryGetBoolean("Game_Started")
3131
3232
3333 func isWhiteListed (addressStr) = tryGetBoolean((addressStr + "_whiteListed"))
3434
3535
36+func calcTokentoRedeem (amnt) = {
37+ let endheight = tryGetInteger("End_Height")
38+ if ((endheight == 0))
39+ then 0
40+ else {
41+ let passed = fraction((endheight - lastBlock.height), 1, 1440)
42+ let perday = fraction(amnt, 1, 180)
43+ (passed * perday)
44+ }
45+ }
46+
47+
3648 @Callable(i)
3749 func init () = [IntegerEntry("Remaining_Tokens", presaletokenamount)]
3850
3951
4052
4153 @Callable(i)
4254 func addToWhiteList (addressStr) = if ((i.caller != this))
4355 then throw("you are not authorized to perform this operation")
4456 else [BooleanEntry((addressStr + "_whiteListed"), true)]
4557
4658
4759
4860 @Callable(i)
4961 func setStartGame (start) = if ((i.caller != this))
5062 then throw("you are not authorized to perform this operation")
51- else [BooleanEntry("Game_Started", start)]
63+ else [BooleanEntry("Game_Started", start), IntegerEntry("End_Height", (lastBlock.height + (1440 * 180)))]
5264
5365
5466
5567 @Callable(i)
5668 func reserveTokens () = {
5769 let addressStr = toString(i.caller)
5870 let wl = isWhiteListed(addressStr)
5971 if (!(wl))
6072 then throw("you are not whitelisted!")
6173 else {
6274 let pmt = i.payments[0]
6375 if ((pmt == pmt))
6476 then {
6577 let amountIn = value(i.payments[0].amount)
6678 if ((amountIn == amountIn))
6779 then {
6880 let assetIn = pmt.assetId
6981 if ((assetIn == assetIn))
7082 then {
7183 let reservedAmount = amountIn
7284 if ((reservedAmount == reservedAmount))
7385 then {
7486 let alreadyReserved = tryGetInteger((addressStr + "_Reserved"))
7587 if ((alreadyReserved == alreadyReserved))
7688 then {
7789 let remainingTokens = tryGetInteger("Remaining_Tokens")
7890 if ((assetIn != usdN))
7991 then throw("ONLY USDN ALLOWED")
8092 else if ((0 >= remainingTokens))
8193 then throw("Presale is out of stock!")
8294 else if ((reservedAmount > remainingTokens))
8395 then throw((("You can reserve only" + toString(remainingTokens)) + " SHEGG"))
8496 else {
8597 let reservable = (maxTokensperAddress - alreadyReserved)
8698 if ((alreadyReserved > reservable))
8799 then throw((("You can reserve max " + toString(reservable)) + " SHEGG"))
88100 else {
89101 let remainingTokens2 = (remainingTokens - reservedAmount)
90102 [IntegerEntry((addressStr + "_Reserved"), (reservedAmount + alreadyReserved)), IntegerEntry("Remaining_Tokens", remainingTokens2), ScriptTransfer(adminAddress, amountIn, usdN)]
91103 }
92104 }
93105 }
94106 else throw("Strict value is not equal to itself.")
95107 }
96108 else throw("Strict value is not equal to itself.")
97109 }
98110 else throw("Strict value is not equal to itself.")
99111 }
100112 else throw("Strict value is not equal to itself.")
101113 }
102114 else throw("Strict value is not equal to itself.")
103115 }
104116 }
105117
106118
107119
108120 @Callable(i)
109121 func redeem () = if (!(isGameStarted()))
110122 then throw("Cannot redeem anything before the game starts!")
111123 else {
112124 let addressStr = toString(i.caller)
113125 let reservedAmount = tryGetInteger((addressStr + "_Reserved"))
126+ let redeemed = tryGetInteger((addressStr + "_Redeemed"))
114127 if ((reservedAmount == 0))
115128 then throw("Nothing to redeem")
116129 else {
117- let redeemed = reservedAmount
118-[IntegerEntry((addressStr + "_Reserved"), (reservedAmount - redeemed)), ScriptTransfer(i.caller, redeemed, shinywggid)]
130+ let toRedeem = calcTokentoRedeem(reservedAmount)
131+ let remaining = (reservedAmount - redeemed)
132+ if ((toRedeem >= remaining))
133+ then [IntegerEntry((addressStr + "_Redeemed"), (redeemed + toRedeem)), ScriptTransfer(i.caller, redeemed, shinywggid)]
134+ else throw((("you can redeem max " + toString(remaining)) + " SHEGG"))
119135 }
120136 }
121137
122138

github/deemru/w8io/026f985 
24.96 ms