tx · 6bPHhC8KvqeM2bti86ee4R6bzFWK7LKk3Ayig3YZgo8y 3MrC1oqVCoLkfHabhJtrLJS6GxcooQwRWuP: -0.01400000 Waves 2019.11.14 18:51 [764935] smart account 3MrC1oqVCoLkfHabhJtrLJS6GxcooQwRWuP > SELF 0.00000000 Waves
{ "type": 13, "id": "6bPHhC8KvqeM2bti86ee4R6bzFWK7LKk3Ayig3YZgo8y", "fee": 1400000, "feeAssetId": null, "timestamp": 1573746426424, "version": 1, "sender": "3MrC1oqVCoLkfHabhJtrLJS6GxcooQwRWuP", "senderPublicKey": "3bmZaUZ9wp3K1YZQFqTkN1oZzumQPi7WLQ9QowMaqqEZ", "proofs": [ "eMN5BjqF2HYRak3vZmx4fYEqcUPdyhZn9jx7DqFzrqce89xpxsCN4oyAQD6s3RJxqETZX96B1ZLWvskyJKs3Dnz" ], "script": "base64:AAIDAAAAAAAAAAsIARIDCgEIEgASAAAAAAQAAAAAE2xvdHRlcnlUaWNrZXRIb2xkZXIJAQAAAAdBZGRyZXNzAAAAAQEAAAAaAVQY85hy7YeAyDRGFObJCypdEQTLdt733vIAAAAADGxvdHRlcnlPd25lcgIAAAAjM014dHpuY0tNOXgxa0twTFAzc3A4V1pQdmcxY3phOGpIR20AAAAAC293bmVyUHViS2V5AQAAACCmNNugTM3YDCyk7xZ6vz/eGflRJPu15vOIW0V7gpcRMAAAAAARZEFwcFJhbmRvbUFkZHJlc3MJAQAAAAdBZGRyZXNzAAAAAQEAAAAaAVQs+qsE+m8UScrki/mi9Vg1BPLz1NtSCiEAAAADAAAACmNvbnRleHRPYmoBAAAAF3JhbmRvbVJlcXVlc3RUeElkUmVjb3JkAAAAAQAAABFyYW5kb21SZXF1ZXN0VHhJZAMJAQAAAAlpc0RlZmluZWQAAAABCQAEHQAAAAIFAAAABHRoaXMCAAAAEXJhbmRvbVJlcXVlc3RUeElkCQAAAgAAAAECAAAAInJhbmRvbUlkVHggaXMgYWxyZWFkeSBpbiB0aGUgc3RhdGUDCQ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AACBQAAAAckbWF0Y2gwAgAAABBMZWFzZVRyYW5zYWN0aW9uBAAAAAFsBQAAAAckbWF0Y2gwAwMDCQAAZgAAAAIFAAAABmhlaWdodAUAAAAQaGVpZ2h0U3RhcnRMZWFzZQkAAGYAAAACBQAAAA5oZWlnaHRFbmRMZWFzZQUAAAAGaGVpZ2h0BwkBAAAACWlzRGVmaW5lZAAAAAEJAAQdAAAAAgUAAAAEdGhpcwIAAAANd2lubmVyQWRkcmVzcwcJAAAAAAAAAggFAAAAAWwAAAAJcmVjaXBpZW50CQEAAAARYWRkcmVzc0Zyb21TdHJpbmcAAAABCQEAAAARQGV4dHJOYXRpdmUoMTA1MykAAAACBQAAAAR0aGlzAgAAAA13aW5uZXJBZGRyZXNzBwMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAAWTGVhc2VDYW5jZWxUcmFuc2FjdGlvbgQAAAACbGMFAAAAByRtYXRjaDADCQAAZgAAAAIFAAAABmhlaWdodAUAAAAQaGVpZ2h0U3RhcnRMZWFzZQkAAfQAAAADCAUAAAACdHgAAAAJYm9keUJ5dGVzCQABkQAAAAIIBQAAAAJ0eAAAAAZwcm9vZnMAAAAAAAAAAAAFAAAAC293bmVyUHViS2V5BwMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAATVHJhbnNmZXJUcmFuc2FjdGlvbgQAAAABdAUAAAAHJG1hdGNoMAMJAABmAAAAAgUAAAAGaGVpZ2h0BQAAABBoZWlnaHRTdGFydExlYXNlCQAB9AAAAAMIBQAAAAJ0eAAAAAlib2R5Qnl0ZXMJAAGRAAAAAggFAAAAAnR4AAAABnByb29mcwAAAAAAAAAAAAUAAAALb3duZXJQdWJLZXkHBjMLcbo=", "chainId": 84, "height": 764935, "spentComplexity": 0 } View: original | compacted Prev: 3mjXY3uUg2Jrpk9YpHbJF2V7yBJTP1UhnRfboDRPQj6P Next: 2as9TnjHo2pu1BxK6VttkgSZq1uSKQXimx9HV1SumSDp Full:
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | let | |
4 | + | let lotteryTicketHolder = Address(base58'3MrC1oqVCoLkfHabhJtrLJS6GxcooQwRWuP') | |
5 | 5 | ||
6 | - | let MRTid = "8afYrbDBr6Tw5JgaWUgm2GncY7rL87JvGG7aWezWMGgZ" | |
6 | + | let lotteryOwner = "3MxtzncKM9x1kKpLP3sp8WZPvg1cza8jHGm" | |
7 | + | ||
8 | + | let ownerPubKey = base58'CBoRgqiPjXZMaoN8BwCSFfXsRX5jvNDiZ9SArkfMQX1Z' | |
9 | + | ||
10 | + | let dAppRandomAddress = Address(base58'3Mt1uo5ieYK8Pk9XyVZp88HBLMfprrq515z') | |
7 | 11 | ||
8 | 12 | @Callable(contextObj) | |
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 | - | } | |
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") | |
22 | 18 | ||
23 | 19 | ||
24 | 20 | ||
25 | 21 | @Callable(contextObj) | |
26 | - | func | |
27 | - | let | |
28 | - | | |
29 | - | | |
30 | - | ||
31 | - | | |
32 | - | | |
33 | - | else throw(" | |
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") | |
34 | 30 | } | |
35 | 31 | ||
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 | + | } | |
36 | 77 |
github/deemru/w8io/169f3d6 37.77 ms ◑