tx · 2f5x7nbCvqQJdbYXRvaAsrQiQZwqDGMJUjirizcv1Ys7 3NBEbFU6dKpoAcsbaEK2aC62UQMjYFW4xiL: -0.05000000 Waves 2021.02.20 13:17 [1406333] smart account 3NBEbFU6dKpoAcsbaEK2aC62UQMjYFW4xiL > SELF 0.00000000 Waves
{ "type": 13, "id": "2f5x7nbCvqQJdbYXRvaAsrQiQZwqDGMJUjirizcv1Ys7", "fee": 5000000, "feeAssetId": null, "timestamp": 1613816281594, "version": 2, "chainId": 84, "sender": "3NBEbFU6dKpoAcsbaEK2aC62UQMjYFW4xiL", "senderPublicKey": "AwmS57W97dpK3Bs6tsewG3YaYgJukDtmEZFbG1oQTV4T", "proofs": [ "5UNVMh8PLxZVwZg7bXVYGc7gJ8Xq379z6Csg44EWg3NZK1T1JeKb3b7QH1X5k1hgUktdvNhzd8HhPMGQeMvkeeb6" ], "script": "base64:AAIDAAAAAAAAABAIARIDCgEIEgASAwoBARIAAAAACgAAAAAHUlVOTklORwIAAAAHUlVOTklORwAAAAAGQ0xPU0VEAgAAAAZDTE9TRUQAAAAACENBTkNFTEVEAgAAAAhDQU5DRUxFRAAAAAAJREFQUE9XTkVSAgAAACMzTkJFYkZVNmRLcG9BY3NiYUVLMmFDNjJVUU1qWUZXNHhpTAAAAAAFV0FWRVMCAAAABVdBVkVTAAAAAAROT05FAgAAAAROT05FAAAAAANGRUUAAAAAAAANu6ABAAAACnJhbmRvbWl6ZXIAAAABAAAAA2ludgQAAAAIbGFzdFBsYXkEAAAAByRtYXRjaDAJAAQcAAAAAgUAAAAEdGhpcwIAAAAPZXh0cmFjdGVkTnVtYmVyAwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAApCeXRlVmVjdG9yBAAAAAFzBQAAAAckbWF0Y2gwBQAAAAFzAwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAARVbml0AQAAAAxXYXZlc0xvdHRvVjIJAAACAAAAAQIAAAALTWF0Y2ggZXJyb3IEAAAABHJhbmQJAADLA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fcHJpemUAAAAAAAAAAAAFAAAAA25pbAAAAAEAAAACdHgBAAAABnZlcmlmeQAAAAAEAAAAByRtYXRjaDAFAAAAAnR4AwMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAAUU2V0U2NyaXB0VHJhbnNhY3Rpb24GCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAD0RhdGFUcmFuc2FjdGlvbgkAAfQAAAADCAUAAAACdHgAAAAJYm9keUJ5dGVzCQABkQAAAAIIBQAAAAJ0eAAAAAZwcm9vZnMAAAAAAAAAAAAIBQAAAAJ0eAAAAA9zZW5kZXJQdWJsaWNLZXkDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAF0ludm9rZVNjcmlwdFRyYW5zYWN0aW9uBgaBenii", "height": 1406333, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: FHKMHqtsJvcUSfThRCv79fBVZDJ2cT15z2QAkWbBBmkS Next: Bqg2a9kuT4GLzNY7NyDAxW9pLYjkr6wQvcByBT1n1rvp Diff:
Old | New | Differences | |
---|---|---|---|
86 | 86 | ||
87 | 87 | ||
88 | 88 | @Callable(i) | |
89 | - | func bet ( | |
89 | + | func bet (guessedNumber) = { | |
90 | 90 | let account = toBase58String(i.caller.bytes) | |
91 | 91 | let pmt = extract(i.payment) | |
92 | 92 | let contestCurrNumber = getNumByKey("contest_currentnumber") | |
95 | 95 | let contestCurrStatus = getStrByKey((("contest_" + toString(contestCurrNumber)) + "_status")) | |
96 | 96 | let contestStatus = getStrByKey((("contest_" + toString(contestCurrNumber)) + "_status")) | |
97 | 97 | let accountBetsNumber = getNumByKey((((("contest_" + toString(contestCurrNumber)) + "_") + account) + "_bets")) | |
98 | - | let existingBetAccount = getStrByKey(((("bet_" + toString(contestCurrNumber)) + "_") + toString( | |
98 | + | let existingBetAccount = getStrByKey(((("bet_" + toString(contestCurrNumber)) + "_") + toString(guessedNumber))) | |
99 | 99 | if ((height > (contestFinishHeight - (2 * 1440)))) | |
100 | 100 | then throw("You cannot bet anymore at this height.") | |
101 | 101 | else if ((contestCurrStatus != RUNNING)) | |
106 | 106 | then throw((("Another wallet: " + existingBetAccount) + " took this number.")) | |
107 | 107 | else if ((accountBetsNumber >= 1)) | |
108 | 108 | then throw("You can chose at most one number.") | |
109 | - | else WriteSet([DataEntry(((("bet_" + toString(contestCurrNumber)) + "_") + toString(currencyValue)), account), DataEntry((((("contest_" + toString(contestCurrNumber)) + "_") + account) + "_bets"), (accountBetsNumber + 1))]) | |
109 | + | else if ((contestCurrStatus != RUNNING)) | |
110 | + | then throw(("Invalid status: you cannot bet now, contest status is: " + contestCurrStatus)) | |
111 | + | else if (if ((0 > guessedNumber)) | |
112 | + | then true | |
113 | + | else (guessedNumber > 99)) | |
114 | + | then throw("You can select a number between 0 and 99") | |
115 | + | else WriteSet([DataEntry(((("bet_" + toString(contestCurrNumber)) + "_") + toString(guessedNumber)), account), DataEntry((((("contest_" + toString(contestCurrNumber)) + "_") + account) + "_bets"), (accountBetsNumber + 1))]) | |
110 | 116 | } | |
111 | 117 | ||
112 | 118 | ||
114 | 120 | @Callable(i) | |
115 | 121 | func closecontest () = { | |
116 | 122 | let rand = randomizer(i) | |
117 | - | let extractedNumber = (toInt(rand) % | |
123 | + | let extractedNumber = (toInt(rand) % 100) | |
118 | 124 | let contestCurrNumber = getNumByKey("contest_currentnumber") | |
119 | 125 | let winningBetAccount = getStrByKey(((("bet_" + toString(contestCurrNumber)) + "_") + toString(1))) | |
120 | 126 | let contestFinishHeight = getNumByKey((("contest_" + toString(contestCurrNumber)) + "_finishheight")) |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let RUNNING = "RUNNING" | |
5 | 5 | ||
6 | 6 | let CLOSED = "CLOSED" | |
7 | 7 | ||
8 | 8 | let CANCELED = "CANCELED" | |
9 | 9 | ||
10 | 10 | let DAPPOWNER = "3NBEbFU6dKpoAcsbaEK2aC62UQMjYFW4xiL" | |
11 | 11 | ||
12 | 12 | let WAVES = "WAVES" | |
13 | 13 | ||
14 | 14 | let NONE = "NONE" | |
15 | 15 | ||
16 | 16 | let FEE = 900000 | |
17 | 17 | ||
18 | 18 | func randomizer (inv) = { | |
19 | 19 | let lastPlay = match getBinary(this, "extractedNumber") { | |
20 | 20 | case s: ByteVector => | |
21 | 21 | s | |
22 | 22 | case _: Unit => | |
23 | 23 | base58'2ee4oFDYriWJ9EMeR' | |
24 | 24 | case _ => | |
25 | 25 | throw("Match error") | |
26 | 26 | } | |
27 | 27 | let rand = (((((lastPlay + inv.transactionId) + inv.callerPublicKey) + lastBlock.generationSignature) + toBytes(lastBlock.timestamp)) + toBytes(lastBlock.height)) | |
28 | 28 | sha256(rand) | |
29 | 29 | } | |
30 | 30 | ||
31 | 31 | ||
32 | 32 | func getNumByKey (key) = { | |
33 | 33 | let num = match getInteger(this, key) { | |
34 | 34 | case a: Int => | |
35 | 35 | a | |
36 | 36 | case _ => | |
37 | 37 | 0 | |
38 | 38 | } | |
39 | 39 | num | |
40 | 40 | } | |
41 | 41 | ||
42 | 42 | ||
43 | 43 | func getStrByKey (key) = { | |
44 | 44 | let str = match getString(this, key) { | |
45 | 45 | case a: String => | |
46 | 46 | a | |
47 | 47 | case _ => | |
48 | 48 | NONE | |
49 | 49 | } | |
50 | 50 | str | |
51 | 51 | } | |
52 | 52 | ||
53 | 53 | ||
54 | 54 | @Callable(i) | |
55 | 55 | func setContestStatus (contestStatus) = { | |
56 | 56 | let account = toBase58String(i.caller.bytes) | |
57 | 57 | let contestCurrNumber = getNumByKey("contest_currentnumber") | |
58 | 58 | if ((account != DAPPOWNER)) | |
59 | 59 | then throw("Only dAPP Owner can set Contest Status.") | |
60 | 60 | else if (if ((contestStatus != CANCELED)) | |
61 | 61 | then (contestStatus != CLOSED) | |
62 | 62 | else false) | |
63 | 63 | then throw(("Invalid status: " + contestStatus)) | |
64 | 64 | else WriteSet([DataEntry((("contest_" + toString(contestCurrNumber)) + "_status"), contestStatus)]) | |
65 | 65 | } | |
66 | 66 | ||
67 | 67 | ||
68 | 68 | ||
69 | 69 | @Callable(i) | |
70 | 70 | func setContestConfiguration () = { | |
71 | 71 | let account = toBase58String(i.caller.bytes) | |
72 | 72 | let contestCurrNumber = getNumByKey("contest_currentnumber") | |
73 | 73 | let contestCurrStatus = getStrByKey((("contest_" + toString(contestCurrNumber)) + "_status")) | |
74 | 74 | let contestNewNumber = (contestCurrNumber + 1) | |
75 | 75 | let balance = wavesBalance(this) | |
76 | 76 | if ((account != DAPPOWNER)) | |
77 | 77 | then throw(((("Only dAPP Owner can Configure Contest. Caller account: " + account) + " dapp owner: ") + DAPPOWNER)) | |
78 | 78 | else if ((contestCurrStatus == RUNNING)) | |
79 | 79 | then throw(("You cannot configure a new Contest while old Contest status is: " + contestCurrStatus)) | |
80 | 80 | else { | |
81 | 81 | let contestFinishHeight = (height + (6 * 1440)) | |
82 | 82 | WriteSet([DataEntry("contest_currentnumber", contestNewNumber), DataEntry((("contest_" + toString(contestNewNumber)) + "_finishheight"), contestFinishHeight), DataEntry((("contest_" + toString(contestNewNumber)) + "_status"), RUNNING), DataEntry((("contest_" + toString(contestNewNumber)) + "_betcounter"), 0)]) | |
83 | 83 | } | |
84 | 84 | } | |
85 | 85 | ||
86 | 86 | ||
87 | 87 | ||
88 | 88 | @Callable(i) | |
89 | - | func bet ( | |
89 | + | func bet (guessedNumber) = { | |
90 | 90 | let account = toBase58String(i.caller.bytes) | |
91 | 91 | let pmt = extract(i.payment) | |
92 | 92 | let contestCurrNumber = getNumByKey("contest_currentnumber") | |
93 | 93 | let contestStartHeight = getNumByKey((("contest_" + toString(contestCurrNumber)) + "_startheight")) | |
94 | 94 | let contestFinishHeight = getNumByKey((("contest_" + toString(contestCurrNumber)) + "_finishheight")) | |
95 | 95 | let contestCurrStatus = getStrByKey((("contest_" + toString(contestCurrNumber)) + "_status")) | |
96 | 96 | let contestStatus = getStrByKey((("contest_" + toString(contestCurrNumber)) + "_status")) | |
97 | 97 | let accountBetsNumber = getNumByKey((((("contest_" + toString(contestCurrNumber)) + "_") + account) + "_bets")) | |
98 | - | let existingBetAccount = getStrByKey(((("bet_" + toString(contestCurrNumber)) + "_") + toString( | |
98 | + | let existingBetAccount = getStrByKey(((("bet_" + toString(contestCurrNumber)) + "_") + toString(guessedNumber))) | |
99 | 99 | if ((height > (contestFinishHeight - (2 * 1440)))) | |
100 | 100 | then throw("You cannot bet anymore at this height.") | |
101 | 101 | else if ((contestCurrStatus != RUNNING)) | |
102 | 102 | then throw(("Invalid status: you cannot bet now, contest status is: " + contestCurrStatus)) | |
103 | 103 | else if (if ((existingBetAccount != NONE)) | |
104 | 104 | then (existingBetAccount != account) | |
105 | 105 | else false) | |
106 | 106 | then throw((("Another wallet: " + existingBetAccount) + " took this number.")) | |
107 | 107 | else if ((accountBetsNumber >= 1)) | |
108 | 108 | then throw("You can chose at most one number.") | |
109 | - | else WriteSet([DataEntry(((("bet_" + toString(contestCurrNumber)) + "_") + toString(currencyValue)), account), DataEntry((((("contest_" + toString(contestCurrNumber)) + "_") + account) + "_bets"), (accountBetsNumber + 1))]) | |
109 | + | else if ((contestCurrStatus != RUNNING)) | |
110 | + | then throw(("Invalid status: you cannot bet now, contest status is: " + contestCurrStatus)) | |
111 | + | else if (if ((0 > guessedNumber)) | |
112 | + | then true | |
113 | + | else (guessedNumber > 99)) | |
114 | + | then throw("You can select a number between 0 and 99") | |
115 | + | else WriteSet([DataEntry(((("bet_" + toString(contestCurrNumber)) + "_") + toString(guessedNumber)), account), DataEntry((((("contest_" + toString(contestCurrNumber)) + "_") + account) + "_bets"), (accountBetsNumber + 1))]) | |
110 | 116 | } | |
111 | 117 | ||
112 | 118 | ||
113 | 119 | ||
114 | 120 | @Callable(i) | |
115 | 121 | func closecontest () = { | |
116 | 122 | let rand = randomizer(i) | |
117 | - | let extractedNumber = (toInt(rand) % | |
123 | + | let extractedNumber = (toInt(rand) % 100) | |
118 | 124 | let contestCurrNumber = getNumByKey("contest_currentnumber") | |
119 | 125 | let winningBetAccount = getStrByKey(((("bet_" + toString(contestCurrNumber)) + "_") + toString(1))) | |
120 | 126 | let contestFinishHeight = getNumByKey((("contest_" + toString(contestCurrNumber)) + "_finishheight")) | |
121 | 127 | let account = toBase58String(i.caller.bytes) | |
122 | 128 | let balance = wavesBalance(this) | |
123 | 129 | let contestCurrStatus = getStrByKey((("contest_" + toString(contestCurrNumber)) + "_status")) | |
124 | 130 | if ((account != DAPPOWNER)) | |
125 | 131 | then throw("Only dAPP Owner can Close the Lottery.") | |
126 | 132 | else if ((contestCurrStatus != RUNNING)) | |
127 | 133 | then throw(("Cannot close a contest in status: " + contestCurrStatus)) | |
128 | 134 | else if ((winningBetAccount != NONE)) | |
129 | 135 | then { | |
130 | 136 | let Prize = wavesBalance(this) | |
131 | 137 | let winTransfer = TransferSet([ScriptTransfer(extract(addressFromString(winningBetAccount)), Prize, unit)]) | |
132 | 138 | ScriptResult(WriteSet([DataEntry((("contest_" + toString(contestCurrNumber)) + "_status"), CLOSED), DataEntry((("contest_" + toString(contestCurrNumber)) + "_winner"), winningBetAccount), DataEntry((("contest_" + toString(contestCurrNumber)) + "_rateheight"), height), DataEntry((("contest_" + toString(contestCurrNumber)) + "_extractedNumber"), extractedNumber), DataEntry((("contest_" + toString(contestCurrNumber)) + "_prize"), Prize)]), winTransfer) | |
133 | 139 | } | |
134 | 140 | else WriteSet([DataEntry((("contest_" + toString(contestCurrNumber)) + "_status"), CLOSED), DataEntry((("contest_" + toString(contestCurrNumber)) + "_winner"), winningBetAccount), DataEntry((("contest_" + toString(contestCurrNumber)) + "_extractedNumber"), extractedNumber), DataEntry((("contest_" + toString(contestCurrNumber)) + "_prize"), 0)]) | |
135 | 141 | } | |
136 | 142 | ||
137 | 143 | ||
138 | 144 | @Verifier(tx) | |
139 | 145 | func verify () = match tx { | |
140 | 146 | case _: SetScriptTransaction|DataTransaction => | |
141 | 147 | sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
142 | 148 | case _: InvokeScriptTransaction => | |
143 | 149 | true | |
144 | 150 | case _ => | |
145 | 151 | true | |
146 | 152 | } | |
147 | 153 |
github/deemru/w8io/026f985 36.38 ms ◑