tx · 73U2qiMkfV7bDrNjSsV2dS4ju3uk3ijZjmcYqbWv3UoG 3N7oes1Mab9zmCWuTdXSnKvkN6Y2pJc1dDe: -0.05000000 Waves 2021.04.16 13:13 [1484867] smart account 3N7oes1Mab9zmCWuTdXSnKvkN6Y2pJc1dDe > SELF 0.00000000 Waves
{ "type": 13, "id": "73U2qiMkfV7bDrNjSsV2dS4ju3uk3ijZjmcYqbWv3UoG", "fee": 5000000, "feeAssetId": null, "timestamp": 1618568020889, "version": 2, "chainId": 84, "sender": "3N7oes1Mab9zmCWuTdXSnKvkN6Y2pJc1dDe", "senderPublicKey": "4MMreyp5fK9PfGwiJTaZTXuPjY9Tj3qHt6pHiGJ8uyXJ", "proofs": [ "4h1Mpue8dtfHv1xGRjq71ngMYewrUFmzBTtncUYLm8vyT1HcU32hReN4EzP8hdoVGvGV4HLWvn5MFEX6pYNNrjhv" ], "script": "base64:AAIDAAAAAAAAAAoIARIAEgQKAggIAAAABwAAAAAJUlNBUFVCTElDCQACWwAAAAECAAABj2Jhc2U2NDpNSUlCSWpBTkJna3Foa2lHOXcwQkFRRUZBQU9DQVE4QU1JSUJDZ0tDQVFFQXhYSXVxbWZ4RE5rVjVKbzlheG51RnBBaktIMmN5R3FRY2tqd0JwRnoydFlKWE4vTXNEdVJraC90WkJ0bm5RVEczRUsrWGJ3V0ZjWUhzNEJvSHpoYUtGb2c0eEtyVDRudFViY1RFMkFxUHNoWGlPc0llSnZlR2RJVDdoL0gySmRBVUZNdXIzdGxQVlhBMWZScGxWMVc2NTFPSWFFOEYrQ252QjlZV2NBVEJxcVVLM1lZaHc3VmErRG96dHZKd3ZOcXVjb1ltZG5uaTZ6NXYwckNsSm1pZk9IQlhGczBVUW83UnFqV2gzTDkrZkdqT2pxUUxzQ2VtYklRYmwvU0lxUm1YMUhZZW1CMUdRQlNsM3U1TGlNOU43aEdTT3V2N01GSWYyZXpReWFnU2JxK3YvM3dBRHZQL1d3K3FTbHhpa0pOYmp4WHBMYUxMSlh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gAAAAVyYW5kOgkAAaQAAAABBQAAAARyYW5kAgAAAAVyaXNrOgkAAaQAAAABBQAAAARyaXNrAgAAAAVsb3N0OgkAAaQAAAABBQAAAAZhbW91bnQFAAAAA25pbAMJAABmAAAAAgAAAAAAAAAAMAUAAAAEcmFuZAkBAAAACFdyaXRlU2V0AAAAAQkABEwAAAACCQEAAAAJRGF0YUVudHJ5AAAAAgkAASwAAAACCQABLAAAAAIFAAAADWNhbGxlckFkZHJlc3MCAAAAB3VzZXJpZDoFAAAABnVzZXJpZAkAASwAAAACCQABLAAAAAIJAAEsAAAAAgkAASwAAAACCQABLAAAAAICAAAABXJhbmQ6CQABpAAAAAEFAAAABHJhbmQCAAAABXJpc2s6CQABpAAAAAEFAAAABHJpc2sCAAAABHdvbjoJAAGkAAAAAQkAAGgAAAACBQAAAAZhbW91bnQAAAAAAAAAAAMFAAAAA25pbAkBAAAACFdyaXRlU2V0AAAAAQkABEwAAAACCQEAAAAJRGF0YUVudHJ5AAAAAgkAASwAAAACCQABLAAAAAIFAAAADWNhbGxlckFkZHJlc3MCAAAAB3VzZXJpZDoFAAAABnVzZXJpZAkAASwAAAACCQABLAAAAAIJAAEsAAAAAgkAASwAAAACCQABLAAAAAICAAAABXJhbmQ6CQABpAAAAAEFAAAABHJhbmQCAAAABXJpc2s6CQABpAAAAAEFAAAABHJpc2sCAAAABWxvc3Q6CQABpAAAAAEFAAAABmFtb3VudAUAAAADbmlsAAAAABTmZEk=", "height": 1484867, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: HdRwzetE36Xhezyq148z5XnGVnFMSPJZCEX6iFHJr2M6 Next: 3QWrXjE5NFXrfh7KJEVDw5TtaU9VpyakapPTPVJ6eW5c Diff:
Old | New | Differences | |
---|---|---|---|
39 | 39 | func init () = { | |
40 | 40 | let callerAddress = toBase58String(i.caller.bytes) | |
41 | 41 | let gameId = toBase58String(i.transactionId) | |
42 | - | WriteSet([DataEntry(((callerAddress + "_") + GAMESCOUNTERKEY), gameId)]) | |
42 | + | let newGameNum = IncrementGameNum() | |
43 | + | WriteSet([DataEntry(((callerAddress + "_") + toString(newGameNum)), gameId)]) | |
43 | 44 | } | |
44 | 45 | ||
45 | 46 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let RSAPUBLIC = fromBase64String("base64:MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAxXIuqmfxDNkV5Jo9axnuFpAjKH2cyGqQckjwBpFz2tYJXN/MsDuRkh/tZBtnnQTG3EK+XbwWFcYHs4BoHzhaKFog4xKrT4ntUbcTE2AqPshXiOsIeJveGdIT7h/H2JdAUFMur3tlPVXA1fRplV1W651OIaE8F+CnvB9YWcATBqqUK3YYhw7Va+DoztvJwvNqucoYmdnni6z5v0rClJmifOHBXFs0UQo7RqjWh3L9+fGjOjqQLsCembIQbl/SIqRmX1HYemB1GQBSl3u5LiM9N7hGSOuv7MFIf2ezQyagSbq+v/3wADvP/Ww+qSlxikJNbjxXpLaLLJXzTyeJD+kt4wIDAQAB") | |
5 | 5 | ||
6 | 6 | let GAMESCOUNTERKEY = "$GAME_NUM" | |
7 | 7 | ||
8 | 8 | let STATESUBMITTED = "SUBMITTED" | |
9 | 9 | ||
10 | 10 | let STATEWON = "WON" | |
11 | 11 | ||
12 | 12 | let STATELOST = "LOST" | |
13 | 13 | ||
14 | 14 | func IncrementGameNum () = { | |
15 | 15 | let gameNum = match getInteger(this, GAMESCOUNTERKEY) { | |
16 | 16 | case num: Int => | |
17 | 17 | num | |
18 | 18 | case _ => | |
19 | 19 | 0 | |
20 | 20 | } | |
21 | 21 | (gameNum + 1) | |
22 | 22 | } | |
23 | 23 | ||
24 | 24 | ||
25 | 25 | func GenerateRandInt (gameId,rsaSign) = { | |
26 | 26 | let rsaSigValid = rsaVerify(SHA256, toBytes(gameId), rsaSign, RSAPUBLIC) | |
27 | 27 | if (rsaSigValid) | |
28 | 28 | then { | |
29 | 29 | let rand = (toInt(sha256(rsaSign)) % 150) | |
30 | 30 | if ((0 > rand)) | |
31 | 31 | then ((-1 * rand) + 1) | |
32 | 32 | else (rand + 1) | |
33 | 33 | } | |
34 | 34 | else throw("Invalid RSA signature") | |
35 | 35 | } | |
36 | 36 | ||
37 | 37 | ||
38 | 38 | @Callable(i) | |
39 | 39 | func init () = { | |
40 | 40 | let callerAddress = toBase58String(i.caller.bytes) | |
41 | 41 | let gameId = toBase58String(i.transactionId) | |
42 | - | WriteSet([DataEntry(((callerAddress + "_") + GAMESCOUNTERKEY), gameId)]) | |
42 | + | let newGameNum = IncrementGameNum() | |
43 | + | WriteSet([DataEntry(((callerAddress + "_") + toString(newGameNum)), gameId)]) | |
43 | 44 | } | |
44 | 45 | ||
45 | 46 | ||
46 | 47 | ||
47 | 48 | @Callable(i) | |
48 | 49 | func game (gameId,rsaSignr) = { | |
49 | 50 | let rsaSign = fromBase64String(rsaSignr) | |
50 | 51 | let callerAddress = toBase58String(i.caller.bytes) | |
51 | 52 | let rand = GenerateRandInt(gameId, rsaSign) | |
52 | 53 | let amount = 10000 | |
53 | 54 | let userid = "123456" | |
54 | 55 | let risk = 3 | |
55 | 56 | if ((risk == 2)) | |
56 | 57 | then if ((73 > rand)) | |
57 | 58 | then WriteSet([DataEntry(((callerAddress + "userid:") + userid), ((((("rand:" + toString(rand)) + "risk:") + toString(risk)) + "won:") + toString((amount * 2))))]) | |
58 | 59 | else WriteSet([DataEntry(((callerAddress + "userid:") + userid), ((((("rand:" + toString(rand)) + "risk:") + toString(risk)) + "lost:") + toString(amount)))]) | |
59 | 60 | else if ((48 > rand)) | |
60 | 61 | then WriteSet([DataEntry(((callerAddress + "userid:") + userid), ((((("rand:" + toString(rand)) + "risk:") + toString(risk)) + "won:") + toString((amount * 3))))]) | |
61 | 62 | else WriteSet([DataEntry(((callerAddress + "userid:") + userid), ((((("rand:" + toString(rand)) + "risk:") + toString(risk)) + "lost:") + toString(amount)))]) | |
62 | 63 | } | |
63 | 64 | ||
64 | 65 |
github/deemru/w8io/026f985 27.15 ms ◑