tx · DzCd7V7HAQVDTTyduKdnwjAS2zSTaiji9XSasPhbtJbV 3MpNtiPSRSq6NnaQYk38BfWSzZcgAYTyrQ9: -0.01400000 Waves 2022.01.10 19:17 [1873057] smart account 3MpNtiPSRSq6NnaQYk38BfWSzZcgAYTyrQ9 > SELF 0.00000000 Waves
{ "type": 13, "id": "DzCd7V7HAQVDTTyduKdnwjAS2zSTaiji9XSasPhbtJbV", "fee": 1400000, "feeAssetId": null, "timestamp": 1641831473116, "version": 2, "chainId": 84, "sender": "3MpNtiPSRSq6NnaQYk38BfWSzZcgAYTyrQ9", "senderPublicKey": "HwnFy5MZJ9eyVKF9GSXN8nuA5uT2rcvnVqHw9vCv3DNn", "proofs": [ "6nby6j8guRjNBV548WUNT8RBcgupQSKvtSzy9AfherPbFijWKqen4nJmsZJeqEdJu6DEUr3WYou8gQu2E9Vaqag" ], "script": "base64:AAIFAAAAAAAAAiMIAhIAEgMKAQgSAwoBBBIAEgAaFAoBQRIPYWxyZWFkeVJlc2VydmVkGhQKAUISD3JlbWFpbmluZ1Rva2VucxoPCgFDEgpyZXNlcnZhYmxlGhUKAUQSEHJlbWFpbmluZ1Rva2VuczIaDQoBRRIIdG9SZWRlZW0aDgoBRhIJcmVtYWluaW5nGg8KAWESCnNoaW55d2dnaWQaEQoBYhIMYWRtaW5BZGRyZXNzGhcKAWMSEnByZXNhbGV0b2tlbmFtb3VudBoYCgFkEhNtYXhUb2tlbnNwZXJBZGRyZXNzGgkKAWUSBHVzZE4aEgoBZhINdHJ5R2V0SW50ZWdlchoICgFnEgNrZXkaDAoBaBIHJG1hdGNoMBoGCgFpEgFiGhIKAWoSDXRyeUdldEJvb2xlYW4aEgoBaxINaXNHYW1lU3RhcnRlZBoSCgFsEg1pc1doaXRlTGlzdGVkGg8KAW0SCmFkZHJlc3NTdHIaFgoBbhIRY2FsY1Rva2VudG9SZWRlZW0aCQoBbxIEYW1udBoQCgFwEgtzdGFydEhlaWdodBoNCgFxEghyZWRlZW1lZBoN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AAAFxBQAAAAFhBQAAAANuaWwJAAACAAAAAQkAASwAAAACCQABLAAAAAICAAAAE3lvdSBjYW4gcmVkZWVtIG1heCAJAAGkAAAAAQUAAAABRgIAAAAGIFNIRUdHAAAAAGSlcsc=", "height": 1873057, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 3tRD2kAddgKNrytVnVoi34vvRXNYXURj4i7rW77UksbD Next: 4iL5jmBbxnik4VbSWPCxUqr4SVsA1XTdQ7679zgtn3s2 Diff:
Old | New | Differences | |
---|---|---|---|
134 | 134 | else { | |
135 | 135 | let toRedeem = calcTokentoRedeem(reservedAmount, addressStr) | |
136 | 136 | let remaining = (reservedAmount - redeemed) | |
137 | - | if (( | |
137 | + | if ((remaining >= toRedeem)) | |
138 | 138 | then [IntegerEntry((addressStr + "_Redeemed"), (redeemed + toRedeem)), ScriptTransfer(i.caller, redeemed, shinywggid)] | |
139 | 139 | else throw((("you can redeem max " + toString(remaining)) + " SHEGG")) | |
140 | 140 | } |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let shinywggid = base58'AFQS5E4ELtxex3iANtWtUU2V2oWJZSo8VVnK8z3VFmqf' | |
5 | 5 | ||
6 | 6 | let adminAddress = addressFromStringValue("3N2fmsxjTetfnJBXEUpnALKcAQeNR4EizQQ") | |
7 | 7 | ||
8 | 8 | let presaletokenamount = 50000000000000 | |
9 | 9 | ||
10 | 10 | let maxTokensperAddress = 10000 | |
11 | 11 | ||
12 | 12 | let usdN = unit | |
13 | 13 | ||
14 | 14 | func tryGetInteger (key) = match getInteger(this, key) { | |
15 | 15 | case b: Int => | |
16 | 16 | b | |
17 | 17 | case _ => | |
18 | 18 | 0 | |
19 | 19 | } | |
20 | 20 | ||
21 | 21 | ||
22 | 22 | func tryGetBoolean (key) = match getBoolean(this, key) { | |
23 | 23 | case b: Boolean => | |
24 | 24 | b | |
25 | 25 | case _ => | |
26 | 26 | false | |
27 | 27 | } | |
28 | 28 | ||
29 | 29 | ||
30 | 30 | func isGameStarted () = tryGetBoolean("Game_Started") | |
31 | 31 | ||
32 | 32 | ||
33 | 33 | func isWhiteListed (addressStr) = tryGetBoolean((addressStr + "_whiteListed")) | |
34 | 34 | ||
35 | 35 | ||
36 | 36 | func calcTokentoRedeem (amnt,addressStr) = { | |
37 | 37 | let startHeight = tryGetInteger("Start_Height") | |
38 | 38 | let redeemed = tryGetInteger((addressStr + "_Redeemed")) | |
39 | 39 | if ((startHeight == 0)) | |
40 | 40 | then throw("Redeem time not started") | |
41 | 41 | else { | |
42 | 42 | let blocknum = (1440 * 180) | |
43 | 43 | if ((lastBlock.height > (startHeight + blocknum))) | |
44 | 44 | then (amnt - redeemed) | |
45 | 45 | else { | |
46 | 46 | let perblock = fraction(amnt, 1, blocknum) | |
47 | 47 | (((lastBlock.height - startHeight) * perblock) - redeemed) | |
48 | 48 | } | |
49 | 49 | } | |
50 | 50 | } | |
51 | 51 | ||
52 | 52 | ||
53 | 53 | @Callable(i) | |
54 | 54 | func init () = [IntegerEntry("Remaining_Tokens", presaletokenamount)] | |
55 | 55 | ||
56 | 56 | ||
57 | 57 | ||
58 | 58 | @Callable(i) | |
59 | 59 | func addToWhiteList (addressStr) = if ((i.caller != this)) | |
60 | 60 | then throw("you are not authorized to perform this operation") | |
61 | 61 | else [BooleanEntry((addressStr + "_whiteListed"), true)] | |
62 | 62 | ||
63 | 63 | ||
64 | 64 | ||
65 | 65 | @Callable(i) | |
66 | 66 | func setStartGame (start) = if ((i.caller != this)) | |
67 | 67 | then throw("you are not authorized to perform this operation") | |
68 | 68 | else [BooleanEntry("Game_Started", start), IntegerEntry("Start_Height", lastBlock.height)] | |
69 | 69 | ||
70 | 70 | ||
71 | 71 | ||
72 | 72 | @Callable(i) | |
73 | 73 | func reserveTokens () = { | |
74 | 74 | let addressStr = toString(i.caller) | |
75 | 75 | let wl = isWhiteListed(addressStr) | |
76 | 76 | if (!(wl)) | |
77 | 77 | then throw("you are not whitelisted!") | |
78 | 78 | else { | |
79 | 79 | let pmt = i.payments[0] | |
80 | 80 | if ((pmt == pmt)) | |
81 | 81 | then { | |
82 | 82 | let amountIn = value(i.payments[0].amount) | |
83 | 83 | if ((amountIn == amountIn)) | |
84 | 84 | then { | |
85 | 85 | let assetIn = pmt.assetId | |
86 | 86 | if ((assetIn == assetIn)) | |
87 | 87 | then { | |
88 | 88 | let reservedAmount = amountIn | |
89 | 89 | if ((reservedAmount == reservedAmount)) | |
90 | 90 | then { | |
91 | 91 | let alreadyReserved = tryGetInteger((addressStr + "_Reserved")) | |
92 | 92 | if ((alreadyReserved == alreadyReserved)) | |
93 | 93 | then { | |
94 | 94 | let remainingTokens = tryGetInteger("Remaining_Tokens") | |
95 | 95 | if ((assetIn != usdN)) | |
96 | 96 | then throw("ONLY USDN ALLOWED") | |
97 | 97 | else if ((0 >= remainingTokens)) | |
98 | 98 | then throw("Presale is out of stock!") | |
99 | 99 | else if ((reservedAmount > remainingTokens)) | |
100 | 100 | then throw((("You can reserve only" + toString(remainingTokens)) + " SHEGG")) | |
101 | 101 | else { | |
102 | 102 | let reservable = (maxTokensperAddress - alreadyReserved) | |
103 | 103 | if ((alreadyReserved > reservable)) | |
104 | 104 | then throw((("You can reserve max " + toString(reservable)) + " SHEGG")) | |
105 | 105 | else { | |
106 | 106 | let remainingTokens2 = (remainingTokens - reservedAmount) | |
107 | 107 | [IntegerEntry((addressStr + "_Reserved"), (reservedAmount + alreadyReserved)), IntegerEntry("Remaining_Tokens", remainingTokens2), ScriptTransfer(adminAddress, amountIn, usdN)] | |
108 | 108 | } | |
109 | 109 | } | |
110 | 110 | } | |
111 | 111 | else throw("Strict value is not equal to itself.") | |
112 | 112 | } | |
113 | 113 | else throw("Strict value is not equal to itself.") | |
114 | 114 | } | |
115 | 115 | else throw("Strict value is not equal to itself.") | |
116 | 116 | } | |
117 | 117 | else throw("Strict value is not equal to itself.") | |
118 | 118 | } | |
119 | 119 | else throw("Strict value is not equal to itself.") | |
120 | 120 | } | |
121 | 121 | } | |
122 | 122 | ||
123 | 123 | ||
124 | 124 | ||
125 | 125 | @Callable(i) | |
126 | 126 | func redeem () = if (!(isGameStarted())) | |
127 | 127 | then throw("Cannot redeem anything before the game starts!") | |
128 | 128 | else { | |
129 | 129 | let addressStr = toString(i.caller) | |
130 | 130 | let reservedAmount = tryGetInteger((addressStr + "_Reserved")) | |
131 | 131 | let redeemed = tryGetInteger((addressStr + "_Redeemed")) | |
132 | 132 | if ((reservedAmount == 0)) | |
133 | 133 | then throw("Nothing to redeem") | |
134 | 134 | else { | |
135 | 135 | let toRedeem = calcTokentoRedeem(reservedAmount, addressStr) | |
136 | 136 | let remaining = (reservedAmount - redeemed) | |
137 | - | if (( | |
137 | + | if ((remaining >= toRedeem)) | |
138 | 138 | then [IntegerEntry((addressStr + "_Redeemed"), (redeemed + toRedeem)), ScriptTransfer(i.caller, redeemed, shinywggid)] | |
139 | 139 | else throw((("you can redeem max " + toString(remaining)) + " SHEGG")) | |
140 | 140 | } | |
141 | 141 | } | |
142 | 142 | ||
143 | 143 |
github/deemru/w8io/026f985 24.74 ms ◑