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