tx · 9zyoZV4p2Zr3MGLcHxtstmu74XuMaaVpxxTzSVyzc19Q 3Mu9qAjmg8fVTxxpwPZnBAH948ujt4m6Xvk: -0.01000000 Waves 2021.10.15 00:54 [1746508] smart account 3Mu9qAjmg8fVTxxpwPZnBAH948ujt4m6Xvk > SELF 0.00000000 Waves
{ "type": 13, "id": "9zyoZV4p2Zr3MGLcHxtstmu74XuMaaVpxxTzSVyzc19Q", "fee": 1000000, "feeAssetId": null, "timestamp": 1634248506195, "version": 2, "chainId": 84, "sender": "3Mu9qAjmg8fVTxxpwPZnBAH948ujt4m6Xvk", "senderPublicKey": "8v9pmcXqHz9DTc5k1Z8duTYyDwykFxN3EzdZ9WAn3KXJ", "proofs": [ "2VjP83t8Cu6kugmkJRwzx4Hb4CFhhzifjfgcPfiXWTAXkKe1QNABhcYy9YRotLvnuQcUWzTS1orAdh5Yb5BccaqV" ], "script": "base64:AAIDAAAAAAAAAAgIARIECgIBAQAAAAgAAAAADWdhbWVOdW1iZXJLZXkCAAAADCRHQU1FX05VTUJFUgAAAAALbGFzdFBsYXlLZXkCAAAACiRMQVNUX1BMQVkAAAAAB3Rlc3RLZXkCAAAABSRURVNUAAAAAANXT04AAAAAAAAAAAEAAAAABExPU0UAAAAAAAAAAAIBAAAACnBheW91dGNhbGMAAAABAAAABm51bWJlcgQAAAAFaG91c2UAAAAAAAAAAAYEAAAABGJhc2UAAAAAAAAAJxAJAABpAAAAAgkAAGgAAAACBQAAAARiYXNlCQAAaQAAAAIJAABlAAAAAgAAAAAAAAAAZAAAAAAAAAAABgAAAAAAAAAAZAUAAAAGbnVtYmVyAQAAAApyYW5kb21pemVyAAAAAQAAAAFpBAAAAAhsYXN0UGxheQQAAAAHJG1hdGNoMAkABBwAAAACBQAAAAR0aGlzBQAAAAtsYXN0UGxheUtleQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAAKQnl0ZVZlY3RvcgQAAAABcwUAAAAHJG1hdGNoMAUAAAABcwMJAAABAAAAAgUAAA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lsCQEAAAAMU2NyaXB0UmVzdWx0AAAAAgUAAAANd3JpdGVMYXN0UGxheQkBAAAAC1RyYW5zZmVyU2V0AAAAAQUAAAADbmlsAAAAAQAAAAFpAQAAAAl6ZXJvMmhlcm8AAAACAAAACmd1ZXNzU3RhcnQAAAAIZ3Vlc3NFbmQJAQAAAApzdGFydExvdHRvAAAAAwUAAAABaQUAAAAKZ3Vlc3NTdGFydAUAAAAIZ3Vlc3NFbmQAAAAAgKs6cg==", "height": 1746508, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: Dxmmapjih7X6uXGeptDJPXbQAP5KbF5nViKqnTLqRAXk Next: J7AfqSYcbRhSbR7ip51YqxyajwJKRiQxaA5XQtE9PLCE Diff:
Old | New | Differences | |
---|---|---|---|
4 | 4 | let gameNumberKey = "$GAME_NUMBER" | |
5 | 5 | ||
6 | 6 | let lastPlayKey = "$LAST_PLAY" | |
7 | + | ||
8 | + | let testKey = "$TEST" | |
7 | 9 | ||
8 | 10 | let WON = 1 | |
9 | 11 | ||
68 | 70 | else false) | |
69 | 71 | then { | |
70 | 72 | let str = ((((((((((toString(WON) + "_WON_") + transactionId) + "_") + gameKey) + "_") + toString(guessStart)) + "-") + toString(guessEnd)) + "_") + toString(rand)) | |
71 | - | let writeLastPlay = WriteSet([DataEntry(lastPlayKey, rand), DataEntry(gameKey, str), DataEntry(gameNumberKey, (gameId + 1))]) | |
73 | + | let payoutRate = (payoutcalc(((guessEnd - guessStart) + 1)) / 100) | |
74 | + | let writeLastPlay = WriteSet([DataEntry(lastPlayKey, rand), DataEntry(gameKey, str), DataEntry(gameNumberKey, (gameId + 1)), DataEntry(testKey, ((toString(payoutRate) + "_") + toString((payment.amount * payoutRate))))]) | |
72 | 75 | ScriptResult(writeLastPlay, TransferSet([ScriptTransfer(i.caller, ((payment.amount * payoutcalc(((guessEnd - guessStart) + 1))) / 100), unit)])) | |
73 | 76 | } | |
74 | 77 | else { |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let gameNumberKey = "$GAME_NUMBER" | |
5 | 5 | ||
6 | 6 | let lastPlayKey = "$LAST_PLAY" | |
7 | + | ||
8 | + | let testKey = "$TEST" | |
7 | 9 | ||
8 | 10 | let WON = 1 | |
9 | 11 | ||
10 | 12 | let LOSE = 2 | |
11 | 13 | ||
12 | 14 | func payoutcalc (number) = { | |
13 | 15 | let house = 6 | |
14 | 16 | let base = 10000 | |
15 | 17 | ((base * ((100 - 6) / 100)) / number) | |
16 | 18 | } | |
17 | 19 | ||
18 | 20 | ||
19 | 21 | func randomizer (i) = { | |
20 | 22 | let lastPlay = match getBinary(this, lastPlayKey) { | |
21 | 23 | case s: ByteVector => | |
22 | 24 | s | |
23 | 25 | case _: Unit => | |
24 | 26 | base58'2ee4oFDYriWJ9EMeR' | |
25 | 27 | case _ => | |
26 | 28 | throw("Match error") | |
27 | 29 | } | |
28 | 30 | let rand = (((((lastPlay + i.transactionId) + i.callerPublicKey) + lastBlock.generationSignature) + toBytes(lastBlock.timestamp)) + toBytes(lastBlock.height)) | |
29 | 31 | sha256(rand) | |
30 | 32 | } | |
31 | 33 | ||
32 | 34 | ||
33 | 35 | func startLotto (i,guessStart,guessEnd) = { | |
34 | 36 | let playLimit = (wavesBalance(this) / 100) | |
35 | 37 | let payment = extract(i.payment) | |
36 | 38 | if (!(isDefined(i.payment))) | |
37 | 39 | then throw("Should be with Payment in Waves") | |
38 | 40 | else if (isDefined(payment.assetId)) | |
39 | 41 | then throw("Payment should be in Waves") | |
40 | 42 | else if ((payment.amount > playLimit)) | |
41 | 43 | then throw(("Payment should be less than " + toString(playLimit))) | |
42 | 44 | else if ((0 > guessStart)) | |
43 | 45 | then throw("guessStart and guessEnd Must be in between 0-99") | |
44 | 46 | else if ((guessEnd > 99)) | |
45 | 47 | then throw("guessStart and guessEnd Must be in between 0-99") | |
46 | 48 | else if ((guessStart > guessEnd)) | |
47 | 49 | then throw("guessStart and guessEnd Must be in between 0-99") | |
48 | 50 | else if ((5 > ((guessEnd - guessStart) + 1))) | |
49 | 51 | then throw("guessStart and guessEnd Must be at least 5 apart") | |
50 | 52 | else if ((((guessEnd - guessStart) + 1) > 95)) | |
51 | 53 | then throw("guessStart and guessEnd Must not be at least 95 apart") | |
52 | 54 | else { | |
53 | 55 | let callerAddress = toBase58String(i.caller.bytes) | |
54 | 56 | let transactionId = toBase58String(i.transactionId) | |
55 | 57 | let randhash = randomizer(i) | |
56 | 58 | let rand = (toInt(randhash) % 100) | |
57 | 59 | let gameId = match getInteger(this, gameNumberKey) { | |
58 | 60 | case a: Int => | |
59 | 61 | a | |
60 | 62 | case _: Unit => | |
61 | 63 | 1 | |
62 | 64 | case _ => | |
63 | 65 | throw("Match error") | |
64 | 66 | } | |
65 | 67 | let gameKey = ((callerAddress + "_") + toString(gameId)) | |
66 | 68 | if (if (((guessEnd + 1) > rand)) | |
67 | 69 | then (rand > (guessStart - 1)) | |
68 | 70 | else false) | |
69 | 71 | then { | |
70 | 72 | let str = ((((((((((toString(WON) + "_WON_") + transactionId) + "_") + gameKey) + "_") + toString(guessStart)) + "-") + toString(guessEnd)) + "_") + toString(rand)) | |
71 | - | let writeLastPlay = WriteSet([DataEntry(lastPlayKey, rand), DataEntry(gameKey, str), DataEntry(gameNumberKey, (gameId + 1))]) | |
73 | + | let payoutRate = (payoutcalc(((guessEnd - guessStart) + 1)) / 100) | |
74 | + | let writeLastPlay = WriteSet([DataEntry(lastPlayKey, rand), DataEntry(gameKey, str), DataEntry(gameNumberKey, (gameId + 1)), DataEntry(testKey, ((toString(payoutRate) + "_") + toString((payment.amount * payoutRate))))]) | |
72 | 75 | ScriptResult(writeLastPlay, TransferSet([ScriptTransfer(i.caller, ((payment.amount * payoutcalc(((guessEnd - guessStart) + 1))) / 100), unit)])) | |
73 | 76 | } | |
74 | 77 | else { | |
75 | 78 | let str = ((((((((((toString(WON) + "_LOSE_") + transactionId) + "_") + gameKey) + "_") + toString(guessStart)) + "-") + toString(guessEnd)) + "_") + toString(rand)) | |
76 | 79 | let writeLastPlay = WriteSet([DataEntry(lastPlayKey, rand), DataEntry(gameKey, str), DataEntry(gameNumberKey, (gameId + 1))]) | |
77 | 80 | ScriptResult(writeLastPlay, TransferSet(nil)) | |
78 | 81 | } | |
79 | 82 | } | |
80 | 83 | } | |
81 | 84 | ||
82 | 85 | ||
83 | 86 | @Callable(i) | |
84 | 87 | func zero2hero (guessStart,guessEnd) = startLotto(i, guessStart, guessEnd) | |
85 | 88 | ||
86 | 89 |
github/deemru/w8io/169f3d6 35.51 ms ◑