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