tx · 3ht3ky6EiWoUVFj3ELX3HZtz5fH4cPMPphKnfLbgVn9M

3MrfLFw1uz3BDr45RQLvrRnAwT2nHpB4KiX:  -0.01000000 Waves

2023.06.11 15:59 [2618045] smart account 3MrfLFw1uz3BDr45RQLvrRnAwT2nHpB4KiX > SELF 0.00000000 Waves

{ "type": 13, "id": "3ht3ky6EiWoUVFj3ELX3HZtz5fH4cPMPphKnfLbgVn9M", "fee": 1000000, "feeAssetId": null, "timestamp": 1686488425174, "version": 2, "chainId": 84, "sender": "3MrfLFw1uz3BDr45RQLvrRnAwT2nHpB4KiX", "senderPublicKey": "5iiNX4Sz3qZzcerumQLc1y7u9TH2X46jDV4f9Xivtmtv", "proofs": [ "3TGowUtWjFJT61T99wXddG6XrsVaVnbe41NTL3c3iuvyrKZHXtvxVk8tkmHjUobByMefBuxiMGotVjpNxXqLMBX1" ], "script": "base64:BgIHCAISAwoBARoBCm51bVRvV2F2ZXMBA251bQkAaAIFA251bQCAwtcvAQtpc1BheW1lbnRPawIBaQNzdW0EEWFjY2VwdGFibGVBc3NldElkAQQTq9kzBAFwCQCRAwIIBQFpCHBheW1lbnRzAAADCQBnAggFAXAGYW1vdW50CQEKbnVtVG9XYXZlcwEFA3N1bQkAAAIIBQFwB2Fzc2V0SWQFBHVuaXQHAQttYXBJbnRUb1N0cgIFYWNjdW0EbmV4dAkAzAgCCQCkAwEFBG5leHQFBWFjY3VtAQttYXBTdHJUb0ludAIFYWNjdW0EbmV4dAkAzAgCCQENcGFyc2VJbnRWYWx1ZQEFBG5leHQFBWFjY3VtAQttYXBJbnRUb1N1bQIFYWNjdW0EbmV4dAkAZAIFBWFjY3VtBQRuZXh0AQxsaXN0SW50VG9TdW0BA2FycgoAAiRsBQNhcnIKAAIkcwkAkAMBBQIkbAoABSRhY2MwAAAKAQUkZjBfMQICJGECJGkDCQBnAgUCJGkFAiRzBQIkYQkBC21hcEludFRvU3VtAgUCJGEJAJEDAgUCJGwFAiRpCgEFJGYwXzICAiRhA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zc2FnZQIJAO0HAQUMY29tbWl0SGVpZ2h0AhF1bmV4Y3BlY3RlZCBlcnJvcgQDdnJmCQETdmFsdWVPckVycm9yTWVzc2FnZQIIBQtyZXZlYWxCbG9jawN2cmYCEXVuZXhjcGVjdGVkIGVycm9yBApyYW5kb21IYXNoCQD3AwEJAQV2YWx1ZQEFA3ZyZgQMcmV2ZWFsQmxvY2syCQETdmFsdWVPckVycm9yTWVzc2FnZQIJAO0HAQkAZQIFDGNvbW1pdEhlaWdodAAKAhF1bmV4Y3BlY3RlZCBlcnJvcgQEdnJmMgkBE3ZhbHVlT3JFcnJvck1lc3NhZ2UCCAULcmV2ZWFsQmxvY2sDdnJmAhF1bmV4Y3BlY3RlZCBlcnJvcgQLcmFuZG9tSGFzaDIJAPcDAQkBBXZhbHVlAQUDdnJmBAxyZXZlYWxCbG9jazMJARN2YWx1ZU9yRXJyb3JNZXNzYWdlAgkA7QcBCQBlAgUMY29tbWl0SGVpZ2h0ABQCEXVuZXhjcGVjdGVkIGVycm9yBAR2cmYzCQETdmFsdWVPckVycm9yTWVzc2FnZQIIBQtyZXZlYWxCbG9jawN2cmYCEXVuZXhjcGVjdGVkIGVycm9yBAtyYW5kb21IYXNoMwkA9wMBCQEFdmFsdWUBBQN2cmYEA251bQkAagIJAGgCCQBpAgkAsgkCBQpyYW5kb21IYXNoABAJALIJAgULcmFuZG9tSGFzaDIAEAkAsgkCBQtyYW5kb21IYXNoMgAQACUJAAIBCQCkAwEFA251bQBvD55Y", "height": 2618045, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: C7Wxtv1w3sYZsK1NRX9r6z99girsT23g7aaYkr3DH31a Next: Ar5DA7EkuQSw4TQq4TEsYLJPdj3nKKcwoL4Hs2b3jrMR Diff:
OldNewDifferences
196196 let revealBlock2 = valueOrErrorMessage(blockInfoByHeight((commitHeight - 10)), "unexcpected error")
197197 let vrf2 = valueOrErrorMessage(revealBlock.vrf, "unexcpected error")
198198 let randomHash2 = sha256(value(vrf))
199- let num = ((toInt(randomHash, 16) / toInt(randomHash2, 16)) % 37)
199+ let revealBlock3 = valueOrErrorMessage(blockInfoByHeight((commitHeight - 20)), "unexcpected error")
200+ let vrf3 = valueOrErrorMessage(revealBlock.vrf, "unexcpected error")
201+ let randomHash3 = sha256(value(vrf))
202+ let num = (((toInt(randomHash, 16) / toInt(randomHash2, 16)) * toInt(randomHash2, 16)) % 37)
200203 throw(toString(num))
201- }
202-
203-
204-
205-@Callable(i)
206-func Roulette_commit (betAmount,selectedNumberBets,betDirection) = {
207- let p = i.payments[0]
208- if (!(isPaymentOk(i, betAmount)))
209- then throw("Wrong payment amount or asset!")
210- else [IntegerEntry(R_getBetKey(i), (height + 1)), IntegerEntry(R_getBetAmountKey(i), betAmount), StringEntry(R_getSelectedNumbersKey(i), listIntCompressToString(selectedNumberBets)), StringEntry(R_getDirectionKey(i), betDirection), StringEntry(R_getStatusKey(i), ((((("| status: commit | revealBlock: " + toString((height + 1))) + " | betAmount: ") + toString(betAmount)) + " | selectedNumbers: ") + listIntCompressToString(selectedNumberBets)))]
211- }
212-
213-
214-
215-@Callable(i)
216-func Roulette_reveal () = {
217- let commitHeight = valueOrErrorMessage(getIntegerValue(R_getBetKey(i)), "Bet not found")
218- let betAmount = valueOrErrorMessage(getIntegerValue(R_getBetAmountKey(i)), "Bet amount not found")
219- let selectedNumbersStr = valueOrErrorMessage(getStringValue(R_getSelectedNumbersKey(i)), "Selected numbers not found")
220- let direction = valueOrErrorMessage(getStringValue(R_getDirectionKey(i)), "Direction not found")
221- let selectedNumbers = stringDecompressToListInt(selectedNumbersStr)
222- if ((commitHeight > height))
223- then throw((("Wait " + toString((commitHeight - height))) + " blocks to reveal this id"))
224- else {
225- let revealBlock = valueOrErrorMessage(blockInfoByHeight(commitHeight), "unexcpected error")
226- let vrf = valueOrErrorMessage(revealBlock.vrf, "unexcpected error")
227- let randomHash = sha256(value(vrf))
228- let randomNumber = (toInt(randomHash, 16) % 37)
229- let winningAmount = numToWaves(R_WinCalculator(randomNumber, betAmount, selectedNumbers, direction))
230- let logStr = ((((((((("| commitHeight: " + toString(commitHeight)) + " | betAmount: ") + toString(betAmount)) + " | winningAmount: ") + toString(winningAmount)) + " | selectedNumbers: ") + listIntCompressToString(selectedNumbers)) + " | randomNumber: ") + toString(randomNumber))
231- let statusStr = ((((((((("| status: reveal | winningAmount: " + toString(winningAmount)) + " | selectedNumbers: ") + listIntCompressToString(selectedNumbers)) + " | randomNumber: ") + toString(randomNumber)) + " | betAmount: ") + toString(betAmount)) + " | selectedNumbers: ") + listIntCompressToString(selectedNumbers))
232- if ((winningAmount > 0))
233- then [DeleteEntry(R_getBetKey(i)), DeleteEntry(R_getBetAmountKey(i)), DeleteEntry(R_getSelectedNumbersKey(i)), DeleteEntry(R_getDirectionKey(i)), ScriptTransfer(i.caller, winningAmount, unit), StringEntry(R_getLogKey(i), logStr), StringEntry(R_getStatusKey(i), statusStr)]
234- else [DeleteEntry(R_getBetKey(i)), DeleteEntry(R_getBetAmountKey(i)), DeleteEntry(R_getSelectedNumbersKey(i)), DeleteEntry(R_getDirectionKey(i)), IntegerEntry(R_getLogKey(i), winningAmount), StringEntry(R_getLogKey(i), logStr), StringEntry(R_getStatusKey(i), statusStr)]
235- }
236- }
237-
238-
239-
240-@Callable(i)
241-func LuckyWheel_commit () = if (!(isPaymentOk(i, 1)))
242- then throw("Wrong payment amount or asset")
243- else [IntegerEntry(LW_getBetKey(i), (height + 1)), DeleteEntry(LW_getRandomNumberKey(i)), DeleteEntry(LW_getWonKey(i)), StringEntry(LW_getStatusKey(i), "| status: commit")]
244-
245-
246-
247-@Callable(i)
248-func LuckyWheel_reveal () = {
249- let commitHeight = valueOrErrorMessage(getIntegerValue(LW_getBetKey(i)), "Bet not found")
250- if ((commitHeight > height))
251- then throw((("Wait " + toString((commitHeight - height))) + " blocks to reveal this id"))
252- else {
253- let revealBlock = valueOrErrorMessage(blockInfoByHeight(commitHeight), "unexcpected error")
254- let vrf = valueOrErrorMessage(revealBlock.vrf, "unexcpected error")
255- let randomHash = sha256(value(vrf))
256- let revealBlock2 = valueOrErrorMessage(blockInfoByHeight((commitHeight - 1)), "unexcpected error")
257- let vrf2 = valueOrErrorMessage(revealBlock.vrf, "unexcpected error")
258- let randomHash2 = sha256(value(vrf))
259- let random = (toInt(randomHash, 16) + (toInt(randomHash, 10) / toInt(randomHash, 5)))
260- let randomNumber = (random % 12)
261- let winningAmount = LW_whatUserWon(randomNumber)
262- let statusStr = (((("| status: reveal | winningAmount: " + toString(winningAmount)) + " | selectedNumbers: ") + " | randomNumber: ") + toString(randomNumber))
263- if ((winningAmount > 0))
264- then [DeleteEntry(LW_getBetKey(i)), ScriptTransfer(i.caller, winningAmount, unit), IntegerEntry(LW_getWonKey(i), winningAmount), IntegerEntry(LW_getRandomNumberKey(i), randomNumber), StringEntry(LW_getStatusKey(i), statusStr)]
265- else [DeleteEntry(LW_getBetKey(i)), IntegerEntry(LW_getWonKey(i), winningAmount), IntegerEntry(LW_getRandomNumberKey(i), randomNumber), StringEntry(LW_getStatusKey(i), statusStr)]
266- }
267204 }
268205
269206
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 6 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 func numToWaves (num) = (num * 100000000)
55
66
77 func isPaymentOk (i,sum) = {
88 let acceptableAssetId = base58'WAVES'
99 let p = i.payments[0]
1010 if ((p.amount >= numToWaves(sum)))
1111 then (p.assetId == unit)
1212 else false
1313 }
1414
1515
1616 func mapIntToStr (accum,next) = toString(next) :: accum
1717
1818
1919 func mapStrToInt (accum,next) = parseIntValue(next) :: accum
2020
2121
2222 func mapIntToSum (accum,next) = (accum + next)
2323
2424
2525 func listIntToSum (arr) = {
2626 let $l = arr
2727 let $s = size($l)
2828 let $acc0 = 0
2929 func $f0_1 ($a,$i) = if (($i >= $s))
3030 then $a
3131 else mapIntToSum($a, $l[$i])
3232
3333 func $f0_2 ($a,$i) = if (($i >= $s))
3434 then $a
3535 else throw("List size exceeds 50")
3636
3737 $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10), 11), 12), 13), 14), 15), 16), 17), 18), 19), 20), 21), 22), 23), 24), 25), 26), 27), 28), 29), 30), 31), 32), 33), 34), 35), 36), 37), 38), 39), 40), 41), 42), 43), 44), 45), 46), 47), 48), 49), 50)
3838 }
3939
4040
4141 func listIntToListString (arr) = {
4242 let $l = arr
4343 let $s = size($l)
4444 let $acc0 = nil
4545 func $f0_1 ($a,$i) = if (($i >= $s))
4646 then $a
4747 else mapIntToStr($a, $l[$i])
4848
4949 func $f0_2 ($a,$i) = if (($i >= $s))
5050 then $a
5151 else throw("List size exceeds 50")
5252
5353 $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10), 11), 12), 13), 14), 15), 16), 17), 18), 19), 20), 21), 22), 23), 24), 25), 26), 27), 28), 29), 30), 31), 32), 33), 34), 35), 36), 37), 38), 39), 40), 41), 42), 43), 44), 45), 46), 47), 48), 49), 50)
5454 }
5555
5656
5757 func listStringToListIng (arr) = {
5858 let $l = arr
5959 let $s = size($l)
6060 let $acc0 = nil
6161 func $f0_1 ($a,$i) = if (($i >= $s))
6262 then $a
6363 else mapStrToInt($a, $l[$i])
6464
6565 func $f0_2 ($a,$i) = if (($i >= $s))
6666 then $a
6767 else throw("List size exceeds 50")
6868
6969 $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10), 11), 12), 13), 14), 15), 16), 17), 18), 19), 20), 21), 22), 23), 24), 25), 26), 27), 28), 29), 30), 31), 32), 33), 34), 35), 36), 37), 38), 39), 40), 41), 42), 43), 44), 45), 46), 47), 48), 49), 50)
7070 }
7171
7272
7373 func listStringCompressToString (arr) = makeString(arr, "|")
7474
7575
7676 func stringDecompressToListString (str) = split(str, "|")
7777
7878
7979 func listIntCompressToString (arr) = makeString(listIntToListString(arr), "|")
8080
8181
8282 func stringDecompressToListInt (arrStr) = listStringToListIng(split(arrStr, "|"))
8383
8484
8585 func getRandom (commitHeight) = {
8686 let revealBlock = valueOrErrorMessage(blockInfoByHeight(commitHeight), "unexcpected error")
8787 let vrf = valueOrErrorMessage(revealBlock.vrf, "unexcpected error")
8888 let randomHash = sha256(value(vrf))
8989 let hash = toInt(randomHash, 16)
9090 (hash % 37)
9191 }
9292
9393
9494 func R_WinCalculator (randomNumber,betAmount,selectedNumberBets,betDirection) = {
9595 let RED_SECTORS = [32, 19, 21, 25, 34, 27, 36, 30, 23, 5, 16, 1, 14, 9, 18, 7, 12, 3]
9696 if (if ((size(selectedNumberBets) == 1))
9797 then (betDirection == "num")
9898 else false)
9999 then if ((selectedNumberBets[0] == randomNumber))
100100 then (betAmount * 36)
101101 else 0
102102 else if ((size(selectedNumberBets) == 2))
103103 then if (containsElement(selectedNumberBets, randomNumber))
104104 then (betAmount * 18)
105105 else 0
106106 else if ((size(selectedNumberBets) == 3))
107107 then if (containsElement(selectedNumberBets, randomNumber))
108108 then (betAmount * 12)
109109 else 0
110110 else if ((size(selectedNumberBets) == 4))
111111 then if (containsElement(selectedNumberBets, randomNumber))
112112 then (betAmount * 9)
113113 else 0
114114 else if ((size(selectedNumberBets) == 12))
115115 then if (containsElement(selectedNumberBets, randomNumber))
116116 then (betAmount * 3)
117117 else 0
118118 else if ((betDirection == "red"))
119119 then if (containsElement(RED_SECTORS, randomNumber))
120120 then (betAmount * 2)
121121 else 0
122122 else if ((betDirection == "black"))
123123 then if (if (!(containsElement(RED_SECTORS, randomNumber)))
124124 then (randomNumber != 0)
125125 else false)
126126 then (betAmount * 2)
127127 else 0
128128 else if ((betDirection == "odd"))
129129 then if (((randomNumber % 2) != 0))
130130 then (betAmount * 2)
131131 else 0
132132 else if ((betDirection == "even"))
133133 then if (((randomNumber % 2) == 0))
134134 then (betAmount * 2)
135135 else 0
136136 else if ((size(selectedNumberBets) == 18))
137137 then if (containsElement(selectedNumberBets, randomNumber))
138138 then (betAmount * 2)
139139 else 0
140140 else 0
141141 }
142142
143143
144144 func R_getBetKey (i) = ("bet_Roulette_" + toString(i.caller))
145145
146146
147147 func R_getBetAmountKey (i) = ("betAmount_Roulette_" + toString(i.caller))
148148
149149
150150 func R_getSelectedNumbersKey (i) = ("selectedNumbers_Roulette_" + toString(i.caller))
151151
152152
153153 func R_getDirectionKey (i) = ("direction_Roulette_" + toString(i.caller))
154154
155155
156156 func R_getLogKey (i) = ((("log_Roulette_" + toString(i.caller)) + "_") + toBase58String(i.transactionId))
157157
158158
159159 func R_getStatusKey (i) = ("status_Roulette_" + toString(i.caller))
160160
161161
162162 func LW_getBetKey (i) = ("bet_LuckyWheel_" + toString(i.caller))
163163
164164
165165 func LW_getWonKey (i) = ("won_LuckyWheel_" + toString(i.caller))
166166
167167
168168 func LW_getRandomNumberKey (i) = ("randomNumber_LuckyWheel_" + toString(i.caller))
169169
170170
171171 func LW_getLogKey (i) = ((("log_LuckyWheel_" + toString(i.caller)) + "_") + toBase58String(i.transactionId))
172172
173173
174174 func LW_whatUserWon (value) = match value {
175175 case _ =>
176176 if ((1 == $match0))
177177 then numToWaves(2)
178178 else if ((3 == $match0))
179179 then numToWaves(1)
180180 else if ((7 == $match0))
181181 then numToWaves(6)
182182 else if ((9 == $match0))
183183 then numToWaves(1)
184184 else 0
185185 }
186186
187187
188188 func LW_getStatusKey (i) = ("status_Roulette_" + toString(i.caller))
189189
190190
191191 @Callable(i)
192192 func testRandomNumber (commitHeight) = {
193193 let revealBlock = valueOrErrorMessage(blockInfoByHeight(commitHeight), "unexcpected error")
194194 let vrf = valueOrErrorMessage(revealBlock.vrf, "unexcpected error")
195195 let randomHash = sha256(value(vrf))
196196 let revealBlock2 = valueOrErrorMessage(blockInfoByHeight((commitHeight - 10)), "unexcpected error")
197197 let vrf2 = valueOrErrorMessage(revealBlock.vrf, "unexcpected error")
198198 let randomHash2 = sha256(value(vrf))
199- let num = ((toInt(randomHash, 16) / toInt(randomHash2, 16)) % 37)
199+ let revealBlock3 = valueOrErrorMessage(blockInfoByHeight((commitHeight - 20)), "unexcpected error")
200+ let vrf3 = valueOrErrorMessage(revealBlock.vrf, "unexcpected error")
201+ let randomHash3 = sha256(value(vrf))
202+ let num = (((toInt(randomHash, 16) / toInt(randomHash2, 16)) * toInt(randomHash2, 16)) % 37)
200203 throw(toString(num))
201- }
202-
203-
204-
205-@Callable(i)
206-func Roulette_commit (betAmount,selectedNumberBets,betDirection) = {
207- let p = i.payments[0]
208- if (!(isPaymentOk(i, betAmount)))
209- then throw("Wrong payment amount or asset!")
210- else [IntegerEntry(R_getBetKey(i), (height + 1)), IntegerEntry(R_getBetAmountKey(i), betAmount), StringEntry(R_getSelectedNumbersKey(i), listIntCompressToString(selectedNumberBets)), StringEntry(R_getDirectionKey(i), betDirection), StringEntry(R_getStatusKey(i), ((((("| status: commit | revealBlock: " + toString((height + 1))) + " | betAmount: ") + toString(betAmount)) + " | selectedNumbers: ") + listIntCompressToString(selectedNumberBets)))]
211- }
212-
213-
214-
215-@Callable(i)
216-func Roulette_reveal () = {
217- let commitHeight = valueOrErrorMessage(getIntegerValue(R_getBetKey(i)), "Bet not found")
218- let betAmount = valueOrErrorMessage(getIntegerValue(R_getBetAmountKey(i)), "Bet amount not found")
219- let selectedNumbersStr = valueOrErrorMessage(getStringValue(R_getSelectedNumbersKey(i)), "Selected numbers not found")
220- let direction = valueOrErrorMessage(getStringValue(R_getDirectionKey(i)), "Direction not found")
221- let selectedNumbers = stringDecompressToListInt(selectedNumbersStr)
222- if ((commitHeight > height))
223- then throw((("Wait " + toString((commitHeight - height))) + " blocks to reveal this id"))
224- else {
225- let revealBlock = valueOrErrorMessage(blockInfoByHeight(commitHeight), "unexcpected error")
226- let vrf = valueOrErrorMessage(revealBlock.vrf, "unexcpected error")
227- let randomHash = sha256(value(vrf))
228- let randomNumber = (toInt(randomHash, 16) % 37)
229- let winningAmount = numToWaves(R_WinCalculator(randomNumber, betAmount, selectedNumbers, direction))
230- let logStr = ((((((((("| commitHeight: " + toString(commitHeight)) + " | betAmount: ") + toString(betAmount)) + " | winningAmount: ") + toString(winningAmount)) + " | selectedNumbers: ") + listIntCompressToString(selectedNumbers)) + " | randomNumber: ") + toString(randomNumber))
231- let statusStr = ((((((((("| status: reveal | winningAmount: " + toString(winningAmount)) + " | selectedNumbers: ") + listIntCompressToString(selectedNumbers)) + " | randomNumber: ") + toString(randomNumber)) + " | betAmount: ") + toString(betAmount)) + " | selectedNumbers: ") + listIntCompressToString(selectedNumbers))
232- if ((winningAmount > 0))
233- then [DeleteEntry(R_getBetKey(i)), DeleteEntry(R_getBetAmountKey(i)), DeleteEntry(R_getSelectedNumbersKey(i)), DeleteEntry(R_getDirectionKey(i)), ScriptTransfer(i.caller, winningAmount, unit), StringEntry(R_getLogKey(i), logStr), StringEntry(R_getStatusKey(i), statusStr)]
234- else [DeleteEntry(R_getBetKey(i)), DeleteEntry(R_getBetAmountKey(i)), DeleteEntry(R_getSelectedNumbersKey(i)), DeleteEntry(R_getDirectionKey(i)), IntegerEntry(R_getLogKey(i), winningAmount), StringEntry(R_getLogKey(i), logStr), StringEntry(R_getStatusKey(i), statusStr)]
235- }
236- }
237-
238-
239-
240-@Callable(i)
241-func LuckyWheel_commit () = if (!(isPaymentOk(i, 1)))
242- then throw("Wrong payment amount or asset")
243- else [IntegerEntry(LW_getBetKey(i), (height + 1)), DeleteEntry(LW_getRandomNumberKey(i)), DeleteEntry(LW_getWonKey(i)), StringEntry(LW_getStatusKey(i), "| status: commit")]
244-
245-
246-
247-@Callable(i)
248-func LuckyWheel_reveal () = {
249- let commitHeight = valueOrErrorMessage(getIntegerValue(LW_getBetKey(i)), "Bet not found")
250- if ((commitHeight > height))
251- then throw((("Wait " + toString((commitHeight - height))) + " blocks to reveal this id"))
252- else {
253- let revealBlock = valueOrErrorMessage(blockInfoByHeight(commitHeight), "unexcpected error")
254- let vrf = valueOrErrorMessage(revealBlock.vrf, "unexcpected error")
255- let randomHash = sha256(value(vrf))
256- let revealBlock2 = valueOrErrorMessage(blockInfoByHeight((commitHeight - 1)), "unexcpected error")
257- let vrf2 = valueOrErrorMessage(revealBlock.vrf, "unexcpected error")
258- let randomHash2 = sha256(value(vrf))
259- let random = (toInt(randomHash, 16) + (toInt(randomHash, 10) / toInt(randomHash, 5)))
260- let randomNumber = (random % 12)
261- let winningAmount = LW_whatUserWon(randomNumber)
262- let statusStr = (((("| status: reveal | winningAmount: " + toString(winningAmount)) + " | selectedNumbers: ") + " | randomNumber: ") + toString(randomNumber))
263- if ((winningAmount > 0))
264- then [DeleteEntry(LW_getBetKey(i)), ScriptTransfer(i.caller, winningAmount, unit), IntegerEntry(LW_getWonKey(i), winningAmount), IntegerEntry(LW_getRandomNumberKey(i), randomNumber), StringEntry(LW_getStatusKey(i), statusStr)]
265- else [DeleteEntry(LW_getBetKey(i)), IntegerEntry(LW_getWonKey(i), winningAmount), IntegerEntry(LW_getRandomNumberKey(i), randomNumber), StringEntry(LW_getStatusKey(i), statusStr)]
266- }
267204 }
268205
269206

github/deemru/w8io/026f985 
62.60 ms