tx · 2as9TnjHo2pu1BxK6VttkgSZq1uSKQXimx9HV1SumSDp 3MrC1oqVCoLkfHabhJtrLJS6GxcooQwRWuP: -0.01400000 Waves 2019.11.14 18:53 [764939] smart account 3MrC1oqVCoLkfHabhJtrLJS6GxcooQwRWuP > SELF 0.00000000 Waves
{ "type": 13, "id": "2as9TnjHo2pu1BxK6VttkgSZq1uSKQXimx9HV1SumSDp", "fee": 1400000, "feeAssetId": null, "timestamp": 1573746831408, "version": 1, "sender": "3MrC1oqVCoLkfHabhJtrLJS6GxcooQwRWuP", "senderPublicKey": "3bmZaUZ9wp3K1YZQFqTkN1oZzumQPi7WLQ9QowMaqqEZ", "proofs": [ "5wmK752fwtYvStswZA4tqWJfY7F8Fk5JdCucB8nR7i34CGGXCWEA3pypMnLjKdTeNtaf4dVgu194ZG4nCXEigHm8" ], "script": "base64:AAIDAAAAAAAAAA0IARIDCgEIEgQKAggBAAAAAgAAAAALdGlja2V0UHJpY2UAAAAAAAAAJxAAAAAABU1SVGlkAgAAACw4YWZZcmJEQnI2VHc1SmdhV1VnbTJHbmNZN3JMODdKdkdHN2FXZXpXTUdnWgAAAAIAAAAKY29udGV4dE9iagEAAAAJYnV5VGlja2V0AAAAAQAAAA1hZGRyZXNUb0xlYXNlBAAAAAckbWF0Y2gwCAUAAAAKY29udGV4dE9iagAAAAdwYXltZW50AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAA9BdHRhY2hlZFBheW1lbnQEAAAAAXAFAAAAByRtYXRjaDADAwkAAAAAAAACCAUAAAABcAAAAAZhbW91bnQFAAAAC3RpY2tldFByaWNlCQAAAAAAAAIJAAJYAAAAAQkBAAAAB2V4dHJhY3QAAAABCAUAAAABcAAAAAdhc3NldElkBQAAAAVNUlRpZAcEAAAAD3RpY2tldEFtb3VudE5ldwkAAGQAAAACCQEAAAARQGV4dHJOYXRpdmUoMTA1MCkAAAACBQAAAAR0aGlzAgAAAAx0aWNrZXRBbW91bnQAAAAAAAAAAAEJAQAAAAhXcml0ZVNldAAAAAEJAARMAAAAAgkBAAAACURhdGFFbnRyeQAAAAIJAAEsAAAAAgIAAAAGdGlja2V0CQABpAAAAAEFAAAAD3RpY2tldEFtb3VudE5ldwUAAAANYWRkcmVzVG9MZWFzZQkABEwAAAACCQEAAAAJRGF0YUVudHJ5AAAAAgIAAAAMdGlja2V0QW1vdW50BQAAAA90aWNrZXRBbW91bnROZXcFAAAAA25pbAkAAAIAAAABAgAAACZJbmNvcnJlY3QgYW1vdW50IG9yIGFzc2V0SWQgaW4gcGF5bWVudAkAAAIAAAABAgAAABRQYXltZW50IG5vdCBhdHRhY2hlZAAAAApjb250ZXh0T2JqAQAAAAlhZGRXaW5uZXIAAAACAAAAB2xvdHRlcnkAAAAGdGlja2V0BAAAAA5sb3R0ZXJ5QWRkcmVzcwkBAAAAB2V4dHJhY3QAAAABCQEAAAARYWRkcmVzc0Zyb21TdHJpbmcAAAABBQAAAAdsb3R0ZXJ5AwkBAAAACWlzRGVmaW5lZAAAAAEJAAQdAAAAAgUAAAAEdGhpcwUAAAAHbG90dGVyeQQAAAANd2lubmVyQWRkcmVzcwkBAAAAEUBleHRyTmF0aXZlKDEwNTMpAAAAAgUAAAAObG90dGVyeUFkZHJlc3MCAAAADXdpbm5lckFkZHJlc3MEAAAADHdpbm5lclRpY2tldAkBAAAAEUBleHRyTmF0aXZlKDEwNTApAAAAAgUAAAAObG90dGVyeUFkZHJlc3MCAAAADHdpbm5lclRpY2tldAkBAAAACFdyaXRlU2V0AAAAAQkABEwAAAACCQEAAAAJRGF0YUVudHJ5AAAAAgkAASwAAAACAgAAAA13aW5uaW5nVGlja2V0CQABpAAAAAEFAAAADHdpbm5lclRpY2tldAUAAAANd2lubmVyQWRkcmVzcwUAAAADbmlsCQAAAgAAAAECAAAAI3lvdSB0b3VjaCBpbmNvcnJlY3QgbG90dGVyeSBhZGRyZXNzAAAAALy/BIE=", "chainId": 84, "height": 764939, "spentComplexity": 0 } View: original | compacted Prev: 6bPHhC8KvqeM2bti86ee4R6bzFWK7LKk3Ayig3YZgo8y Next: AEaHTefo6PjA3d37Cv6rkSjs1kKJjWy7ZVWUQTYrAQbC Full:
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | let | |
4 | + | let ticketPrice = 10000 | |
5 | 5 | ||
6 | - | let lotteryOwner = "3MxtzncKM9x1kKpLP3sp8WZPvg1cza8jHGm" | |
7 | - | ||
8 | - | let ownerPubKey = base58'CBoRgqiPjXZMaoN8BwCSFfXsRX5jvNDiZ9SArkfMQX1Z' | |
9 | - | ||
10 | - | let dAppRandomAddress = Address(base58'3Mt1uo5ieYK8Pk9XyVZp88HBLMfprrq515z') | |
6 | + | let MRTid = "8afYrbDBr6Tw5JgaWUgm2GncY7rL87JvGG7aWezWMGgZ" | |
11 | 7 | ||
12 | 8 | @Callable(contextObj) | |
13 | - | func randomRequestTxIdRecord (randomRequestTxId) = if (isDefined(getString(this, "randomRequestTxId"))) | |
14 | - | then throw("randomIdTx is already in the state") | |
15 | - | else if ((contextObj.caller == addressFromString(lotteryOwner))) | |
16 | - | then WriteSet([DataEntry("randomRequestTxId", randomRequestTxId)]) | |
17 | - | else throw("only owner can start the lottery") | |
9 | + | func buyTicket (addresToLease) = match contextObj.payment { | |
10 | + | case p: AttachedPayment => | |
11 | + | if (if ((p.amount == ticketPrice)) | |
12 | + | then (toBase58String(extract(p.assetId)) == MRTid) | |
13 | + | else false) | |
14 | + | then { | |
15 | + | let ticketAmountNew = (getIntegerValue(this, "ticketAmount") + 1) | |
16 | + | WriteSet([DataEntry(("ticket" + toString(ticketAmountNew)), addresToLease), DataEntry("ticketAmount", ticketAmountNew)]) | |
17 | + | } | |
18 | + | else throw("Incorrect amount or assetId in payment") | |
19 | + | case _ => | |
20 | + | throw("Payment not attached") | |
21 | + | } | |
18 | 22 | ||
19 | 23 | ||
20 | 24 | ||
21 | 25 | @Callable(contextObj) | |
22 | - | func checkRandom () = { | |
23 | - | let randomRequestCommitedTxId = getStringValue(this, "randomRequestTxId") | |
24 | - | let randomResponse = getStringValue(dAppRandomAddress, randomRequestCommitedTxId) | |
25 | - | let status = split(randomResponse, "_")[0] | |
26 | - | let randomResult = split(randomResponse, "--")[1] | |
27 | - | if ((status == "FINISHED")) | |
28 | - | then WriteSet([DataEntry("randomResult", parseIntValue(randomResult))]) | |
29 | - | else throw("Incorrect random result") | |
26 | + | func addWinner (lottery,ticket) = { | |
27 | + | let lotteryAddress = extract(addressFromString(lottery)) | |
28 | + | if (isDefined(getString(this, lottery))) | |
29 | + | then { | |
30 | + | let winnerAddress = getStringValue(lotteryAddress, "winnerAddress") | |
31 | + | let winnerTicket = getIntegerValue(lotteryAddress, "winnerTicket") | |
32 | + | WriteSet([DataEntry(("winningTicket" + toString(winnerTicket)), winnerAddress)]) | |
33 | + | } | |
34 | + | else throw("you touch incorrect lottery address") | |
30 | 35 | } | |
31 | 36 | ||
32 | - | ||
33 | - | ||
34 | - | @Callable(contextObj) | |
35 | - | func defineTheWinner () = { | |
36 | - | let randomResult = getIntegerValue(this, "randomResult") | |
37 | - | if (isDefined(getInteger(lotteryTicketHolder, ("winningTicket" + toString(randomResult))))) | |
38 | - | then { | |
39 | - | let ticketAmount = getIntegerValue(lotteryTicketHolder, "ticketAmount") | |
40 | - | let randomResultUpdate = if ((randomResult == ticketAmount)) | |
41 | - | then 1 | |
42 | - | else (randomResult + 1) | |
43 | - | WriteSet([DataEntry("randomResult", randomResultUpdate)]) | |
44 | - | } | |
45 | - | else { | |
46 | - | let winnerAddress = getStringValue(lotteryTicketHolder, ("ticket" + toString(randomResult))) | |
47 | - | WriteSet([DataEntry("winnerTicket", randomResult), DataEntry("winnerAddress", winnerAddress)]) | |
48 | - | } | |
49 | - | } | |
50 | - | ||
51 | - | ||
52 | - | @Verifier(tx) | |
53 | - | func verify () = { | |
54 | - | let heightStartLease = 1 | |
55 | - | let heightEndLease = 0 | |
56 | - | match tx { | |
57 | - | case l: LeaseTransaction => | |
58 | - | if (if (if ((height > heightStartLease)) | |
59 | - | then (heightEndLease > height) | |
60 | - | else false) | |
61 | - | then isDefined(getString(this, "winnerAddress")) | |
62 | - | else false) | |
63 | - | then (l.recipient == addressFromString(getStringValue(this, "winnerAddress"))) | |
64 | - | else false | |
65 | - | case lc: LeaseCancelTransaction => | |
66 | - | if ((height > heightStartLease)) | |
67 | - | then sigVerify(tx.bodyBytes, tx.proofs[0], ownerPubKey) | |
68 | - | else false | |
69 | - | case t: TransferTransaction => | |
70 | - | if ((height > heightStartLease)) | |
71 | - | then sigVerify(tx.bodyBytes, tx.proofs[0], ownerPubKey) | |
72 | - | else false | |
73 | - | case _ => | |
74 | - | true | |
75 | - | } | |
76 | - | } | |
77 | 37 |
github/deemru/w8io/169f3d6 32.17 ms ◑