tx · AFpQLnwLh9qt7Kg9pKu8Hvu7qcWJcaxyLK7epwMb4dUm 3MvcThc2oaRXWLgYxiGhr1jnd4gK5CXBGhE: -0.01400000 Waves 2019.08.04 00:13 [615219] smart account 3MvcThc2oaRXWLgYxiGhr1jnd4gK5CXBGhE > SELF 0.00000000 Waves
{ "type": 13, "id": "AFpQLnwLh9qt7Kg9pKu8Hvu7qcWJcaxyLK7epwMb4dUm", "fee": 1400000, "feeAssetId": null, "timestamp": 1564866853677, "version": 1, "sender": "3MvcThc2oaRXWLgYxiGhr1jnd4gK5CXBGhE", "senderPublicKey": "Czmo9kTsBGhSfVm9DSRTG8uoiyrcMQB63vabDwPobjqx", "proofs": [ "4yKTTHTSNULcGQri5CM63MhSFwiiVJgtmUFyjWiizQRoh4U98Pfaa4YK8z9LcLvFgj3N4t1GmBXRyyMY7U2HCwNK" ], "script": "base64:AAIDAAAAAAAAAAAAAAACAAAAAAhsYXN0Q2VsbAAAAAAAAAAABAAAAAAIY2VsbHNLZXkCAAAABWNlbGxzAAAAAgAAAAFpAQAAAAZjcmVhdGUAAAAEAAAABG5hbWUAAAAEZGVzYwAAAAt0aWNrZXRQcmljZQAAAAt0aWNrZXRBc3NldAQAAAAHYXNzZXRJZAMJAQAAAAIhPQAAAAIFAAAAC3RpY2tldEFzc2V0AgAAAAVXQVZFUwQAAAAFYUluZm8JAQAAABN2YWx1ZU9yRXJyb3JNZXNzYWdlAAAAAgkAA+wAAAABCQACWQAAAAEFAAAAC3RpY2tldEFzc2V0AgAAACNUaGVyZSBpcyBubyBhc3NldCB3aXRoIHNwZWNpZmllZCBpZAUAAAALdGlja2V0QXNzZXQCAAAABVdBVkVTBAAAAANwbXQJAQAAABN2YWx1ZU9yRXJyb3JNZXNzYWdlAAAAAggFAAAAAWkAAAAHcGF5bWVudAIAAAAPV2hlcmUgaXMgcHJpemU/BAAAAApwcml6ZUFzc2V0AwkBAAAACWlzRGVmaW5lZAAAAAEIBQAAAANwbXQAAAAHYXNzZXR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If", "chainId": 84, "height": 615219, "spentComplexity": 0 } View: original | compacted Prev: 62oTz3PbFunapYmg4fQ17uJEqh5MyUHUJcHefuKqSSYA Next: DbhKDdWqjqjehsxzoiPd11HtjvM9So4LmqTkbM5tNoQn Diff:
Old | New | Differences | |
---|---|---|---|
56 | 56 | then throw("Already bought") | |
57 | 57 | else { | |
58 | 58 | let last = (cells == lastCell) | |
59 | - | let balance = valueOrErrorMessage(getInteger(this, (id + "_balance")), "Balance error") | |
59 | + | let balance = (valueOrErrorMessage(getInteger(this, (id + "_balance")), "Balance error") + pmt.amount) | |
60 | 60 | if (last) | |
61 | 61 | then { | |
62 | 62 | let creator = addressFromStringValue(valueOrErrorMessage(getString(this, (id + "_creator")), "Creator error")) | |
75 | 75 | then ScriptTransfer(creator, balance, unit) | |
76 | 76 | else ScriptTransfer(creator, balance, fromBase58String(ticketAsset))])) | |
77 | 77 | } | |
78 | - | else WriteSet([DataEntry(((id + "_cell:") + toString(cell)), toString(i.caller)), DataEntry((id + "_cells"), (cells + 1)), DataEntry((id + "_balance"), | |
78 | + | else WriteSet([DataEntry(((id + "_cell:") + toString(cell)), toString(i.caller)), DataEntry((id + "_cells"), (cells + 1)), DataEntry((id + "_balance"), balance)]) | |
79 | 79 | } | |
80 | 80 | } | |
81 | 81 | } |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let lastCell = 4 | |
5 | 5 | ||
6 | 6 | let cellsKey = "cells" | |
7 | 7 | ||
8 | 8 | @Callable(i) | |
9 | 9 | func create (name,desc,ticketPrice,ticketAsset) = { | |
10 | 10 | let assetId = if ((ticketAsset != "WAVES")) | |
11 | 11 | then { | |
12 | 12 | let aInfo = valueOrErrorMessage(assetInfo(fromBase58String(ticketAsset)), "There is no asset with specified id") | |
13 | 13 | ticketAsset | |
14 | 14 | } | |
15 | 15 | else "WAVES" | |
16 | 16 | let pmt = valueOrErrorMessage(i.payment, "Where is prize?") | |
17 | 17 | let prizeAsset = if (isDefined(pmt.assetId)) | |
18 | 18 | then toBase58String(value(pmt.assetId)) | |
19 | 19 | else "WAVES" | |
20 | 20 | if (if (if ((name == "")) | |
21 | 21 | then true | |
22 | 22 | else (desc == "")) | |
23 | 23 | then true | |
24 | 24 | else (0 > ticketPrice)) | |
25 | 25 | then throw("Invalid name, description or ticket price") | |
26 | 26 | else { | |
27 | 27 | let lotteryId = toBase58String(i.transactionId) | |
28 | 28 | WriteSet([DataEntry((lotteryId + "_name"), name), DataEntry((lotteryId + "_desc"), desc), DataEntry((lotteryId + "_ticket_price"), ticketPrice), DataEntry((lotteryId + "_ticket_asset"), assetId), DataEntry((lotteryId + "_prize_amount"), pmt.amount), DataEntry((lotteryId + "_prize_asset"), prizeAsset), DataEntry((lotteryId + "_creator"), toBase58String(i.caller.bytes)), DataEntry((lotteryId + "_cells"), 0), DataEntry((lotteryId + "_status"), true), DataEntry((lotteryId + "_balance"), 0)]) | |
29 | 29 | } | |
30 | 30 | } | |
31 | 31 | ||
32 | 32 | ||
33 | 33 | ||
34 | 34 | @Callable(i) | |
35 | 35 | func buy (id,cell) = { | |
36 | 36 | let cells = valueOrErrorMessage(getInteger(this, (id + "_cells")), "No lottery with specified id") | |
37 | 37 | let status = getBooleanValue(this, (id + "_status")) | |
38 | 38 | if (!(status)) | |
39 | 39 | then throw("Specified lottery is over") | |
40 | 40 | else if (if ((0 > cell)) | |
41 | 41 | then true | |
42 | 42 | else (cell > lastCell)) | |
43 | 43 | then throw("Invalid number") | |
44 | 44 | else { | |
45 | 45 | let ticketPrice = valueOrErrorMessage(getInteger(this, (id + "_ticket_price")), "Ticket price error") | |
46 | 46 | let ticketAsset = valueOrErrorMessage(getString(this, (id + "_ticket_asset")), "Ticket asset error") | |
47 | 47 | let pmt = valueOrErrorMessage(i.payment, "Where is payment?") | |
48 | 48 | let assetId = if (isDefined(pmt.assetId)) | |
49 | 49 | then toBase58String(value(pmt.assetId)) | |
50 | 50 | else "WAVES" | |
51 | 51 | if (if ((assetId != ticketAsset)) | |
52 | 52 | then true | |
53 | 53 | else (pmt.amount != ticketPrice)) | |
54 | 54 | then throw("Invalid payment") | |
55 | 55 | else if (isDefined(getString(this, toString(cell)))) | |
56 | 56 | then throw("Already bought") | |
57 | 57 | else { | |
58 | 58 | let last = (cells == lastCell) | |
59 | - | let balance = valueOrErrorMessage(getInteger(this, (id + "_balance")), "Balance error") | |
59 | + | let balance = (valueOrErrorMessage(getInteger(this, (id + "_balance")), "Balance error") + pmt.amount) | |
60 | 60 | if (last) | |
61 | 61 | then { | |
62 | 62 | let creator = addressFromStringValue(valueOrErrorMessage(getString(this, (id + "_creator")), "Creator error")) | |
63 | 63 | let prizeAmount = valueOrErrorMessage(getInteger(this, (id + "_prize_amount")), "Prize amount error") | |
64 | 64 | let prizeAsset = valueOrErrorMessage(getString(this, (id + "_prize_asset")), "Prize asset error") | |
65 | 65 | let winCell = (toInt(lastBlock.generationSignature) % (lastCell + 1)) | |
66 | 66 | let winAddress = if ((winCell == cell)) | |
67 | 67 | then i.caller | |
68 | 68 | else { | |
69 | 69 | let winData = valueOrErrorMessage(getString(this, ((id + "_cell:") + toString(winCell))), "Win data error") | |
70 | 70 | value(addressFromString(winData)) | |
71 | 71 | } | |
72 | 72 | ScriptResult(WriteSet([DataEntry((id + "_status"), false), DataEntry((id + "_balance"), 0), DataEntry((id + "_cells"), (cells + 1)), DataEntry(((id + "_cell:") + toString(cell)), toString(i.caller)), DataEntry((id + "_winner:"), toBase58String(winAddress.bytes))]), TransferSet([if ((prizeAsset == "WAVES")) | |
73 | 73 | then ScriptTransfer(winAddress, prizeAmount, unit) | |
74 | 74 | else ScriptTransfer(winAddress, prizeAmount, fromBase58String(prizeAsset)), if ((ticketAsset == "WAVES")) | |
75 | 75 | then ScriptTransfer(creator, balance, unit) | |
76 | 76 | else ScriptTransfer(creator, balance, fromBase58String(ticketAsset))])) | |
77 | 77 | } | |
78 | - | else WriteSet([DataEntry(((id + "_cell:") + toString(cell)), toString(i.caller)), DataEntry((id + "_cells"), (cells + 1)), DataEntry((id + "_balance"), | |
78 | + | else WriteSet([DataEntry(((id + "_cell:") + toString(cell)), toString(i.caller)), DataEntry((id + "_cells"), (cells + 1)), DataEntry((id + "_balance"), balance)]) | |
79 | 79 | } | |
80 | 80 | } | |
81 | 81 | } | |
82 | 82 | ||
83 | 83 | ||
84 | 84 | @Verifier(tx) | |
85 | 85 | func verify () = true | |
86 | 86 |
github/deemru/w8io/026f985 26.66 ms ◑