tx · GzkY8pZWuuJ45NHhpurZAw4nkVNoCW4WupRZCBv2ZUEo 3Mynaio8coZLr58tu2AdBEhmCvB17vTBRkA: -0.01000000 Waves 2023.06.03 22:32 [2606925] smart account 3Mynaio8coZLr58tu2AdBEhmCvB17vTBRkA > SELF 0.00000000 Waves
{ "type": 13, "id": "GzkY8pZWuuJ45NHhpurZAw4nkVNoCW4WupRZCBv2ZUEo", "fee": 1000000, "feeAssetId": null, "timestamp": 1685820720619, "version": 2, "chainId": 84, "sender": "3Mynaio8coZLr58tu2AdBEhmCvB17vTBRkA", "senderPublicKey": "Dx7cJVhpJb4qUDGiDnSjj6Wfjdj5nmzwVLfaggkbjDtv", "proofs": [ "5UFZgJNSZp3X9hKPu4LMjKTaRQLHV3PjfyzsFaVYuWtmpdyVJ7oe6WMuUhn6QWkNAcHoQunV6HWE6CjvZSmhmGWu" ], "script": "base64:BgIGCAISABIABwEKbnVtVG9XYXZlcwEDbnVtCQBoAgUDbnVtAIDC1y8BC2lzUGF5bWVudE9rAQFpBBFhY2NlcHRhYmxlQXNzZXRJZAEgIkSm54hUfVEormpXug9p+nbhDnc37ahHq1IfaU2UQkcDCQAAAgkAkAMBCAUBaQhwYXltZW50cwAACQACAQIUUGF5bWVudCBub3QgYXR0YWNoZWQEAXAJAJEDAggFAWkIcGF5bWVudHMAAAQHJG1hdGNoMAgFAXAHYXNzZXRJZAMJAAECBQckbWF0Y2gwAgpCeXRlVmVjdG9yBAdhc3NldElkBQckbWF0Y2gwAwkAAAIFB2Fzc2V0SWQFEWFjY2VwdGFibGVBc3NldElkCQBnAggFAXAGYW1vdW50CQEKbnVtVG9XYXZlcwEAAQcJAGcCCAUBcAZhbW91bnQJAQpudW1Ub1dhdmVzAQABARNnZXRMdWNreVdoZWVsQmV0S2V5AQFpCQCsAgICD2JldF9MdWNreVdoZWVsXwkApQgBCAUBaQZjYWxsZXIBE2dldEx1Y2t5V2hlZWxXb25LZXkBAWkJAKwCAgIPd29uX0x1Y2t5V2hl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lZWxXb25LZXkBBQFpBQ13aW5uaW5nQW1vdW50CQDMCAIJAQxJbnRlZ2VyRW50cnkCCQEcZ2V0THVja3lXaGVlbFJhbmRvbU51bWJlcktleQEFAWkFDHJhbmRvbU51bWJlcgkAzAgCCQEMSW50ZWdlckVudHJ5AgkBE2dldEx1Y2t5V2hlZWxMb2dLZXkBBQFpBQ13aW5uaW5nQW1vdW50CQDMCAIJAQxJbnRlZ2VyRW50cnkCAgpyYW5kb21TZWVkBQpyYW5kb21TZWVkBQNuaWwAQyKnBw==", "height": 2606925, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: xEc8Yznj2JmVyQ9jJDWaFu6wQyrdj1fLqrbhpQsnSNP Next: 9wRa37kVK2YZzw54mDtXLrF4MdcpeBdRUUWvB4KCHd6H Diff:
Old | New | Differences | |
---|---|---|---|
44 | 44 | then numToWaves(6) | |
45 | 45 | else if ((9 == $match0)) | |
46 | 46 | then numToWaves(1) | |
47 | - | else if ((11 == $match0)) | |
48 | - | then numToWaves(1) | |
49 | - | else 0 | |
47 | + | else 0 | |
50 | 48 | } | |
51 | 49 | ||
52 | 50 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | func numToWaves (num) = (num * 100000000) | |
5 | 5 | ||
6 | 6 | ||
7 | 7 | func isPaymentOk (i) = { | |
8 | 8 | let acceptableAssetId = base58'3JmaWyFqWo8YSA8x3DXCBUW7veesxacvKx19dMv7wTMg' | |
9 | 9 | if ((size(i.payments) == 0)) | |
10 | 10 | then throw("Payment not attached") | |
11 | 11 | else { | |
12 | 12 | let p = i.payments[0] | |
13 | 13 | match p.assetId { | |
14 | 14 | case assetId: ByteVector => | |
15 | 15 | if ((assetId == acceptableAssetId)) | |
16 | 16 | then (p.amount >= numToWaves(1)) | |
17 | 17 | else false | |
18 | 18 | case _ => | |
19 | 19 | (p.amount >= numToWaves(1)) | |
20 | 20 | } | |
21 | 21 | } | |
22 | 22 | } | |
23 | 23 | ||
24 | 24 | ||
25 | 25 | func getLuckyWheelBetKey (i) = ("bet_LuckyWheel_" + toString(i.caller)) | |
26 | 26 | ||
27 | 27 | ||
28 | 28 | func getLuckyWheelWonKey (i) = ("won_LuckyWheel_" + toString(i.caller)) | |
29 | 29 | ||
30 | 30 | ||
31 | 31 | func getLuckyWheelRandomNumberKey (i) = ("randomNumber_LuckyWheel_" + toString(i.caller)) | |
32 | 32 | ||
33 | 33 | ||
34 | 34 | func getLuckyWheelLogKey (i) = ((("log_LuckyWheel_" + toString(i.caller)) + "_") + toBase58String(i.transactionId)) | |
35 | 35 | ||
36 | 36 | ||
37 | 37 | func gameLuckyWheelWhatUserWon (value) = match value { | |
38 | 38 | case _ => | |
39 | 39 | if ((1 == $match0)) | |
40 | 40 | then numToWaves(2) | |
41 | 41 | else if ((3 == $match0)) | |
42 | 42 | then numToWaves(1) | |
43 | 43 | else if ((7 == $match0)) | |
44 | 44 | then numToWaves(6) | |
45 | 45 | else if ((9 == $match0)) | |
46 | 46 | then numToWaves(1) | |
47 | - | else if ((11 == $match0)) | |
48 | - | then numToWaves(1) | |
49 | - | else 0 | |
47 | + | else 0 | |
50 | 48 | } | |
51 | 49 | ||
52 | 50 | ||
53 | 51 | @Callable(i) | |
54 | 52 | func commitLuckyWheel () = if (!(isPaymentOk(i))) | |
55 | 53 | then throw("Wrong payment amount or asset") | |
56 | 54 | else [IntegerEntry(getLuckyWheelBetKey(i), (height + 1)), DeleteEntry(getLuckyWheelRandomNumberKey(i)), DeleteEntry(getLuckyWheelWonKey(i))] | |
57 | 55 | ||
58 | 56 | ||
59 | 57 | ||
60 | 58 | @Callable(i) | |
61 | 59 | func revealLuckyWheel () = { | |
62 | 60 | let commitHeight = valueOrErrorMessage(getIntegerValue(getLuckyWheelBetKey(i)), "Bet not found") | |
63 | 61 | if ((commitHeight > height)) | |
64 | 62 | then throw((("wait " + toString((commitHeight - height))) + " blocks to reveal this id")) | |
65 | 63 | else { | |
66 | 64 | let revealBlock = valueOrErrorMessage(blockInfoByHeight(commitHeight), "unexcpected error") | |
67 | 65 | let vrf = valueOrErrorMessage(revealBlock.vrf, "unexcpected error") | |
68 | 66 | let randomHash = sha256(value(vrf)) | |
69 | 67 | let randomSeed = (toInt(randomHash, 16) % 12) | |
70 | 68 | let randomNumber = ((randomSeed % ((12 - 1) + 1)) + 1) | |
71 | 69 | let winningAmount = gameLuckyWheelWhatUserWon(randomNumber) | |
72 | 70 | if ((winningAmount > 0)) | |
73 | 71 | then [DeleteEntry(getLuckyWheelBetKey(i)), ScriptTransfer(i.caller, winningAmount, unit), IntegerEntry(getLuckyWheelWonKey(i), winningAmount), IntegerEntry(getLuckyWheelRandomNumberKey(i), randomNumber), IntegerEntry(getLuckyWheelLogKey(i), winningAmount), IntegerEntry("randomSeed", randomSeed)] | |
74 | 72 | else [DeleteEntry(getLuckyWheelBetKey(i)), IntegerEntry(getLuckyWheelWonKey(i), winningAmount), IntegerEntry(getLuckyWheelRandomNumberKey(i), randomNumber), IntegerEntry(getLuckyWheelLogKey(i), winningAmount), IntegerEntry("randomSeed", randomSeed)] | |
75 | 73 | } | |
76 | 74 | } | |
77 | 75 | ||
78 | 76 |
github/deemru/w8io/169f3d6 27.82 ms ◑