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