tx · FfRPkqTX516SnHptKsFASDTMvzn7nqomQqfbEY8QJmV4 3N7a7sTSKaE621QewSqQcL1mUbknJjnLkZc: -0.01000000 Waves 2021.10.20 17:21 [1754720] smart account 3N7a7sTSKaE621QewSqQcL1mUbknJjnLkZc > SELF 0.00000000 Waves
{ "type": 13, "id": "FfRPkqTX516SnHptKsFASDTMvzn7nqomQqfbEY8QJmV4", "fee": 1000000, "feeAssetId": null, "timestamp": 1634739673205, "version": 2, "chainId": 84, "sender": "3N7a7sTSKaE621QewSqQcL1mUbknJjnLkZc", "senderPublicKey": "6LrPmGtwuADhwHYcxBouLzwfSTGgucbwYG5Pja7LUrcd", "proofs": [ "3PUudR1cUAKjzzDu4Try9QoRwukMq9UFTACMz6GzSDWL1RcumStny17Y3wKETynFLmPJiHuUBLP8PENfpm9irJVE" ], "script": "base64:AAIFAAAAAAAAAAkIAhIAEgMKAQEAAAAMAAAAAA1nYW1lTnVtYmVyS2V5AgAAAAwkR0FNRV9OVU1CRVIAAAAAB3Rlc3RLZXkCAAAABSRURVNUAAAAAAxkZWxheUZvckdhbWUAAAAAAAAAAAIAAAAAC0dhbWVTdGFydGVkAAAAAAAAAAABAAAAAAxHYW1lRmluaXNoZWQAAAAAAAAAAAIBAAAAEGdldEdhbWVTdGF0dXNLZXkAAAACAAAAB2FkZHJlc3MAAAAGZ2FtZUlkCQABLAAAAAIJAAEsAAAAAgkAASwAAAACBQAAAAdhZGRyZXNzAgAAAAFfCQABpAAAAAEFAAAABmdhbWVJZAIAAAAHX3N0YXR1cwEAAAAOZ2V0R2FtZVR4SWRLZXkAAAACAAAAB2FkZHJlc3MAAAAGZ2FtZUlkCQABLAAAAAIJAAEsAAAAAgkAASwAAAACBQAAAAdhZGRyZXNzAgAAAAFfCQABpAAAAAEFAAAABmdhbWVJZAIAAAAFX3R4aWQBAAAAGWdldEdhbWVpbmdGaW5pc2hIZWlnaHRLZXkAAAACAAAAB2FkZHJlc3MAAAAGZ2FtZUlkCQABLAAAAAIJ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FAAAABmhlaWdodAIAAAAnIGJsb2NrcyByZW1haW5pbmcsIGl0IHdpbGwgdGFrZSBhcm91bmQgCQABpAAAAAEJAABlAAAAAgUAAAATZ2FtZWluZ0ZpbmlzaEhlaWdodAUAAAAGaGVpZ2h0AgAAAAggbWludXRlcwQAAAAKcmFuZG9uTmFtZQkBAAAADWdldFJhbmRvbU5hbWUAAAACBQAAAAhnYW1lVHhJZAUAAAATZ2FtZWluZ0ZpbmlzaEhlaWdodAQAAAAFYXNzZXQJAARDAAAABwUAAAAKcmFuZG9uTmFtZQUAAAAKcmFuZG9uTmFtZQAAAAAAAAAAAQAAAAAAAAAAAAcFAAAABHVuaXQFAAAAE2dhbWVpbmdGaW5pc2hIZWlnaHQEAAAAB2Fzc2V0SWQJAAQ4AAAAAQUAAAAFYXNzZXQJAARMAAAAAgkBAAAADEludGVnZXJFbnRyeQAAAAIFAAAAEGdhbWVpbmdTdGF0dXNLZXkFAAAADEdhbWVGaW5pc2hlZAkABEwAAAACCQEAAAALU3RyaW5nRW50cnkAAAACBQAAAAphc3NldElkS2V5CQACWAAAAAEFAAAAB2Fzc2V0SWQJAARMAAAAAgkBAAAAC1N0cmluZ0VudHJ5AAAAAgkAAlgAAAABBQAAAAdhc3NldElkBQAAAAphc3NldElkS2V5CQAETAAAAAIFAAAABWFzc2V0CQAETAAAAAIJAQAAAA5TY3JpcHRUcmFuc2ZlcgAAAAMIBQAAAAFpAAAABmNhbGxlcgAAAAAAAAAAAQUAAAAHYXNzZXRJZAUAAAADbmlsAAAAAGibb4g=", "height": 1754720, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 1fVc1JSYaDGrpccXxJ6bwjtyfMjaxp4uwcy7GfAxzNG Next: AukX1ALS9qG9MWq36y3Ys6cYQGtE1TYtRvgGdtwytqMB Full:
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let gameNumberKey = "$GAME_NUMBER" | |
5 | 5 | ||
6 | 6 | let testKey = "$TEST" | |
7 | 7 | ||
8 | 8 | let delayForGame = 2 | |
9 | 9 | ||
10 | 10 | let GameStarted = 1 | |
11 | 11 | ||
12 | 12 | let GameFinished = 2 | |
13 | 13 | ||
14 | 14 | func getGameStatusKey (address,gameId) = (((address + "_") + toString(gameId)) + "_status") | |
15 | 15 | ||
16 | 16 | ||
17 | 17 | func getGameTxIdKey (address,gameId) = (((address + "_") + toString(gameId)) + "_txid") | |
18 | 18 | ||
19 | 19 | ||
20 | 20 | func getGameingFinishHeightKey (address,gameId) = (((address + "_") + toString(gameId)) + "_fh") | |
21 | 21 | ||
22 | 22 | ||
23 | 23 | func getAssetIdKey (address,gameId) = (((address + "_") + toString(gameId)) + "_di") | |
24 | 24 | ||
25 | 25 | ||
26 | 26 | func tryGetInteger (key) = { | |
27 | 27 | let val = match getInteger(this, key) { | |
28 | 28 | case b: Int => | |
29 | 29 | b | |
30 | 30 | case _ => | |
31 | 31 | 0 | |
32 | 32 | } | |
33 | 33 | val | |
34 | 34 | } | |
35 | 35 | ||
36 | 36 | ||
37 | 37 | func getRandomNumber (variants,txId,gameingFinishHeight,offset) = { | |
38 | 38 | let randomSeedBlock = value(blockInfoByHeight((gameingFinishHeight - 1))) | |
39 | 39 | let randomHash = sha256((txId + value(randomSeedBlock.vrf))) | |
40 | 40 | (toInt(randomHash, (offset * 8)) % variants) | |
41 | 41 | } | |
42 | 42 | ||
43 | 43 | ||
44 | 44 | func getRandomName (txId,gameingFinishHeight) = { | |
45 | 45 | let rand = getRandomNumber(2, txId, gameingFinishHeight, 0) | |
46 | 46 | if ((rand == 0)) | |
47 | 47 | then "type1" | |
48 | 48 | else "type2" | |
49 | 49 | } | |
50 | 50 | ||
51 | 51 | ||
52 | 52 | @Callable(i) | |
53 | 53 | func startAssetGaming () = { | |
54 | 54 | let firstPayment = value(i.payments[0]) | |
55 | 55 | let gameId = tryGetInteger(gameNumberKey) | |
56 | 56 | [IntegerEntry(getGameStatusKey(toString(i.caller), gameId), GameStarted), StringEntry(getGameTxIdKey(toString(i.caller), gameId), toBase58String(i.transactionId)), IntegerEntry(getGameingFinishHeightKey(toString(i.caller), gameId), (height + delayForGame)), IntegerEntry(gameNumberKey, (gameId + 1))] | |
57 | 57 | } | |
58 | 58 | ||
59 | 59 | ||
60 | 60 | ||
61 | 61 | @Callable(i) | |
62 | 62 | func finishAssetGaming (gameId) = { | |
63 | 63 | let gameingStatusKey = getGameStatusKey(toString(i.caller), gameId) | |
64 | 64 | let finishHeightKey = getGameingFinishHeightKey(toString(i.caller), gameId) | |
65 | 65 | let assetIdKey = getAssetIdKey(toString(i.caller), gameId) | |
66 | 66 | let gameTxIdKey = getGameTxIdKey(toString(i.caller), gameId) | |
67 | 67 | let gameingTxStatus = tryGetInteger(gameingStatusKey) | |
68 | 68 | let gameingFinishHeight = getIntegerValue(this, finishHeightKey) | |
69 | 69 | let gameTxId = fromBase58String(getStringValue(this, gameTxIdKey)) | |
70 | 70 | if ((gameingTxStatus == GameFinished)) | |
71 | 71 | then { | |
72 | 72 | let assetId = getStringValue(this, getAssetIdKey(toString(i.caller), gameId)) | |
73 | 73 | throw(("The asset was gamed and claimed already, here is the folowing: " + assetId)) | |
74 | 74 | } | |
75 | 75 | else if ((gameingFinishHeight > height)) | |
76 | 76 | then throw((((("Gaming is not finished yet " + toString((gameingFinishHeight - height))) + " blocks remaining, it will take around ") + toString((gameingFinishHeight - height))) + " minutes")) | |
77 | 77 | else { | |
78 | 78 | let randonName = getRandomName(gameTxId, gameingFinishHeight) | |
79 | 79 | let asset = Issue(randonName, randonName, 1, 0, false, unit, gameingFinishHeight) | |
80 | 80 | let assetId = calculateAssetId(asset) | |
81 | 81 | [IntegerEntry(gameingStatusKey, GameFinished), StringEntry(assetIdKey, toBase58String(assetId)), StringEntry(toBase58String(assetId), assetIdKey), asset, ScriptTransfer(i.caller, 1, assetId)] | |
82 | 82 | } | |
83 | 83 | } | |
84 | 84 | ||
85 | 85 |
github/deemru/w8io/026f985 48.77 ms ◑