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