tx · Ff8opM7C4Eyt5bc6WZFDP1TZznkpq5puyB3bga1pqe3A 3Mynaio8coZLr58tu2AdBEhmCvB17vTBRkA: -0.01000000 Waves 2023.06.01 10:00 [2603261] smart account 3Mynaio8coZLr58tu2AdBEhmCvB17vTBRkA > SELF 0.00000000 Waves
{ "type": 13, "id": "Ff8opM7C4Eyt5bc6WZFDP1TZznkpq5puyB3bga1pqe3A", "fee": 1000000, "feeAssetId": null, "timestamp": 1685602814444, "version": 2, "chainId": 84, "sender": "3Mynaio8coZLr58tu2AdBEhmCvB17vTBRkA", "senderPublicKey": "Dx7cJVhpJb4qUDGiDnSjj6Wfjdj5nmzwVLfaggkbjDtv", "proofs": [ "3rbzum62RLQS7ugn1oxdSLyJgvrHR6MJH3Sxm3v8kvd48cUT2F6TTMHZTMrpSkMQk1yzdtZrjdDRbE2oBxfNrxu8" ], "script": "base64:BgIGCAISABIABgEKbnVtVG9XYXZlcwEDbnVtCQBoAgUDbnVtAIDC1y8BC2lzUGF5bWVudE9rAQFpBBFhY2NlcHRhYmxlQXNzZXRJZAEgIkSm54hUfVEormpXug9p+nbhDnc37ahHq1IfaU2UQkcDCQAAAgkAkAMBCAUBaQhwYXltZW50cwAACQACAQIUUGF5bWVudCBub3QgYXR0YWNoZWQEAXAJAJEDAggFAWkIcGF5bWVudHMAAAQHJG1hdGNoMAgFAXAHYXNzZXRJZAMJAAECBQckbWF0Y2gwAgpCeXRlVmVjdG9yBAdhc3NldElkBQckbWF0Y2gwAwkAAAIFB2Fzc2V0SWQFEWFjY2VwdGFibGVBc3NldElkCQBnAggFAXAGYW1vdW50CQEKbnVtVG9XYXZlcwEAAQcJAGcCCAUBcAZhbW91bnQJAQpudW1Ub1dhdmVzAQABARNnZXRMdWNreVdoZWVsQmV0S2V5AQFpCQCsAgICD2JldF9MdWNreVdoZWVsXwkApQgBCAUBaQZjYWxsZXIBE2dldEx1Y2t5V2hlZWxXb25LZXkBAWkJAKwCAgIPd29uX0x1Y2t5V2hlZWxf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QkA9QMBBQN2cmYEDHJhbmRvbU51bWJlcgkAZAIJAGoCBQpyYW5kb21TZWVkCQBkAgkAZQIADAABAAEAAQQNd2lubmluZ0Ftb3VudAkBGWdhbWVMdWNreVdoZWVsV2hhdFVzZXJXb24BBQxyYW5kb21OdW1iZXIDCQBmAgUNd2lubmluZ0Ftb3VudAAACQDMCAIJAQtEZWxldGVFbnRyeQEJARNnZXRMdWNreVdoZWVsQmV0S2V5AQUBaQkAzAgCCQEOU2NyaXB0VHJhbnNmZXIDCAUBaQZjYWxsZXIFDXdpbm5pbmdBbW91bnQFBHVuaXQJAMwIAgkBDEludGVnZXJFbnRyeQIJARNnZXRMdWNreVdoZWVsV29uS2V5AQUBaQUNd2lubmluZ0Ftb3VudAkAzAgCCQEMSW50ZWdlckVudHJ5AgkBHGdldEx1Y2t5V2hlZWxSYW5kb21OdW1iZXJLZXkBBQFpBQxyYW5kb21OdW1iZXIFA25pbAkAzAgCCQELRGVsZXRlRW50cnkBCQETZ2V0THVja3lXaGVlbEJldEtleQEFAWkJAMwIAgkBDEludGVnZXJFbnRyeQIJARNnZXRMdWNreVdoZWVsV29uS2V5AQUBaQUNd2lubmluZ0Ftb3VudAkAzAgCCQEMSW50ZWdlckVudHJ5AgkBHGdldEx1Y2t5V2hlZWxSYW5kb21OdW1iZXJLZXkBBQFpBQxyYW5kb21OdW1iZXIFA25pbAC395AY", "height": 2603261, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 3oskqxZztcAUS3PemdsMDntReEcyUDiBH8dV6p8teCoD Next: 4RG8Fit1vRGWGGHaBKGKsSo1gTuP8cgScYchQXv35yDK Diff:
Old | New | Differences | |
---|---|---|---|
26 | 26 | ||
27 | 27 | ||
28 | 28 | func getLuckyWheelWonKey (i) = ("won_LuckyWheel_" + toString(i.caller)) | |
29 | + | ||
30 | + | ||
31 | + | func getLuckyWheelRandomNumberKey (i) = ("randomNumber_LuckyWheel_" + toString(i.caller)) | |
29 | 32 | ||
30 | 33 | ||
31 | 34 | func gameLuckyWheelWhatUserWon (value) = match value { | |
61 | 64 | let randomNumber = ((randomSeed % ((12 - 1) + 1)) + 1) | |
62 | 65 | let winningAmount = gameLuckyWheelWhatUserWon(randomNumber) | |
63 | 66 | if ((winningAmount > 0)) | |
64 | - | then [DeleteEntry(getLuckyWheelBetKey(i)), ScriptTransfer(i.caller, winningAmount, unit), IntegerEntry(getLuckyWheelWonKey(i), winningAmount)] | |
65 | - | else [DeleteEntry(getLuckyWheelBetKey(i)), IntegerEntry(getLuckyWheelWonKey(i), winningAmount)] | |
67 | + | then [DeleteEntry(getLuckyWheelBetKey(i)), ScriptTransfer(i.caller, winningAmount, unit), IntegerEntry(getLuckyWheelWonKey(i), winningAmount), IntegerEntry(getLuckyWheelRandomNumberKey(i), randomNumber)] | |
68 | + | else [DeleteEntry(getLuckyWheelBetKey(i)), IntegerEntry(getLuckyWheelWonKey(i), winningAmount), IntegerEntry(getLuckyWheelRandomNumberKey(i), randomNumber)] | |
66 | 69 | } | |
67 | 70 | } | |
68 | 71 |
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 | + | ||
30 | + | ||
31 | + | func getLuckyWheelRandomNumberKey (i) = ("randomNumber_LuckyWheel_" + toString(i.caller)) | |
29 | 32 | ||
30 | 33 | ||
31 | 34 | func gameLuckyWheelWhatUserWon (value) = match value { | |
32 | 35 | case _ => | |
33 | 36 | if ((1 == $match0)) | |
34 | 37 | then numToWaves(2) | |
35 | 38 | else if ((5 == $match0)) | |
36 | 39 | then numToWaves(1) | |
37 | 40 | else if ((7 == $match0)) | |
38 | 41 | then numToWaves(4) | |
39 | 42 | else if ((11 == $match0)) | |
40 | 43 | then numToWaves(1) | |
41 | 44 | else 0 | |
42 | 45 | } | |
43 | 46 | ||
44 | 47 | ||
45 | 48 | @Callable(i) | |
46 | 49 | func commitLuckyWheel () = if (!(isPaymentOk(i))) | |
47 | 50 | then throw("Wrong payment amount or asset") | |
48 | 51 | else [IntegerEntry(getLuckyWheelBetKey(i), (height + 1))] | |
49 | 52 | ||
50 | 53 | ||
51 | 54 | ||
52 | 55 | @Callable(i) | |
53 | 56 | func revealLuckyWheel () = { | |
54 | 57 | let commitHeight = valueOrErrorMessage(getIntegerValue(getLuckyWheelBetKey(i)), "Bet not found") | |
55 | 58 | if ((commitHeight > height)) | |
56 | 59 | then throw((("wait " + toString((commitHeight - height))) + " blocks to reveal this id")) | |
57 | 60 | else { | |
58 | 61 | let revealBlock = valueOrErrorMessage(blockInfoByHeight(commitHeight), "unexcpected error") | |
59 | 62 | let vrf = valueOrErrorMessage(revealBlock.vrf, "unexcpected error") | |
60 | 63 | let randomSeed = toInt(keccak256(vrf)) | |
61 | 64 | let randomNumber = ((randomSeed % ((12 - 1) + 1)) + 1) | |
62 | 65 | let winningAmount = gameLuckyWheelWhatUserWon(randomNumber) | |
63 | 66 | if ((winningAmount > 0)) | |
64 | - | then [DeleteEntry(getLuckyWheelBetKey(i)), ScriptTransfer(i.caller, winningAmount, unit), IntegerEntry(getLuckyWheelWonKey(i), winningAmount)] | |
65 | - | else [DeleteEntry(getLuckyWheelBetKey(i)), IntegerEntry(getLuckyWheelWonKey(i), winningAmount)] | |
67 | + | then [DeleteEntry(getLuckyWheelBetKey(i)), ScriptTransfer(i.caller, winningAmount, unit), IntegerEntry(getLuckyWheelWonKey(i), winningAmount), IntegerEntry(getLuckyWheelRandomNumberKey(i), randomNumber)] | |
68 | + | else [DeleteEntry(getLuckyWheelBetKey(i)), IntegerEntry(getLuckyWheelWonKey(i), winningAmount), IntegerEntry(getLuckyWheelRandomNumberKey(i), randomNumber)] | |
66 | 69 | } | |
67 | 70 | } | |
68 | 71 | ||
69 | 72 |
github/deemru/w8io/169f3d6 32.41 ms ◑