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