tx · GhrnZDcmfPjrg58w2WRU3Epwdho4jvCKNZvugMDL7ia4 3Mynaio8coZLr58tu2AdBEhmCvB17vTBRkA: -0.01000000 Waves 2023.05.31 21:25 [2602506] smart account 3Mynaio8coZLr58tu2AdBEhmCvB17vTBRkA > SELF 0.00000000 Waves
{ "type": 13, "id": "GhrnZDcmfPjrg58w2WRU3Epwdho4jvCKNZvugMDL7ia4", "fee": 1000000, "feeAssetId": null, "timestamp": 1685557557286, "version": 2, "chainId": 84, "sender": "3Mynaio8coZLr58tu2AdBEhmCvB17vTBRkA", "senderPublicKey": "Dx7cJVhpJb4qUDGiDnSjj6Wfjdj5nmzwVLfaggkbjDtv", "proofs": [ "3tTZ7JQejC9n4bdghJ3QMj1zGAqUdBnn3AFnQzmLpXuM6AvNGumWTjeZZmjtMHsyAFqtMFHwAP7YdHqBFoGjthuk" ], "script": "base64:AAIEAAAAAAAAAAwIAhIDCgEIEgMKAQEAAAAEAQAAAApudW1Ub1dhdmVzAAAAAQAAAANudW0JAABoAAAAAgUAAAADbnVtAAAAAAAF9eEAAQAAABRnZW5lcmF0ZVJhbmRvbU51bWJlcgAAAAMAAAABaQAAAANtaW4AAAADbWF4BAAAAApyYW5kb21TZWVkCQAEsQAAAAEJAAH1AAAAAQgFAAAAAWkAAAANdHJhbnNhY3Rpb25JZAQAAAAMcmFuZG9tTnVtYmVyCQAAZAAAAAIJAABqAAAAAgUAAAAKcmFuZG9tU2VlZAkAAGQAAAACCQAAZQAAAAIFAAAAA21heAUAAAADbWluAAAAAAAAAAABBQAAAANtaW4FAAAADHJhbmRvbU51bWJlcgEAAAALaXNQYXltZW50T2sAAAABAAAAAWkEAAAAEWFjY2VwdGFibGVBc3NldElkAQAAACAiRKbniFR9USiuale6D2n6duEOdzftqEerUh9pTZRCRwMJAAAAAAAAAgkAAZAAAAABCAUAAAABaQAAAAhwYXltZW50cwAAAAAAAAAAAAkAAAIAAAABAgAAABRQYXltZW50IG5vdCBhdHRhY2hlZAQAAAABcAk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VzdF9nYW1lX3JhbmRvbU51bWJlcl8FAAAAAmlkBQAAAAxyYW5kb21OdW1iZXIJAARMAAAAAgkBAAAADEludGVnZXJFbnRyeQAAAAIJAAEsAAAAAgIAAAAYdGVzdF9nYW1lX3dpbm5pbmdBbW91bnRfBQAAAAJpZAUAAAANd2lubmluZ0Ftb3VudAUAAAADbmlsCQAETAAAAAIJAQAAAAxJbnRlZ2VyRW50cnkAAAACCQABLAAAAAICAAAABWdhbWVfBQAAAAJpZAUAAAANd2lubmluZ0Ftb3VudAkABEwAAAACCQEAAAALU3RyaW5nRW50cnkAAAACCQABLAAAAAICAAAADGdhbWVfc3RhdHVzXwUAAAACaWQCAAAABGxvc2UJAARMAAAAAgkBAAAADEludGVnZXJFbnRyeQAAAAIJAAEsAAAAAgIAAAAXdGVzdF9nYW1lX3JhbmRvbU51bWJlcl8FAAAAAmlkBQAAAAxyYW5kb21OdW1iZXIJAARMAAAAAgkBAAAADEludGVnZXJFbnRyeQAAAAIJAAEsAAAAAgIAAAAYdGVzdF9nYW1lX3dpbm5pbmdBbW91bnRfBQAAAAJpZAUAAAANd2lubmluZ0Ftb3VudAUAAAADbmlsAAAAAWkBAAAAEGNvbW1pdEx1Y2t5V2hlZWwAAAABAAAAA2JldAQAAAAFYnl0ZXMJAAQlAAAAAQgFAAAAAWkAAAAGY2FsbGVyCQAETAAAAAIJAQAAAAtTdHJpbmdFbnRyeQAAAAICAAAABHRlc3QFAAAABWJ5dGVzBQAAAANuaWwAAAAA4w9LwA==", "height": 2602506, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: Bbf3BU8TcGYU3Ap61GFcKyt3PuFetCunhNCpeij5NDW4 Next: HoCW69TMjiYjffqCBVVisk7BDQcYdenKwuASUuB7wUxk Full:
Old | New | Differences | |
---|---|---|---|
1 | - | {-# STDLIB_VERSION | |
1 | + | {-# STDLIB_VERSION 4 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | let N = 1 | |
4 | + | func numToWaves (num) = (num * 100000000) | |
5 | + | ||
6 | + | ||
7 | + | func generateRandomNumber (i,min,max) = { | |
8 | + | let randomSeed = toInt(keccak256(i.transactionId)) | |
9 | + | let randomNumber = ((randomSeed % ((max - min) + 1)) + min) | |
10 | + | randomNumber | |
11 | + | } | |
12 | + | ||
13 | + | ||
14 | + | func isPaymentOk (i) = { | |
15 | + | let acceptableAssetId = base58'3JmaWyFqWo8YSA8x3DXCBUW7veesxacvKx19dMv7wTMg' | |
16 | + | if ((size(i.payments) == 0)) | |
17 | + | then throw("Payment not attached") | |
18 | + | else { | |
19 | + | let p = i.payments[0] | |
20 | + | match p.assetId { | |
21 | + | case assetId: ByteVector => | |
22 | + | if ((assetId == acceptableAssetId)) | |
23 | + | then (p.amount >= numToWaves(1)) | |
24 | + | else false | |
25 | + | case _ => | |
26 | + | (p.amount >= numToWaves(1)) | |
27 | + | } | |
28 | + | } | |
29 | + | } | |
30 | + | ||
31 | + | ||
32 | + | func gameLuckyWheelWhatUserWon (value) = match value { | |
33 | + | case _ => | |
34 | + | if ((1 == $match0)) | |
35 | + | then numToWaves(2) | |
36 | + | else if ((5 == $match0)) | |
37 | + | then numToWaves(1) | |
38 | + | else if ((7 == $match0)) | |
39 | + | then numToWaves(4) | |
40 | + | else if ((11 == $match0)) | |
41 | + | then numToWaves(1) | |
42 | + | else 0 | |
43 | + | } | |
44 | + | ||
5 | 45 | ||
6 | 46 | @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)] | |
47 | + | func gameLuckyWheel (id) = if (!(isPaymentOk(i))) | |
48 | + | then throw("Wrong payment amount or asset") | |
49 | + | else { | |
50 | + | let randomNumber = generateRandomNumber(i, 1, 12) | |
51 | + | let winningAmount = gameLuckyWheelWhatUserWon(randomNumber) | |
52 | + | if ((winningAmount == numToWaves(1))) | |
53 | + | then [ScriptTransfer(i.caller, winningAmount, unit), StringEntry(("game_status_" + id), "roll"), IntegerEntry(("game_" + id), winningAmount), IntegerEntry(("test_game_randomNumber_" + id), randomNumber), IntegerEntry(("test_game_winningAmount_" + id), winningAmount)] | |
54 | + | else if ((winningAmount > 0)) | |
55 | + | then [ScriptTransfer(i.caller, winningAmount, unit), StringEntry(("game_status_" + id), "win"), IntegerEntry(("game_" + id), winningAmount), IntegerEntry(("test_game_randomNumber_" + id), randomNumber), IntegerEntry(("test_game_winningAmount_" + id), winningAmount)] | |
56 | + | else [IntegerEntry(("game_" + id), winningAmount), StringEntry(("game_status_" + id), "lose"), IntegerEntry(("test_game_randomNumber_" + id), randomNumber), IntegerEntry(("test_game_winningAmount_" + id), winningAmount)] | |
57 | + | } | |
12 | 58 | ||
13 | 59 | ||
14 | 60 | ||
15 | 61 | @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([IntegerEntry((id + "_result"), goal)], win) | |
31 | - | } | |
32 | - | } | |
62 | + | func commitLuckyWheel (bet) = { | |
63 | + | let bytes = toString(i.caller) | |
64 | + | [StringEntry("test", bytes)] | |
65 | + | } | |
33 | 66 | ||
34 | 67 |
github/deemru/w8io/169f3d6 33.71 ms ◑