tx · Ds8rWA1iitPHEtJdG92UzRvwxYW89WGCXRwDw1hYsNYV 3N6GuFb7Ucxs3cZjmwYDusKtfLaAigDtav5: -0.01000000 Waves 2023.06.07 08:33 [2611835] smart account 3N6GuFb7Ucxs3cZjmwYDusKtfLaAigDtav5 > SELF 0.00000000 Waves
{ "type": 13, "id": "Ds8rWA1iitPHEtJdG92UzRvwxYW89WGCXRwDw1hYsNYV", "fee": 1000000, "feeAssetId": null, "timestamp": 1686116001215, "version": 2, "chainId": 84, "sender": "3N6GuFb7Ucxs3cZjmwYDusKtfLaAigDtav5", "senderPublicKey": "EMAuwff72FwVoiJK9xHyuUUMbpKmgV5temqeLU2aEsiS", "proofs": [ "p1NJq6AqLm5FvTmvQNAQqcUjn1nwWHptGC4QUfTJ5AiCd34cNjoZEtTWCuwwDR89aiV7wqZsDDCAnJRwvTqmmNs" ], "script": "base64:BgIOCAISABIAEgYKBAERAQgIAQpudW1Ub1dhdmVzAQNudW0JAGgCBQNudW0AgMLXLwELaXNQYXltZW50T2sBAWkEEWFjY2VwdGFibGVBc3NldElkASAiRKbniFR9USiuale6D2n6duEOdzftqEerUh9pTZRCRwMJAAACCQCQAwEIBQFpCHBheW1lbnRzAAAJAAIBAhRQYXltZW50IG5vdCBhdHRhY2hlZAQBcAkAkQMCCAUBaQhwYXltZW50cwAABAckbWF0Y2gwCAUBcAdhc3NldElkAwkAAQIFByRtYXRjaDACCkJ5dGVWZWN0b3IEB2Fzc2V0SWQFByRtYXRjaDADCQAAAgUHYXNzZXRJZAURYWNjZXB0YWJsZUFzc2V0SWQJAGcCCAUBcAZhbW91bnQJAQpudW1Ub1dhdmVzAQABBwkAZwIIBQFwBmFtb3VudAkBCm51bVRvV2F2ZXMBAAEBDExXX2dldEJldEtleQEBaQkArAICAg9iZXRfTHVja3lXaGVlbF8JAKUIAQgFAWkGY2FsbGVyAQxMV19nZXRXb25LZXkBAWkJAKwCAgIPd29uX0x1Y2t5V2hlZWxfCQClCAEIBQFpBmNhbG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AWkFDXdpbm5pbmdBbW91bnQJAMwIAgkBDEludGVnZXJFbnRyeQIJARVMV19nZXRSYW5kb21OdW1iZXJLZXkBBQFpBQxyYW5kb21OdW1iZXIJAMwIAgkBDEludGVnZXJFbnRyeQIJAQxMV19nZXRMb2dLZXkBBQFpBQ13aW5uaW5nQW1vdW50BQNuaWwJAMwIAgkBC0RlbGV0ZUVudHJ5AQkBDExXX2dldEJldEtleQEFAWkJAMwIAgkBDEludGVnZXJFbnRyeQIJAQxMV19nZXRXb25LZXkBBQFpBQ13aW5uaW5nQW1vdW50CQDMCAIJAQxJbnRlZ2VyRW50cnkCCQEVTFdfZ2V0UmFuZG9tTnVtYmVyS2V5AQUBaQUMcmFuZG9tTnVtYmVyCQDMCAIJAQxJbnRlZ2VyRW50cnkCCQEMTFdfZ2V0TG9nS2V5AQUBaQUNd2lubmluZ0Ftb3VudAUDbmlsAWkBBFRlc3QEA2JldBJzZWxlY3RlZE51bWJlckJldHMMcmFuZG9tTnVtYmVyDGJldERpcmVjdGlvbgkAzAgCCQEMSW50ZWdlckVudHJ5AgIPUl9XaW5DYWxjdWxhdG9yCQEPUl9XaW5DYWxjdWxhdG9yBAUDYmV0BRJzZWxlY3RlZE51bWJlckJldHMFDHJhbmRvbU51bWJlcgUMYmV0RGlyZWN0aW9uBQNuaWwAuEZJfQ==", "height": 2611835, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: DRykuMBG3XybRhBPrJQWswKMcWXJzUqBuzFBeXvqya57 Next: 85sCb1oszDSXSS5vutYCjhrhhABJZzo3X96JGW83pWnP Diff:
Old | New | Differences | |
---|---|---|---|
48 | 48 | } | |
49 | 49 | ||
50 | 50 | ||
51 | - | func | |
51 | + | func R_WinCalculator (bet,selectedNumberBets,randomNumber,betDirection) = { | |
52 | 52 | let RED_SECTORS = [32, 19, 21, 25, 34, 27, 36, 30, 23, 5, 16, 1, 14, 9, 18, 7, 12, 3] | |
53 | 53 | if (if ((size(selectedNumberBets) == 1)) | |
54 | 54 | then (betDirection == "num") | |
126 | 126 | ||
127 | 127 | ||
128 | 128 | @Callable(i) | |
129 | - | func Test () = | |
129 | + | func Test (bet,selectedNumberBets,randomNumber,betDirection) = [IntegerEntry("R_WinCalculator", R_WinCalculator(bet, selectedNumberBets, randomNumber, betDirection))] | |
130 | 130 | ||
131 | 131 |
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 LW_getBetKey (i) = ("bet_LuckyWheel_" + toString(i.caller)) | |
26 | 26 | ||
27 | 27 | ||
28 | 28 | func LW_getWonKey (i) = ("won_LuckyWheel_" + toString(i.caller)) | |
29 | 29 | ||
30 | 30 | ||
31 | 31 | func LW_getRandomNumberKey (i) = ("randomNumber_LuckyWheel_" + toString(i.caller)) | |
32 | 32 | ||
33 | 33 | ||
34 | 34 | func LW_getLogKey (i) = ((("log_LuckyWheel_" + toString(i.caller)) + "_") + toBase58String(i.transactionId)) | |
35 | 35 | ||
36 | 36 | ||
37 | 37 | func LW_whatUserWon (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 | 47 | else 0 | |
48 | 48 | } | |
49 | 49 | ||
50 | 50 | ||
51 | - | func | |
51 | + | func R_WinCalculator (bet,selectedNumberBets,randomNumber,betDirection) = { | |
52 | 52 | let RED_SECTORS = [32, 19, 21, 25, 34, 27, 36, 30, 23, 5, 16, 1, 14, 9, 18, 7, 12, 3] | |
53 | 53 | if (if ((size(selectedNumberBets) == 1)) | |
54 | 54 | then (betDirection == "num") | |
55 | 55 | else false) | |
56 | 56 | then if ((selectedNumberBets[0] == randomNumber)) | |
57 | 57 | then (bet * 36) | |
58 | 58 | else 0 | |
59 | 59 | else if ((size(selectedNumberBets) == 2)) | |
60 | 60 | then if (containsElement(selectedNumberBets, randomNumber)) | |
61 | 61 | then (bet * 18) | |
62 | 62 | else 0 | |
63 | 63 | else if ((size(selectedNumberBets) == 3)) | |
64 | 64 | then if (containsElement(selectedNumberBets, randomNumber)) | |
65 | 65 | then (bet * 12) | |
66 | 66 | else 0 | |
67 | 67 | else if ((size(selectedNumberBets) == 4)) | |
68 | 68 | then if (containsElement(selectedNumberBets, randomNumber)) | |
69 | 69 | then (bet * 9) | |
70 | 70 | else 0 | |
71 | 71 | else if ((size(selectedNumberBets) == 12)) | |
72 | 72 | then if (containsElement(selectedNumberBets, randomNumber)) | |
73 | 73 | then (bet * 3) | |
74 | 74 | else 0 | |
75 | 75 | else if ((betDirection == "red")) | |
76 | 76 | then if (containsElement(RED_SECTORS, randomNumber)) | |
77 | 77 | then (bet * 2) | |
78 | 78 | else 0 | |
79 | 79 | else if ((betDirection == "black")) | |
80 | 80 | then if (if (!(containsElement(RED_SECTORS, randomNumber))) | |
81 | 81 | then (randomNumber != 0) | |
82 | 82 | else false) | |
83 | 83 | then (bet * 2) | |
84 | 84 | else 0 | |
85 | 85 | else if ((betDirection == "odd")) | |
86 | 86 | then if (((randomNumber % 2) != 0)) | |
87 | 87 | then (bet * 2) | |
88 | 88 | else 0 | |
89 | 89 | else if ((betDirection == "even")) | |
90 | 90 | then if (((randomNumber % 2) == 0)) | |
91 | 91 | then (bet * 2) | |
92 | 92 | else 0 | |
93 | 93 | else if ((size(selectedNumberBets) == 18)) | |
94 | 94 | then if (containsElement(selectedNumberBets, randomNumber)) | |
95 | 95 | then (bet * 2) | |
96 | 96 | else 0 | |
97 | 97 | else 0 | |
98 | 98 | } | |
99 | 99 | ||
100 | 100 | ||
101 | 101 | @Callable(i) | |
102 | 102 | func LuckyWheel_commit () = if (!(isPaymentOk(i))) | |
103 | 103 | then throw("Wrong payment amount or asset") | |
104 | 104 | else [IntegerEntry(LW_getBetKey(i), (height + 1)), DeleteEntry(LW_getRandomNumberKey(i)), DeleteEntry(LW_getWonKey(i))] | |
105 | 105 | ||
106 | 106 | ||
107 | 107 | ||
108 | 108 | @Callable(i) | |
109 | 109 | func LuckyWheel_reveal () = { | |
110 | 110 | let commitHeight = valueOrErrorMessage(getIntegerValue(LW_getBetKey(i)), "Bet not found") | |
111 | 111 | if ((commitHeight > height)) | |
112 | 112 | then throw((("wait " + toString((commitHeight - height))) + " blocks to reveal this id")) | |
113 | 113 | else { | |
114 | 114 | let revealBlock = valueOrErrorMessage(blockInfoByHeight(commitHeight), "unexcpected error") | |
115 | 115 | let vrf = valueOrErrorMessage(revealBlock.vrf, "unexcpected error") | |
116 | 116 | let randomHash = sha256(value(vrf)) | |
117 | 117 | let randomSeed = (toInt(randomHash, 16) % 12) | |
118 | 118 | let randomNumber = ((randomSeed % ((12 - 1) + 1)) + 1) | |
119 | 119 | let winningAmount = LW_whatUserWon(randomNumber) | |
120 | 120 | if ((winningAmount > 0)) | |
121 | 121 | 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)] | |
122 | 122 | else [DeleteEntry(LW_getBetKey(i)), IntegerEntry(LW_getWonKey(i), winningAmount), IntegerEntry(LW_getRandomNumberKey(i), randomNumber), IntegerEntry(LW_getLogKey(i), winningAmount)] | |
123 | 123 | } | |
124 | 124 | } | |
125 | 125 | ||
126 | 126 | ||
127 | 127 | ||
128 | 128 | @Callable(i) | |
129 | - | func Test () = | |
129 | + | func Test (bet,selectedNumberBets,randomNumber,betDirection) = [IntegerEntry("R_WinCalculator", R_WinCalculator(bet, selectedNumberBets, randomNumber, betDirection))] | |
130 | 130 | ||
131 | 131 |
github/deemru/w8io/169f3d6 48.71 ms ◑