tx · DGn5BtdPMuxHhrXBcKtQQ8BVQUDBabbhwB6oJnbuioQJ 3NBiXxLpuHVS2dGSaLvyPfCQYMPRKCtGCVg: -0.01400000 Waves 2019.07.09 22:46 [578542] smart account 3NBiXxLpuHVS2dGSaLvyPfCQYMPRKCtGCVg > SELF 0.00000000 Waves
{ "type": 13, "id": "DGn5BtdPMuxHhrXBcKtQQ8BVQUDBabbhwB6oJnbuioQJ", "fee": 1400000, "feeAssetId": null, "timestamp": 1562701649586, "version": 1, "sender": "3NBiXxLpuHVS2dGSaLvyPfCQYMPRKCtGCVg", "senderPublicKey": "H2yzJU1BtKf9NAhJSK6nCVgmFdaRaFBs5y3zgajHTLGs", "proofs": [ "3j5CWs4Nmdy2x2mGqHSavSZ2h8wznHGCLYdUiDAAudVEv8wZRfZzpxXbjQwDpv9GP85JrdnCd4i61ncvQAZBRxhV" ], "script": "base64:AAIDAAAAAAAAAAAAAAAKAAAAAA5hZG1pblB1YmxpY0tleQEAAAAgoPq5TrIPqNMyX9LJ5ea1kHoixxLdZLkjdZ9lUlSz41QAAAAABXdjdElkAQAAACBAkwcahwxqDOVmEdNdlcYsRPoEBwsu3SMjVjLFv3jP4gAAAAAId3ZzUHJpY2UAAAAAAAX14QAAAAAACHdjdFByaWNlAAAAAAAAAABkAAAAAAhsYXN0Q2VsbAAAAAAAAAAAYwAAAAAIcm91bmRLZXkCAAAABXJvdW5kAAAAAAhjZWxsc0tleQIAAAAFY2VsbHMAAAAACmxhc3RXaW5LZXkCAAAAB2xhc3RXaW4AAAAADWxhc3RXaW5XY3RLZXkCAAAAC2xhc3RXaW5fd2N0AAAAAA1sYXN0V2luV3ZzS2V5AgAAAAtsYXN0V2luX3d2cwAAAAEAAAABaQEAAAADYnV5AAAAAQAAAARjZWxsBAAAAAVyb3VuZAkBAAAAB2V4dHJhY3QAAAABCQAEGgAAAAIFAAAABHRoaXMFAAAACHJvdW5kS2V5BAAAAAVjZWxscwkBAAAAB2V4dHJhY3QAAAABCQAEGg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BZGRyZXNzBQAAAA13Y3RBZG1pblNoYXJlBQAAAAV3Y3RJZAUAAAADbmlsCQEAAAAIV3JpdGVTZXQAAAABCQAETAAAAAIJAQAAAAlEYXRhRW50cnkAAAACCQABpAAAAAEFAAAABGNlbGwJAAEsAAAAAgkAASwAAAACCQAEJQAAAAEIBQAAAAFpAAAABmNhbGxlcgIAAAABXwkAAaQAAAABBQAAAAVyb3VuZAkABEwAAAACCQEAAAAJRGF0YUVudHJ5AAAAAgUAAAAIY2VsbHNLZXkJAABkAAAAAgUAAAAFY2VsbHMAAAAAAAAAAAEFAAAAA25pbAAAAAEAAAACdHgBAAAABnZlcmlmeQAAAAAEAAAAByRtYXRjaDAFAAAAAnR4CQAB9AAAAAMIBQAAAAJ0eAAAAAlib2R5Qnl0ZXMJAAGRAAAAAggFAAAAAnR4AAAABnByb29mcwAAAAAAAAAAAAgFAAAAAnR4AAAAD3NlbmRlclB1YmxpY0tleTFEEw0=", "chainId": 84, "height": 578542, "spentComplexity": 0 } View: original | compacted Prev: 67ujRgftPDhNHFEp1W6b7v4gzCp3AwTZDe46zEHAGyt2 Next: 2wEC6v8EayocEeQyKWa4LKHVHjxfdvv7zquh7BSR1cwi Diff:
Old | New | Differences | |
---|---|---|---|
11 | 11 | ||
12 | 12 | let lastCell = 99 | |
13 | 13 | ||
14 | - | let addressLength = 35 | |
15 | - | ||
16 | 14 | let roundKey = "round" | |
17 | 15 | ||
18 | 16 | let cellsKey = "cells" | |
19 | 17 | ||
20 | 18 | let lastWinKey = "lastWin" | |
21 | 19 | ||
22 | - | @Callable(i) | |
23 | - | func test () = { | |
24 | - | let winCell = (toInt(lastBlock.generationSignature) % 10) | |
25 | - | throw(((((toBase58String(lastBlock.generationSignature) + ", ") + toBase64String(lastBlock.generationSignature)) + ", ") + toString(winCell))) | |
26 | - | } | |
20 | + | let lastWinWctKey = "lastWin_wct" | |
27 | 21 | ||
28 | - | ||
22 | + | let lastWinWvsKey = "lastWin_wvs" | |
29 | 23 | ||
30 | 24 | @Callable(i) | |
31 | 25 | func buy (cell) = { | |
34 | 28 | if (if ((0 > cell)) | |
35 | 29 | then true | |
36 | 30 | else (cell > lastCell)) | |
37 | - | then throw(" | |
31 | + | then throw("Invalid number") | |
38 | 32 | else { | |
39 | 33 | let pmt = valueOrErrorMessage(i.payment, "Where is payment?") | |
40 | 34 | let wvs = !(isDefined(pmt.assetId)) | |
50 | 44 | else if (wvs) | |
51 | 45 | then (pmt.amount != wvsPrice) | |
52 | 46 | else false) | |
53 | - | then throw(" | |
47 | + | then throw("Price is 1 WCT or 1 WAVES") | |
54 | 48 | else { | |
55 | 49 | let cellData = getString(this, toString(cell)) | |
56 | 50 | let bought = if (isDefined(cellData)) | |
62 | 56 | } | |
63 | 57 | else false | |
64 | 58 | if (bought) | |
65 | - | then throw(" | |
59 | + | then throw("Already bought") | |
66 | 60 | else { | |
67 | 61 | let last = (cells == lastCell) | |
68 | 62 | if (last) | |
85 | 79 | let winAddress = if ((winCell == cell)) | |
86 | 80 | then i.caller | |
87 | 81 | else extract(addressFromString(split(winData, "_")[0])) | |
88 | - | ScriptResult(WriteSet([DataEntry(toString(cell), ((toString(i.caller) + "_") + toString(round))), DataEntry(cellsKey, 0), DataEntry(roundKey, (round + 1)), DataEntry(lastWinKey, ((toString(winCell) + "_") + toString(winAddress)))]), TransferSet([ScriptTransfer(winAddress, wvsWinShare, unit), ScriptTransfer(adminAddress, wvsAdminShare, unit), ScriptTransfer(winAddress, wctWinShare, wctId), ScriptTransfer(adminAddress, wctAdminShare, wctId)])) | |
82 | + | ScriptResult(WriteSet([DataEntry(toString(cell), ((toString(i.caller) + "_") + toString(round))), DataEntry(cellsKey, 0), DataEntry(roundKey, (round + 1)), DataEntry(lastWinKey, ((toString(winCell) + "_") + toString(winAddress))), DataEntry(lastWinWvsKey, wvsAmount), DataEntry(lastWinWctKey, wctAmount)]), TransferSet([ScriptTransfer(winAddress, wvsWinShare, unit), ScriptTransfer(adminAddress, wvsAdminShare, unit), ScriptTransfer(winAddress, wctWinShare, wctId), ScriptTransfer(adminAddress, wctAdminShare, wctId)])) | |
89 | 83 | } | |
90 | 84 | else WriteSet([DataEntry(toString(cell), ((toString(i.caller) + "_") + toString(round))), DataEntry(cellsKey, (cells + 1))]) | |
91 | 85 | } |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let adminPublicKey = base58'BqPySUvbKdRTRZ33nGTtrQRdus5qwhnQkqZ7G9iNcDto' | |
5 | 5 | ||
6 | 6 | let wctId = base58'5M58Edq3qciFLWMFS9kLLKfFQoENxokdi2hdE3ju4hrq' | |
7 | 7 | ||
8 | 8 | let wvsPrice = 100000000 | |
9 | 9 | ||
10 | 10 | let wctPrice = 100 | |
11 | 11 | ||
12 | 12 | let lastCell = 99 | |
13 | 13 | ||
14 | - | let addressLength = 35 | |
15 | - | ||
16 | 14 | let roundKey = "round" | |
17 | 15 | ||
18 | 16 | let cellsKey = "cells" | |
19 | 17 | ||
20 | 18 | let lastWinKey = "lastWin" | |
21 | 19 | ||
22 | - | @Callable(i) | |
23 | - | func test () = { | |
24 | - | let winCell = (toInt(lastBlock.generationSignature) % 10) | |
25 | - | throw(((((toBase58String(lastBlock.generationSignature) + ", ") + toBase64String(lastBlock.generationSignature)) + ", ") + toString(winCell))) | |
26 | - | } | |
20 | + | let lastWinWctKey = "lastWin_wct" | |
27 | 21 | ||
28 | - | ||
22 | + | let lastWinWvsKey = "lastWin_wvs" | |
29 | 23 | ||
30 | 24 | @Callable(i) | |
31 | 25 | func buy (cell) = { | |
32 | 26 | let round = extract(getInteger(this, roundKey)) | |
33 | 27 | let cells = extract(getInteger(this, cellsKey)) | |
34 | 28 | if (if ((0 > cell)) | |
35 | 29 | then true | |
36 | 30 | else (cell > lastCell)) | |
37 | - | then throw(" | |
31 | + | then throw("Invalid number") | |
38 | 32 | else { | |
39 | 33 | let pmt = valueOrErrorMessage(i.payment, "Where is payment?") | |
40 | 34 | let wvs = !(isDefined(pmt.assetId)) | |
41 | 35 | let wct = (pmt.assetId == wctId) | |
42 | 36 | if (if (if (if (!(wct)) | |
43 | 37 | then !(wvs) | |
44 | 38 | else false) | |
45 | 39 | then true | |
46 | 40 | else if (wct) | |
47 | 41 | then (pmt.amount != wctPrice) | |
48 | 42 | else false) | |
49 | 43 | then true | |
50 | 44 | else if (wvs) | |
51 | 45 | then (pmt.amount != wvsPrice) | |
52 | 46 | else false) | |
53 | - | then throw(" | |
47 | + | then throw("Price is 1 WCT or 1 WAVES") | |
54 | 48 | else { | |
55 | 49 | let cellData = getString(this, toString(cell)) | |
56 | 50 | let bought = if (isDefined(cellData)) | |
57 | 51 | then { | |
58 | 52 | let cellRound = split(extract(cellData), "_")[1] | |
59 | 53 | if ((cellRound == toString(round))) | |
60 | 54 | then true | |
61 | 55 | else false | |
62 | 56 | } | |
63 | 57 | else false | |
64 | 58 | if (bought) | |
65 | - | then throw(" | |
59 | + | then throw("Already bought") | |
66 | 60 | else { | |
67 | 61 | let last = (cells == lastCell) | |
68 | 62 | if (last) | |
69 | 63 | then { | |
70 | 64 | let wctFlag = if (wct) | |
71 | 65 | then 1 | |
72 | 66 | else 0 | |
73 | 67 | let wvsFlag = if (wvs) | |
74 | 68 | then 1 | |
75 | 69 | else 0 | |
76 | 70 | let wctAmount = (assetBalance(this, wctId) + (pmt.amount * wctFlag)) | |
77 | 71 | let wvsAmount = (wavesBalance(this) + (pmt.amount * wvsFlag)) | |
78 | 72 | let wvsAdminShare = (wvsAmount / 10) | |
79 | 73 | let wvsWinShare = (wvsAmount - wvsAdminShare) | |
80 | 74 | let wctAdminShare = (wctAmount / 10) | |
81 | 75 | let wctWinShare = (wctAmount - wctAdminShare) | |
82 | 76 | let adminAddress = addressFromPublicKey(adminPublicKey) | |
83 | 77 | let winCell = (toInt(lastBlock.generationSignature) % (lastCell + 1)) | |
84 | 78 | let winData = extract(getString(this, toString(winCell))) | |
85 | 79 | let winAddress = if ((winCell == cell)) | |
86 | 80 | then i.caller | |
87 | 81 | else extract(addressFromString(split(winData, "_")[0])) | |
88 | - | ScriptResult(WriteSet([DataEntry(toString(cell), ((toString(i.caller) + "_") + toString(round))), DataEntry(cellsKey, 0), DataEntry(roundKey, (round + 1)), DataEntry(lastWinKey, ((toString(winCell) + "_") + toString(winAddress)))]), TransferSet([ScriptTransfer(winAddress, wvsWinShare, unit), ScriptTransfer(adminAddress, wvsAdminShare, unit), ScriptTransfer(winAddress, wctWinShare, wctId), ScriptTransfer(adminAddress, wctAdminShare, wctId)])) | |
82 | + | ScriptResult(WriteSet([DataEntry(toString(cell), ((toString(i.caller) + "_") + toString(round))), DataEntry(cellsKey, 0), DataEntry(roundKey, (round + 1)), DataEntry(lastWinKey, ((toString(winCell) + "_") + toString(winAddress))), DataEntry(lastWinWvsKey, wvsAmount), DataEntry(lastWinWctKey, wctAmount)]), TransferSet([ScriptTransfer(winAddress, wvsWinShare, unit), ScriptTransfer(adminAddress, wvsAdminShare, unit), ScriptTransfer(winAddress, wctWinShare, wctId), ScriptTransfer(adminAddress, wctAdminShare, wctId)])) | |
89 | 83 | } | |
90 | 84 | else WriteSet([DataEntry(toString(cell), ((toString(i.caller) + "_") + toString(round))), DataEntry(cellsKey, (cells + 1))]) | |
91 | 85 | } | |
92 | 86 | } | |
93 | 87 | } | |
94 | 88 | } | |
95 | 89 | ||
96 | 90 | ||
97 | 91 | @Verifier(tx) | |
98 | 92 | func verify () = match tx { | |
99 | 93 | case _ => | |
100 | 94 | sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
101 | 95 | } | |
102 | 96 |
github/deemru/w8io/169f3d6 42.12 ms ◑