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