tx · 9t9HMWUsoP97r7c7eirMrxRxabZEMV5BKtp23HUDdnbV 3N6GuFb7Ucxs3cZjmwYDusKtfLaAigDtav5: -0.01000000 Waves 2023.05.29 19:07 [2599481] smart account 3N6GuFb7Ucxs3cZjmwYDusKtfLaAigDtav5 > SELF 0.00000000 Waves
{ "type": 13, "id": "9t9HMWUsoP97r7c7eirMrxRxabZEMV5BKtp23HUDdnbV", "fee": 1000000, "feeAssetId": null, "timestamp": 1685376472045, "version": 2, "chainId": 84, "sender": "3N6GuFb7Ucxs3cZjmwYDusKtfLaAigDtav5", "senderPublicKey": "EMAuwff72FwVoiJK9xHyuUUMbpKmgV5temqeLU2aEsiS", "proofs": [ "4SyChRQ9mQiDEc1sxJqTHqVUMbPisPcoZeLN46HsDcFAyGNSRNDeqzG85eqHwQqhj7qDhoaFrToLX52NUxE6V9QV" ], "script": "base64:AAIEAAAAAAAAAAcIAhIDCgEIAAAAAwEAAAAUZ2VuZXJhdGVSYW5kb21OdW1iZXIAAAADAAAAAWkAAAADbWluAAAAA21heAQAAAAKcmFuZG9tU2VlZAkABLEAAAABCQAB9QAAAAEIBQAAAAFpAAAADXRyYW5zYWN0aW9uSWQEAAAADHJhbmRvbU51bWJlcgkAAGQAAAACCQAAagAAAAIFAAAACnJhbmRvbVNlZWQJAABkAAAAAgkAAGUAAAACBQAAAANtYXgFAAAAA21pbgAAAAAAAAAAAQUAAAADbWluBQAAAAxyYW5kb21OdW1iZXIBAAAAC2lzUGF5bWVudE9rAAAAAQAAAAFpBAAAABFhY2NlcHRhYmxlQXNzZXRJZAEAAAAgIkSm54hUfVEormpXug9p+nbhDnc37ahHq1IfaU2UQkcDCQAAAAAAAAIJAAGQAAAAAQgFAAAAAWkAAAAIcGF5bWVudHMAAAAAAAAAAAAJAAACAAAAAQIAAAAUUGF5bWVudCBub3QgYXR0YWNoZWQEAAAAAXAJAAGRAAAAAggFAAAAAWkAAAAIcGF5bWVudHMAAAAAAAAAAAAEAAAAByRtYXRjaDAIB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AOU2NyaXB0VHJhbnNmZXIAAAADCAUAAAABaQAAAAZjYWxsZXIFAAAADXdpbm5pbmdBbW91bnQFAAAABHVuaXQJAARMAAAAAgkBAAAADEludGVnZXJFbnRyeQAAAAIJAAEsAAAAAgIAAAAFZ2FtZV8FAAAAAmlkBQAAAA13aW5uaW5nQW1vdW50BQAAAANuaWwJAARMAAAAAgkBAAAADEludGVnZXJFbnRyeQAAAAIJAAEsAAAAAgIAAAAFZ2FtZV8FAAAAAmlkBQAAAA13aW5uaW5nQW1vdW50BQAAAANuaWwAAAAApvswfg==", "height": 2599481, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 8UmzEeFAgCqhd6AQcHCE2Bym93itBf78efqNE6Dd2Jng Next: DRykuMBG3XybRhBPrJQWswKMcWXJzUqBuzFBeXvqya57 Diff:
Old | New | Differences | |
---|---|---|---|
1 | - | {-# STDLIB_VERSION | |
1 | + | {-# STDLIB_VERSION 4 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | func getRandomNumber () = { | |
5 | - | let randomSeedBlock = value(blockInfoByHeight(2)) | |
6 | - | let randomHash = sha256_16Kb(value(randomSeedBlock.vrf)) | |
7 | - | toInt(randomHash) | |
8 | - | } | |
9 | - | ||
10 | - | ||
11 | 4 | func generateRandomNumber (i,min,max) = { | |
12 | 5 | let randomSeed = toInt(keccak256(i.transactionId)) | |
13 | 6 | let randomNumber = ((randomSeed % ((max - min) + 1)) + min) | |
15 | 8 | } | |
16 | 9 | ||
17 | 10 | ||
18 | - | func getRandomNumber2 () = { | |
19 | - | let randomSeedBlock = value(blockInfoByHeight(2)) | |
20 | - | let randomHash = sha256_16Kb(value(randomSeedBlock.vrf)) | |
21 | - | toBase64String(randomHash) | |
11 | + | func isPaymentOk (i) = { | |
12 | + | let acceptableAssetId = base58'3JmaWyFqWo8YSA8x3DXCBUW7veesxacvKx19dMv7wTMg' | |
13 | + | if ((size(i.payments) == 0)) | |
14 | + | then throw("Payment not attached") | |
15 | + | else { | |
16 | + | let p = i.payments[0] | |
17 | + | match p.assetId { | |
18 | + | case assetId: ByteVector => | |
19 | + | if ((assetId == acceptableAssetId)) | |
20 | + | then (p.amount >= 100000000) | |
21 | + | else false | |
22 | + | case _ => | |
23 | + | (p.amount >= 100000000) | |
24 | + | } | |
25 | + | } | |
22 | 26 | } | |
23 | 27 | ||
24 | 28 | ||
25 | - | func test5h1 (address) = [StringEntry("address2", address)] | |
26 | - | ||
27 | - | ||
28 | - | func calc () = 3 | |
29 | + | func gameLuckyWheelWhatUserWon (value) = match value { | |
30 | + | case _ => | |
31 | + | if ((1 == $match0)) | |
32 | + | then 200000000 | |
33 | + | else if ((3 == $match0)) | |
34 | + | then 100000000 | |
35 | + | else if ((5 == $match0)) | |
36 | + | then 100000000 | |
37 | + | else if ((7 == $match0)) | |
38 | + | then 300000000 | |
39 | + | else if ((8 == $match0)) | |
40 | + | then 100000000 | |
41 | + | else if ((11 == $match0)) | |
42 | + | then 100000000 | |
43 | + | else 0 | |
44 | + | } | |
29 | 45 | ||
30 | 46 | ||
31 | 47 | @Callable(i) | |
32 | - | func test1 () = { | |
33 | - | let result = generateRandomNumber(i, 1, 12) | |
34 | - | let x = $Tuple2([IntegerEntry("result", result)], result) | |
35 | - | throw(toString(result)) | |
36 | - | } | |
37 | - | ||
38 | - | ||
39 | - | ||
40 | - | @Callable(i) | |
41 | - | func test3 () = { | |
42 | - | let address = toBase58String(i.caller.bytes) | |
43 | - | [StringEntry("address", address)] | |
44 | - | } | |
45 | - | ||
46 | - | ||
47 | - | ||
48 | - | @Callable(i) | |
49 | - | func test4 () = { | |
50 | - | let address = toBase58String(i.caller.bytes) | |
51 | - | throw(address) | |
52 | - | } | |
53 | - | ||
54 | - | ||
55 | - | ||
56 | - | @Callable(i) | |
57 | - | func test5 () = { | |
58 | - | let address = toBase58String(i.caller.bytes) | |
59 | - | test5h1(address) | |
60 | - | } | |
61 | - | ||
62 | - | ||
63 | - | ||
64 | - | @Callable(i) | |
65 | - | func test6 () = { | |
66 | - | let address = toBase58String(i.caller.bytes) | |
67 | - | let r = test5h1(address) | |
68 | - | throw(address) | |
69 | - | } | |
70 | - | ||
71 | - | ||
72 | - | ||
73 | - | @Callable(i) | |
74 | - | func test7 () = { | |
75 | - | let address = toBase58String(i.caller.bytes) | |
76 | - | let r = toString(getRandomNumber()) | |
77 | - | throw(r) | |
78 | - | } | |
48 | + | func gameLuckyWheel (id) = if (!(isPaymentOk(i))) | |
49 | + | then throw("Wrong payment amount or asset") | |
50 | + | else { | |
51 | + | let randomNumber = generateRandomNumber(i, 1, 12) | |
52 | + | let winningAmount = gameLuckyWheelWhatUserWon(randomNumber) | |
53 | + | if ((winningAmount > 0)) | |
54 | + | then [ScriptTransfer(i.caller, winningAmount, unit), IntegerEntry(("game_" + id), winningAmount)] | |
55 | + | else [IntegerEntry(("game_" + id), winningAmount)] | |
56 | + | } | |
79 | 57 | ||
80 | 58 |
Old | New | Differences | |
---|---|---|---|
1 | - | {-# STDLIB_VERSION | |
1 | + | {-# STDLIB_VERSION 4 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | func getRandomNumber () = { | |
5 | - | let randomSeedBlock = value(blockInfoByHeight(2)) | |
6 | - | let randomHash = sha256_16Kb(value(randomSeedBlock.vrf)) | |
7 | - | toInt(randomHash) | |
8 | - | } | |
9 | - | ||
10 | - | ||
11 | 4 | func generateRandomNumber (i,min,max) = { | |
12 | 5 | let randomSeed = toInt(keccak256(i.transactionId)) | |
13 | 6 | let randomNumber = ((randomSeed % ((max - min) + 1)) + min) | |
14 | 7 | randomNumber | |
15 | 8 | } | |
16 | 9 | ||
17 | 10 | ||
18 | - | func getRandomNumber2 () = { | |
19 | - | let randomSeedBlock = value(blockInfoByHeight(2)) | |
20 | - | let randomHash = sha256_16Kb(value(randomSeedBlock.vrf)) | |
21 | - | toBase64String(randomHash) | |
11 | + | func isPaymentOk (i) = { | |
12 | + | let acceptableAssetId = base58'3JmaWyFqWo8YSA8x3DXCBUW7veesxacvKx19dMv7wTMg' | |
13 | + | if ((size(i.payments) == 0)) | |
14 | + | then throw("Payment not attached") | |
15 | + | else { | |
16 | + | let p = i.payments[0] | |
17 | + | match p.assetId { | |
18 | + | case assetId: ByteVector => | |
19 | + | if ((assetId == acceptableAssetId)) | |
20 | + | then (p.amount >= 100000000) | |
21 | + | else false | |
22 | + | case _ => | |
23 | + | (p.amount >= 100000000) | |
24 | + | } | |
25 | + | } | |
22 | 26 | } | |
23 | 27 | ||
24 | 28 | ||
25 | - | func test5h1 (address) = [StringEntry("address2", address)] | |
26 | - | ||
27 | - | ||
28 | - | func calc () = 3 | |
29 | + | func gameLuckyWheelWhatUserWon (value) = match value { | |
30 | + | case _ => | |
31 | + | if ((1 == $match0)) | |
32 | + | then 200000000 | |
33 | + | else if ((3 == $match0)) | |
34 | + | then 100000000 | |
35 | + | else if ((5 == $match0)) | |
36 | + | then 100000000 | |
37 | + | else if ((7 == $match0)) | |
38 | + | then 300000000 | |
39 | + | else if ((8 == $match0)) | |
40 | + | then 100000000 | |
41 | + | else if ((11 == $match0)) | |
42 | + | then 100000000 | |
43 | + | else 0 | |
44 | + | } | |
29 | 45 | ||
30 | 46 | ||
31 | 47 | @Callable(i) | |
32 | - | func test1 () = { | |
33 | - | let result = generateRandomNumber(i, 1, 12) | |
34 | - | let x = $Tuple2([IntegerEntry("result", result)], result) | |
35 | - | throw(toString(result)) | |
36 | - | } | |
37 | - | ||
38 | - | ||
39 | - | ||
40 | - | @Callable(i) | |
41 | - | func test3 () = { | |
42 | - | let address = toBase58String(i.caller.bytes) | |
43 | - | [StringEntry("address", address)] | |
44 | - | } | |
45 | - | ||
46 | - | ||
47 | - | ||
48 | - | @Callable(i) | |
49 | - | func test4 () = { | |
50 | - | let address = toBase58String(i.caller.bytes) | |
51 | - | throw(address) | |
52 | - | } | |
53 | - | ||
54 | - | ||
55 | - | ||
56 | - | @Callable(i) | |
57 | - | func test5 () = { | |
58 | - | let address = toBase58String(i.caller.bytes) | |
59 | - | test5h1(address) | |
60 | - | } | |
61 | - | ||
62 | - | ||
63 | - | ||
64 | - | @Callable(i) | |
65 | - | func test6 () = { | |
66 | - | let address = toBase58String(i.caller.bytes) | |
67 | - | let r = test5h1(address) | |
68 | - | throw(address) | |
69 | - | } | |
70 | - | ||
71 | - | ||
72 | - | ||
73 | - | @Callable(i) | |
74 | - | func test7 () = { | |
75 | - | let address = toBase58String(i.caller.bytes) | |
76 | - | let r = toString(getRandomNumber()) | |
77 | - | throw(r) | |
78 | - | } | |
48 | + | func gameLuckyWheel (id) = if (!(isPaymentOk(i))) | |
49 | + | then throw("Wrong payment amount or asset") | |
50 | + | else { | |
51 | + | let randomNumber = generateRandomNumber(i, 1, 12) | |
52 | + | let winningAmount = gameLuckyWheelWhatUserWon(randomNumber) | |
53 | + | if ((winningAmount > 0)) | |
54 | + | then [ScriptTransfer(i.caller, winningAmount, unit), IntegerEntry(("game_" + id), winningAmount)] | |
55 | + | else [IntegerEntry(("game_" + id), winningAmount)] | |
56 | + | } | |
79 | 57 | ||
80 | 58 |
github/deemru/w8io/169f3d6 28.26 ms ◑