tx · 7V2dyp9oNZPAGjFinKLfGDdnXdMa9mEpVE3oD4UuvhAJ 3Mu9qAjmg8fVTxxpwPZnBAH948ujt4m6Xvk: -0.01000000 Waves 2021.10.14 21:15 [1746295] smart account 3Mu9qAjmg8fVTxxpwPZnBAH948ujt4m6Xvk > SELF 0.00000000 Waves
{ "type": 13, "id": "7V2dyp9oNZPAGjFinKLfGDdnXdMa9mEpVE3oD4UuvhAJ", "fee": 1000000, "feeAssetId": null, "timestamp": 1634235404568, "version": 2, "chainId": 84, "sender": "3Mu9qAjmg8fVTxxpwPZnBAH948ujt4m6Xvk", "senderPublicKey": "8v9pmcXqHz9DTc5k1Z8duTYyDwykFxN3EzdZ9WAn3KXJ", "proofs": [ "NLUe6Qb17gxAEuYJZWW8nZN6YksGceuofUetqhh2HAcNeT688ZJue1zDL6REC81dswKzjTyvm3Gt62a1tQN3qcL" ], "script": "base64:AAIDAAAAAAAAAAgIARIECgIBAQAAAAIBAAAACnJhbmRvbWl6ZXIAAAABAAAAA2ludgQAAAAIbGFzdFBsYXkEAAAAByRtYXRjaDAJAAQcAAAAAgUAAAAEdGhpcwIAAAAIbGFzdFBsYXkDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAACkJ5dGVWZWN0b3IEAAAAAXMFAAAAByRtYXRjaDAFAAAAAXMDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAABFVuaXQBAAAADFdhdmVzTG90dG9WMgkAAAIAAAABAgAAAAtNYXRjaCBlcnJvcgQAAAAEcmFuZAkAAMsAAAACCQAAywAAAAIJAADLAAAAAgkAAMsAAAACCQAAywAAAAIFAAAACGxhc3RQbGF5CAUAAAADaW52AAAADXRyYW5zYWN0aW9uSWQIBQAAAANpbnYAAAAPY2FsbGVyUHVibGljS2V5CAUAAAAJbGFzdEJsb2NrAAAAE2dlbmVyYXRpb25TaWduYXR1cmUJAAGaAAAAAQgFAAAACWxhc3RCbG9jawAAAAl0aW1lc3RhbXAJAAGaAAAAAQgFAAAACWxhc3RCb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UmVzdWx0AAAAAgUAAAANd3JpdGVMYXN0UGxheQkBAAAAC1RyYW5zZmVyU2V0AAAAAQkABEwAAAACCQEAAAAOU2NyaXB0VHJhbnNmZXIAAAADCAUAAAADaW52AAAABmNhbGxlcgkAAGkAAAACCQAAaAAAAAIIBQAAAAdwYXltZW50AAAABmFtb3VudAAAAAAAAAAAvgAAAAAAAAAAZAUAAAAEdW5pdAUAAAADbmlsBAAAAA13cml0ZUxhc3RQbGF5CQEAAAAIV3JpdGVTZXQAAAABCQAETAAAAAIJAQAAAAlEYXRhRW50cnkAAAACAgAAAAhsYXN0UGxheQUAAAAEcmFuZAkABEwAAAACCQEAAAAJRGF0YUVudHJ5AAAAAgIAAAAHbGFzdGJldAkAASwAAAACCQABLAAAAAIJAAGkAAAAAQUAAAAKZ3Vlc3NTdGFydAIAAAABXwkAAaQAAAABBQAAAAhndWVzc0VuZAkABEwAAAACCQEAAAAJRGF0YUVudHJ5AAAAAgkAASwAAAACBQAAAA1jYWxsZXJBZGRyZXNzAgAAAAxfcGxheV9hbW91bnQJAABkAAAAAgUAAAAKcGxheUFtb3VudAAAAAAAAAAAAQkABEwAAAACCQEAAAAJRGF0YUVudHJ5AAAAAgkAASwAAAACBQAAAA1jYWxsZXJBZGRyZXNzAgAAAAtfd2luX2Ftb3VudAUAAAAJd2luQW1vdW50BQAAAANuaWwJAQAAAAxTY3JpcHRSZXN1bHQAAAACBQAAAA13cml0ZUxhc3RQbGF5CQEAAAALVHJhbnNmZXJTZXQAAAABBQAAAANuaWwAAAABAAAAA2ludgEAAAAJemVybzJoZXJvAAAAAgAAAApndWVzc1N0YXJ0AAAACGd1ZXNzRW5kCQEAAAAKc3RhcnRMb3R0bwAAAAMFAAAAA2ludgUAAAAKZ3Vlc3NTdGFydAUAAAAIZ3Vlc3NFbmQAAAAA2KdQ1g==", "height": 1746295, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: F5piSAY7RwaFox5DAbd11EdFuxD7AgEQo1N6pxi4Ms3r Next: C5rXC9w7saky9tsPD7H7USp8u1FsNR86eQdUj6qQgn2S Diff:
Old | New | Differences | |
---|---|---|---|
31 | 31 | else if ((guessStart > guessEnd)) | |
32 | 32 | then throw("guessStart and guessEnd Must be in between 0-100") | |
33 | 33 | else { | |
34 | + | let callerAddress = toBase58String(inv.caller.bytes) | |
34 | 35 | let randhash = randomizer(inv) | |
35 | 36 | let rand = (toInt(randhash) % 101) | |
36 | - | let writeLastPlay = WriteSet([DataEntry("lastPlay", rand), DataEntry("lastbet", ((toString(guessStart) + "_") + toString(guessEnd)))]) | |
37 | + | let winAmount = getIntegerValue(this, (toBase58String(inv.caller.bytes) + "_win_amount")) | |
38 | + | let playAmount = getIntegerValue(this, (toBase58String(inv.caller.bytes) + "_play_amount")) | |
37 | 39 | if (if ((guessEnd > rand)) | |
38 | 40 | then (rand > guessStart) | |
39 | 41 | else false) | |
40 | - | then ScriptResult(writeLastPlay, TransferSet([ScriptTransfer(inv.caller, ((payment.amount * 190) / 100), unit)])) | |
41 | - | else ScriptResult(writeLastPlay, TransferSet(nil)) | |
42 | + | then { | |
43 | + | let writeLastPlay = WriteSet([DataEntry("lastPlay", rand), DataEntry("lastbet", ((toString(guessStart) + "_") + toString(guessEnd))), DataEntry((callerAddress + "_play_amount"), (playAmount + 1)), DataEntry((callerAddress + "_win_amount"), (winAmount + 1))]) | |
44 | + | ScriptResult(writeLastPlay, TransferSet([ScriptTransfer(inv.caller, ((payment.amount * 190) / 100), unit)])) | |
45 | + | } | |
46 | + | else { | |
47 | + | let writeLastPlay = WriteSet([DataEntry("lastPlay", rand), DataEntry("lastbet", ((toString(guessStart) + "_") + toString(guessEnd))), DataEntry((callerAddress + "_play_amount"), (playAmount + 1)), DataEntry((callerAddress + "_win_amount"), winAmount)]) | |
48 | + | ScriptResult(writeLastPlay, TransferSet(nil)) | |
49 | + | } | |
42 | 50 | } | |
43 | 51 | } | |
44 | 52 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | func randomizer (inv) = { | |
5 | 5 | let lastPlay = match getBinary(this, "lastPlay") { | |
6 | 6 | case s: ByteVector => | |
7 | 7 | s | |
8 | 8 | case _: Unit => | |
9 | 9 | base58'2ee4oFDYriWJ9EMeR' | |
10 | 10 | case _ => | |
11 | 11 | throw("Match error") | |
12 | 12 | } | |
13 | 13 | let rand = (((((lastPlay + inv.transactionId) + inv.callerPublicKey) + lastBlock.generationSignature) + toBytes(lastBlock.timestamp)) + toBytes(lastBlock.height)) | |
14 | 14 | sha256(rand) | |
15 | 15 | } | |
16 | 16 | ||
17 | 17 | ||
18 | 18 | func startLotto (inv,guessStart,guessEnd) = { | |
19 | 19 | let playLimit = (wavesBalance(this) / 100) | |
20 | 20 | let payment = extract(inv.payment) | |
21 | 21 | if (!(isDefined(inv.payment))) | |
22 | 22 | then throw("Should be with Payment in Waves") | |
23 | 23 | else if (isDefined(payment.assetId)) | |
24 | 24 | then throw("Payment should be in Waves") | |
25 | 25 | else if ((payment.amount > playLimit)) | |
26 | 26 | then throw(("Payment should be less than " + toString(playLimit))) | |
27 | 27 | else if ((0 > guessStart)) | |
28 | 28 | then throw("guessStart and guessEnd Must be in between 0-100") | |
29 | 29 | else if ((guessEnd > 100)) | |
30 | 30 | then throw("guessStart and guessEnd Must be in between 0-100") | |
31 | 31 | else if ((guessStart > guessEnd)) | |
32 | 32 | then throw("guessStart and guessEnd Must be in between 0-100") | |
33 | 33 | else { | |
34 | + | let callerAddress = toBase58String(inv.caller.bytes) | |
34 | 35 | let randhash = randomizer(inv) | |
35 | 36 | let rand = (toInt(randhash) % 101) | |
36 | - | let writeLastPlay = WriteSet([DataEntry("lastPlay", rand), DataEntry("lastbet", ((toString(guessStart) + "_") + toString(guessEnd)))]) | |
37 | + | let winAmount = getIntegerValue(this, (toBase58String(inv.caller.bytes) + "_win_amount")) | |
38 | + | let playAmount = getIntegerValue(this, (toBase58String(inv.caller.bytes) + "_play_amount")) | |
37 | 39 | if (if ((guessEnd > rand)) | |
38 | 40 | then (rand > guessStart) | |
39 | 41 | else false) | |
40 | - | then ScriptResult(writeLastPlay, TransferSet([ScriptTransfer(inv.caller, ((payment.amount * 190) / 100), unit)])) | |
41 | - | else ScriptResult(writeLastPlay, TransferSet(nil)) | |
42 | + | then { | |
43 | + | let writeLastPlay = WriteSet([DataEntry("lastPlay", rand), DataEntry("lastbet", ((toString(guessStart) + "_") + toString(guessEnd))), DataEntry((callerAddress + "_play_amount"), (playAmount + 1)), DataEntry((callerAddress + "_win_amount"), (winAmount + 1))]) | |
44 | + | ScriptResult(writeLastPlay, TransferSet([ScriptTransfer(inv.caller, ((payment.amount * 190) / 100), unit)])) | |
45 | + | } | |
46 | + | else { | |
47 | + | let writeLastPlay = WriteSet([DataEntry("lastPlay", rand), DataEntry("lastbet", ((toString(guessStart) + "_") + toString(guessEnd))), DataEntry((callerAddress + "_play_amount"), (playAmount + 1)), DataEntry((callerAddress + "_win_amount"), winAmount)]) | |
48 | + | ScriptResult(writeLastPlay, TransferSet(nil)) | |
49 | + | } | |
42 | 50 | } | |
43 | 51 | } | |
44 | 52 | ||
45 | 53 | ||
46 | 54 | @Callable(inv) | |
47 | 55 | func zero2hero (guessStart,guessEnd) = startLotto(inv, guessStart, guessEnd) | |
48 | 56 | ||
49 | 57 |
github/deemru/w8io/169f3d6 29.36 ms ◑