tx · 7hr8dYfJXTuyUFKhjfrPzg4dR438Da2UXnpvR7dLA6DQ

3N8GKGgDPGGUaAhPMNtsxTJWafHDRnwL7GQ:  -0.01000000 Waves

2023.06.06 20:15 [2611093] smart account 3N8GKGgDPGGUaAhPMNtsxTJWafHDRnwL7GQ > SELF 0.00000000 Waves

{ "type": 13, "id": "7hr8dYfJXTuyUFKhjfrPzg4dR438Da2UXnpvR7dLA6DQ", "fee": 1000000, "feeAssetId": null, "timestamp": 1686071848902, "version": 2, "chainId": 84, "sender": "3N8GKGgDPGGUaAhPMNtsxTJWafHDRnwL7GQ", "senderPublicKey": "y5twTW93XMmi75S5bati2cok9QLLFivsrwJedxJeUkX", "proofs": [ "2BoQg6N5cKj66tixEivez3wQc6d6AdWSdef3gWVc79T4MShjhEEMTMhNohgXpZVSv4NAUGGoQGBZf25R9z3egCVu" ], "script": "base64:BgIGCAISABIABwEKbnVtVG9XYXZlcwEDbnVtCQBoAgUDbnVtAIDC1y8BC2lzUGF5bWVudE9rAQFpBBFhY2NlcHRhYmxlQXNzZXRJZAEgIkSm54hUfVEormpXug9p+nbhDnc37ahHq1IfaU2UQkcDCQAAAgkAkAMBCAUBaQhwYXltZW50cwAACQACAQIUUGF5bWVudCBub3QgYXR0YWNoZWQEAXAJAJEDAggFAWkIcGF5bWVudHMAAAQHJG1hdGNoMAgFAXAHYXNzZXRJZAMJAAECBQckbWF0Y2gwAgpCeXRlVmVjdG9yBAdhc3NldElkBQckbWF0Y2gwAwkAAAIFB2Fzc2V0SWQFEWFjY2VwdGFibGVBc3NldElkCQBnAggFAXAGYW1vdW50CQEKbnVtVG9XYXZlcwEAAQcJAGcCCAUBcAZhbW91bnQJAQpudW1Ub1dhdmVzAQABAQxMV19nZXRCZXRLZXkBAWkJAKwCAgIPYmV0X0x1Y2t5V2hlZWxfCQClCAEIBQFpBmNhbGxlcgEMTFdfZ2V0V29uS2V5AQFpCQCsAgICD3dvbl9MdWNreVdoZWVsXwkApQgBCAUBaQZjYWx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"height": 2611093, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: AyLNT8tDb6FFttxqDXyP9vX1pbP8YeZzvPnE4Exr8BGE Next: none Full:
OldNewDifferences
1-{-# STDLIB_VERSION 5 #-}
1+{-# STDLIB_VERSION 6 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
4-let N = 10
4+func numToWaves (num) = (num * 100000000)
5+
6+
7+func isPaymentOk (i) = {
8+ let acceptableAssetId = base58'3JmaWyFqWo8YSA8x3DXCBUW7veesxacvKx19dMv7wTMg'
9+ if ((size(i.payments) == 0))
10+ then throw("Payment not attached")
11+ else {
12+ let p = i.payments[0]
13+ match p.assetId {
14+ case assetId: ByteVector =>
15+ if ((assetId == acceptableAssetId))
16+ then (p.amount >= numToWaves(1))
17+ else false
18+ case _ =>
19+ (p.amount >= numToWaves(1))
20+ }
21+ }
22+ }
23+
24+
25+func LW_getBetKey (i) = ("bet_LuckyWheel_" + toString(i.caller))
26+
27+
28+func LW_getWonKey (i) = ("won_LuckyWheel_" + toString(i.caller))
29+
30+
31+func LW_getRandomNumberKey (i) = ("randomNumber_LuckyWheel_" + toString(i.caller))
32+
33+
34+func LW_getLogKey (i) = ((("log_LuckyWheel_" + toString(i.caller)) + "_") + toBase58String(i.transactionId))
35+
36+
37+func LW_whatUserWon (value) = match value {
38+ case _ =>
39+ if ((1 == $match0))
40+ then numToWaves(2)
41+ else if ((3 == $match0))
42+ then numToWaves(1)
43+ else if ((7 == $match0))
44+ then numToWaves(6)
45+ else if ((9 == $match0))
46+ then numToWaves(1)
47+ else 0
48+}
49+
550
651 @Callable(i)
7-func commit (bet) = if (if ((0 > bet))
8- then true
9- else (bet > 255))
10- then throw("0 <= bet <= 255")
11- else [IntegerEntry(toBase58String(i.transactionId), bet)]
52+func LuckyWheel_commit () = if (!(isPaymentOk(i)))
53+ then throw("Wrong payment amount or asset")
54+ else [IntegerEntry(LW_getBetKey(i), (height + 1)), DeleteEntry(LW_getRandomNumberKey(i)), DeleteEntry(LW_getWonKey(i))]
1255
1356
1457
1558 @Callable(i)
16-func reveal (id) = if ((1 > N))
17- then throw("N cannot be < 1")
18- else {
19- let commitHeight = valueOrErrorMessage(transactionHeightById(fromBase58String(id)), (id + " not found"))
20- let revealHeight = (commitHeight + N)
21- if ((revealHeight > height))
22- then throw((("wait " + toString((revealHeight - height))) + " blocks to reveal this id"))
23- else {
24- let revealBlock = valueOrErrorMessage(blockInfoByHeight(revealHeight), "unexcpected error")
25- let vrf = valueOrErrorMessage(revealBlock.vrf, "unexcpected error")
26- let bet = valueOrErrorMessage(getInteger(id), "cannot find bet")
27- let reveal = sha256(((vrf + toBytes(id)) + toBytes(bet)))
28- let goal = (toInt(reveal) % 256)
29- let win = (bet == goal)
30- $Tuple2([DeleteEntry(id)], win)
31- }
32- }
59+func LuckyWheel_reveal () = {
60+ let commitHeight = valueOrErrorMessage(getIntegerValue(LW_getBetKey(i)), "Bet not found")
61+ if ((commitHeight > height))
62+ then throw((("wait " + toString((commitHeight - height))) + " blocks to reveal this id"))
63+ else {
64+ let revealBlock = valueOrErrorMessage(blockInfoByHeight(commitHeight), "unexcpected error")
65+ let vrf = valueOrErrorMessage(revealBlock.vrf, "unexcpected error")
66+ let randomHash = sha256(value(vrf))
67+ let randomSeed = (toInt(randomHash, 16) % 12)
68+ let randomNumber = ((randomSeed % ((12 - 1) + 1)) + 1)
69+ let winningAmount = LW_whatUserWon(randomNumber)
70+ if ((winningAmount > 0))
71+ then [DeleteEntry(LW_getBetKey(i)), ScriptTransfer(i.caller, winningAmount, unit), IntegerEntry(LW_getWonKey(i), winningAmount), IntegerEntry(LW_getRandomNumberKey(i), randomNumber), IntegerEntry(LW_getLogKey(i), winningAmount)]
72+ else [DeleteEntry(LW_getBetKey(i)), IntegerEntry(LW_getWonKey(i), winningAmount), IntegerEntry(LW_getRandomNumberKey(i), randomNumber), IntegerEntry(LW_getLogKey(i), winningAmount)]
73+ }
74+ }
3375
3476

github/deemru/w8io/169f3d6 
29.94 ms