tx · FsYgrnS6sjbKscPyfRn19CCw5xnsZhNKUopwczBTh3Jx 3NAjwfxvJp9VShPRRyyqxM7DBur7oCPn79L: -0.00100000 Waves 2022.08.31 18:50 [2208827] smart account 3NAjwfxvJp9VShPRRyyqxM7DBur7oCPn79L > SELF 0.00000000 Waves
{ "type": 13, "id": "FsYgrnS6sjbKscPyfRn19CCw5xnsZhNKUopwczBTh3Jx", "fee": 100000, "feeAssetId": null, "timestamp": 1661961032347, "version": 2, "chainId": 84, "sender": "3NAjwfxvJp9VShPRRyyqxM7DBur7oCPn79L", "senderPublicKey": "3qLStkxzTGZubeF2nmuXT2iopYYNg89sPT7VaNpTqihE", "proofs": [ "4sAqup6jvRxKPqkZ9dHwcH5gGMNxi9TKa5gHHsTo4AuHAKM68Zn22Fku3VzuSF2zSwUpWkpZGn9gTq66PEPTfrTw" ], "script": "base64:AAIFAAAAAAAAAAgIAhIAEgASAAAAAAQAAAAAEGdhbWVDb3VudGVyTGFiZWwCAAAADkdfR0FNRVNDT1VOVEVSAQAAAA9nYW1lUmVzdWx0TGFiZWwAAAABAAAACmdhbWVOdW1iZXIJAAEsAAAAAgkAASwAAAACAgAAAAJHXwkAAaQAAAABBQAAAApnYW1lTnVtYmVyAgAAAAdfUkVTVUxUAQAAAA9nYW1lc0dldENvdW50ZXIAAAAACQAEGgAAAAIFAAAABHRoaXMFAAAAEGdhbWVDb3VudGVyTGFiZWwBAAAADWdhbWVHZXRSZXN1bHQAAAABAAAACmdhbWVOdW1iZXIJAQAAABFAZXh0ck5hdGl2ZSgxMDUzKQAAAAIFAAAABHRoaXMJAQAAAA9nYW1lUmVzdWx0TGFiZWwAAAABBQAAAApnYW1lTnVtYmVyAAAAAwAAAAFpAQAAAAhpbml0R2FtZQAAAAAJAARMAAAAAgkBAAAADEludGVnZXJFbnRyeQAAAAIFAAAAEGdhbWVDb3VudGVyTGFiZWwAAAAAAAAAAAAFAAAAA25pbAAAAAFpAQAAAAlzdGFydEdhbWUAAAAABAAAAAckbWF0Y2gwCQEAAAAPZ2FtZXNHZXRDb3VudGVyAAAAAAMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAADSW50BAAAAAtjdXJyZW50R2FtZQUAAAAHJG1hdGNoMAQAAAAHbmV3R2FtZQkAAGQAAAACBQAAAAtjdXJyZW50R2FtZQAAAAAAAAAAAQkABEwAAAACCQEAAAAMSW50ZWdlckVudHJ5AAAAAgUAAAAQZ2FtZUNvdW50ZXJMYWJlbAUAAAAHbmV3R2FtZQUAAAADbmlsCQAAAgAAAAECAAAANEdhbWUgaGFzIG5vdCBiZWVuIGluaXRpYWxpemVkLCB0b3RhbCBnYW1lcyBub3QgZm91bmQAAAABaQEAAAAHZW5kR2FtZQAAAAAEAAAAByRtYXRjaDAJAQAAAA9nYW1lc0dldENvdW50ZXIAAAAAAwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAANJbnQEAAAAC2N1cnJlbnRHYW1lBQAAAAckbWF0Y2gwCQAETAAAAAIJAQAAAAtTdHJpbmdFbnRyeQAAAAIJAQAAAA9nYW1lUmVzdWx0TGFiZWwAAAABBQAAAAtjdXJyZW50R2FtZQIAAAAFMSwyLDMFAAAAA25pbAkAAAIAAAABAgAAADRHYW1lIGhhcyBub3QgYmVlbiBpbml0aWFsaXplZCwgdG90YWwgZ2FtZXMgbm90IGZvdW5kAAAAAB8cJmY=", "height": 2208827, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: HF3UDWYdhS7UCrJNcWH3ZMBdAse3NXMsNGjgLTQhoVfD Next: C3ZnRi8xem8b1TWeohZQdFo7kHJWmGiKSepLAGcZDD2e Full:
Old | New | Differences | |
---|---|---|---|
1 | - | {-# STDLIB_VERSION | |
1 | + | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 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 | - | } | |
4 | + | let gameCounterLabel = "G_GAMESCOUNTER" | |
5 | + | ||
6 | + | func gameResultLabel (gameNumber) = (("G_" + toString(gameNumber)) + "_RESULT") | |
16 | 7 | ||
17 | 8 | ||
18 | - | func startLotto (inv) = { | |
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 { | |
28 | - | let randhash = randomizer(inv) | |
29 | - | let winTransfer = TransferSet([ScriptTransfer(inv.caller, ((payment.amount * 190) / 100), unit)]) | |
30 | - | let writeLastPlay = WriteSet([DataEntry("lastPlay", randhash)]) | |
31 | - | if ((500 > (toInt(randhash) % 1000))) | |
32 | - | then ScriptResult(writeLastPlay, winTransfer) | |
33 | - | else ScriptResult(writeLastPlay, TransferSet(nil)) | |
34 | - | } | |
35 | - | } | |
9 | + | func gamesGetCounter () = getInteger(this, gameCounterLabel) | |
36 | 10 | ||
37 | 11 | ||
38 | - | @Callable(inv) | |
39 | - | func lotto () = startLotto(inv) | |
12 | + | func gameGetResult (gameNumber) = getStringValue(this, gameResultLabel(gameNumber)) | |
13 | + | ||
14 | + | ||
15 | + | @Callable(i) | |
16 | + | func initGame () = [IntegerEntry(gameCounterLabel, 0)] | |
40 | 17 | ||
41 | 18 | ||
42 | 19 | ||
43 | - | @Callable(inv) | |
44 | - | func default () = startLotto(inv) | |
20 | + | @Callable(i) | |
21 | + | func startGame () = match gamesGetCounter() { | |
22 | + | case currentGame: Int => | |
23 | + | let newGame = (currentGame + 1) | |
24 | + | [IntegerEntry(gameCounterLabel, newGame)] | |
25 | + | case _ => | |
26 | + | throw("Game has not been initialized, total games not found") | |
27 | + | } | |
28 | + | ||
29 | + | ||
30 | + | ||
31 | + | @Callable(i) | |
32 | + | func endGame () = match gamesGetCounter() { | |
33 | + | case currentGame: Int => | |
34 | + | [StringEntry(gameResultLabel(currentGame), "1,2,3")] | |
35 | + | case _ => | |
36 | + | throw("Game has not been initialized, total games not found") | |
37 | + | } | |
45 | 38 | ||
46 | 39 |
github/deemru/w8io/169f3d6 53.48 ms ◑