tx · 24T724h9MUjHFmPvtz9cBbWGrvuzFVmSyf6P9V9oTX5J 3MpNtiPSRSq6NnaQYk38BfWSzZcgAYTyrQ9: -0.01400000 Waves 2022.01.10 17:27 [1872944] smart account 3MpNtiPSRSq6NnaQYk38BfWSzZcgAYTyrQ9 > SELF 0.00000000 Waves
{ "type": 13, "id": "24T724h9MUjHFmPvtz9cBbWGrvuzFVmSyf6P9V9oTX5J", "fee": 1400000, "feeAssetId": null, "timestamp": 1641824894066, "version": 2, "chainId": 84, "sender": "3MpNtiPSRSq6NnaQYk38BfWSzZcgAYTyrQ9", "senderPublicKey": "HwnFy5MZJ9eyVKF9GSXN8nuA5uT2rcvnVqHw9vCv3DNn", "proofs": [ "22iEGt72c4jtqFSQhJrtNxv2EdsvfXqJHNWqXN2KS9ceEqPhE8kgvhxMzdGvKq3NGsjHPiGi8QcaMwLCx3ev29nc" ], "script": "base64:AAIFAAAAAAAAAbEIAhIAEgMKAQgSAwoBBBIAEgAaDwoBYRIKc2hpbnl3Z2dpZBoRCgFiEgxhZG1pbkFkZHJlc3MaFwoBYxIScHJlc2FsZXRva2VuYW1vdW50GhgKAWQSE21heFRva2Vuc3BlckFkZHJlc3MaCQoBZRIEdXNkThoSCgFmEg10cnlHZXRJbnRlZ2VyGggKAWcSA2tleRoMCgFoEgckbWF0Y2gwGgYKAWkSAWIaEgoBahINdHJ5R2V0Qm9vbGVhbhoSCgFrEg1pc0dhbWVTdGFydGVkGhIKAWwSDWlzV2hpdGVMaXN0ZWQaDwoBbRIKYWRkcmVzc1N0choGCgFuEgFpGgoKAW8SBXN0YXJ0GgcKAXASAndsGggKAXESA3BtdBoNCgFyEghhbW91bnRJbhoMCgFzEgdhc3NldEluGhMKAXQSDnJlc2VydmVkQW1vdW50GhQKAXUSD2FscmVhZHlSZXNlcnZlZBoUCgF2Eg9yZW1haW5pbmdUb2tlbnMaDwoBdxIKcmVzZXJ2YWJsZRoVCgF4EhByZW1haW5pbmdUb2tlbnMyGg0KAXkSC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AgAAAAECAAAAEU5vdGhpbmcgdG8gcmVkZWVtBAAAAAF5BQAAAAF0CQAETAAAAAIJAQAAAAxJbnRlZ2VyRW50cnkAAAACCQABLAAAAAIFAAAAAW0CAAAACV9SZXNlcnZlZAkAAGUAAAACBQAAAAF0BQAAAAF5CQAETAAAAAIJAQAAAA5TY3JpcHRUcmFuc2ZlcgAAAAMIBQAAAAFuAAAABmNhbGxlcgUAAAABeQUAAAABYQUAAAADbmlsAAAAAEpVrhs=", "height": 1872944, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: CMpHpL2Q3XU5N77R63XpHfW7ojg1XtU4thZCZZqrVQeY Next: EaRcG4nb1WzmggqDbJSKxF55veTm9rfk7m1ZquczE8Fw Diff:
Old | New | Differences | |
---|---|---|---|
104 | 104 | } | |
105 | 105 | ||
106 | 106 | ||
107 | + | ||
108 | + | @Callable(i) | |
109 | + | func redeem () = if (!(isGameStarted())) | |
110 | + | then throw("Cannot redeem anything before the game starts!") | |
111 | + | else { | |
112 | + | let addressStr = toString(i.caller) | |
113 | + | let reservedAmount = tryGetInteger((addressStr + "_Reserved")) | |
114 | + | if ((reservedAmount == 0)) | |
115 | + | then throw("Nothing to redeem") | |
116 | + | else { | |
117 | + | let redeemed = reservedAmount | |
118 | + | [IntegerEntry((addressStr + "_Reserved"), (reservedAmount - redeemed)), ScriptTransfer(i.caller, redeemed, shinywggid)] | |
119 | + | } | |
120 | + | } | |
121 | + | ||
122 | + |
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 | @Callable(i) | |
37 | 37 | func init () = [IntegerEntry("Remaining_Tokens", presaletokenamount)] | |
38 | 38 | ||
39 | 39 | ||
40 | 40 | ||
41 | 41 | @Callable(i) | |
42 | 42 | func addToWhiteList (addressStr) = if ((i.caller != this)) | |
43 | 43 | then throw("you are not authorized to perform this operation") | |
44 | 44 | else [BooleanEntry((addressStr + "_whiteListed"), true)] | |
45 | 45 | ||
46 | 46 | ||
47 | 47 | ||
48 | 48 | @Callable(i) | |
49 | 49 | func setStartGame (start) = if ((i.caller != this)) | |
50 | 50 | then throw("you are not authorized to perform this operation") | |
51 | 51 | else [BooleanEntry("Game_Started", start)] | |
52 | 52 | ||
53 | 53 | ||
54 | 54 | ||
55 | 55 | @Callable(i) | |
56 | 56 | func reserveTokens () = { | |
57 | 57 | let addressStr = toString(i.caller) | |
58 | 58 | let wl = isWhiteListed(addressStr) | |
59 | 59 | if (!(wl)) | |
60 | 60 | then throw("you are not whitelisted!") | |
61 | 61 | else { | |
62 | 62 | let pmt = i.payments[0] | |
63 | 63 | if ((pmt == pmt)) | |
64 | 64 | then { | |
65 | 65 | let amountIn = value(i.payments[0].amount) | |
66 | 66 | if ((amountIn == amountIn)) | |
67 | 67 | then { | |
68 | 68 | let assetIn = pmt.assetId | |
69 | 69 | if ((assetIn == assetIn)) | |
70 | 70 | then { | |
71 | 71 | let reservedAmount = amountIn | |
72 | 72 | if ((reservedAmount == reservedAmount)) | |
73 | 73 | then { | |
74 | 74 | let alreadyReserved = tryGetInteger((addressStr + "_Reserved")) | |
75 | 75 | if ((alreadyReserved == alreadyReserved)) | |
76 | 76 | then { | |
77 | 77 | let remainingTokens = tryGetInteger("Remaining_Tokens") | |
78 | 78 | if ((assetIn != usdN)) | |
79 | 79 | then throw("ONLY USDN ALLOWED") | |
80 | 80 | else if ((0 >= remainingTokens)) | |
81 | 81 | then throw("Presale is out of stock!") | |
82 | 82 | else if ((reservedAmount > remainingTokens)) | |
83 | 83 | then throw((("You can reserve only" + toString(remainingTokens)) + " SHEGG")) | |
84 | 84 | else { | |
85 | 85 | let reservable = (maxTokensperAddress - alreadyReserved) | |
86 | 86 | if ((alreadyReserved > reservable)) | |
87 | 87 | then throw((("You can reserve max " + toString(reservable)) + " SHEGG")) | |
88 | 88 | else { | |
89 | 89 | let remainingTokens2 = (remainingTokens - reservedAmount) | |
90 | 90 | [IntegerEntry((addressStr + "_Reserved"), (reservedAmount + alreadyReserved)), IntegerEntry("Remaining_Tokens", remainingTokens2), ScriptTransfer(adminAddress, amountIn, usdN)] | |
91 | 91 | } | |
92 | 92 | } | |
93 | 93 | } | |
94 | 94 | else throw("Strict value is not equal to itself.") | |
95 | 95 | } | |
96 | 96 | else throw("Strict value is not equal to itself.") | |
97 | 97 | } | |
98 | 98 | else throw("Strict value is not equal to itself.") | |
99 | 99 | } | |
100 | 100 | else throw("Strict value is not equal to itself.") | |
101 | 101 | } | |
102 | 102 | else throw("Strict value is not equal to itself.") | |
103 | 103 | } | |
104 | 104 | } | |
105 | 105 | ||
106 | 106 | ||
107 | + | ||
108 | + | @Callable(i) | |
109 | + | func redeem () = if (!(isGameStarted())) | |
110 | + | then throw("Cannot redeem anything before the game starts!") | |
111 | + | else { | |
112 | + | let addressStr = toString(i.caller) | |
113 | + | let reservedAmount = tryGetInteger((addressStr + "_Reserved")) | |
114 | + | if ((reservedAmount == 0)) | |
115 | + | then throw("Nothing to redeem") | |
116 | + | else { | |
117 | + | let redeemed = reservedAmount | |
118 | + | [IntegerEntry((addressStr + "_Reserved"), (reservedAmount - redeemed)), ScriptTransfer(i.caller, redeemed, shinywggid)] | |
119 | + | } | |
120 | + | } | |
121 | + | ||
122 | + |
github/deemru/w8io/026f985 28.20 ms ◑