tx · 993nhb7ZbbzKNV15qGHvsvB8M18BKWdNuqPfR5TjFCLX 3MrcjYoMpyT1YVmsjv9kGGPPDw9DkVnZS7D: -0.01000000 Waves 2019.11.18 15:47 [770588] smart account 3MrcjYoMpyT1YVmsjv9kGGPPDw9DkVnZS7D > SELF 0.00000000 Waves
{ "type": 13, "id": "993nhb7ZbbzKNV15qGHvsvB8M18BKWdNuqPfR5TjFCLX", "fee": 1000000, "feeAssetId": null, "timestamp": 1574081289455, "version": 1, "sender": "3MrcjYoMpyT1YVmsjv9kGGPPDw9DkVnZS7D", "senderPublicKey": "AyC6hxspEkzdnui1NLRQkQM1vn2qT2irGJ4q8LyL7q61", "proofs": [ "465hqF6sDmr4q5wnSCSPhnU7B9op2zNjZdpypStzyAHMRXtJwknBFMc4dETnCsRB9F96FE7gBjgH1ZCV7XkkfxUr" ], "script": "base64:AAIDAAAAAAAAAAsIARIDCgEIEgASAAAAAAQAAAAAE2xvdHRlcnlUaWNrZXRIb2xkZXIJAQAAAAdBZGRyZXNzAAAAAQEAAAAaAVShRJEE54zQFCYe5Uzb3SJctUEptvuQ8j0AAAAADGxvdHRlcnlPd25lcgIAAAAjM01yY2pZb01weVQxWVZtc2p2OWtHR1BQRHc5RGtWblpTN0QAAAAAC293bmVyUHViS2V5AQAAACCUHkGyYABsLgGZMAS9ddr+3mdAI5KNU0Ih5mqRYtkyQgAAAAARZEFwcFJhbmRvbUFkZHJlc3MJAQAAAAdBZGRyZXNzAAAAAQEAAAAaAVQeK2SGSauI0UcadBYn/S60bDuahfqSjoAAAAADAAAACmNvbnRleHRPYmoBAAAAF3JlZ2lzdGVyUmFuZG9tUmVxdWVzdFR4AAAAAQAAAA9yYW5kb21SZXF1ZXN0VHgDCQEAAAAJaXNEZWZpbmVkAAAAAQkABB0AAAACBQAAAAR0aGlzAgAAAA9yYW5kb21SZXF1ZXN0VHgJAAACAAAAAQIAAAAncmFuZG9tUmVxdWVzdFR4IGlzIGFscmVhZHkgaW4gdGhlIHN0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kHCQAB9AAAAAMIBQAAAAJ0eAAAAAlib2R5Qnl0ZXMJAAGRAAAAAggFAAAAAnR4AAAABnByb29mcwAAAAAAAAAAAAUAAAALb3duZXJQdWJLZXnUuYD+", "chainId": 84, "height": 770588, "spentComplexity": 0 } View: original | compacted Prev: none Next: none Full:
Old | New | Differences | |
---|---|---|---|
1 | - | # no script | |
1 | + | {-# STDLIB_VERSION 3 #-} | |
2 | + | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | + | {-# CONTENT_TYPE DAPP #-} | |
4 | + | let lotteryTicketHolder = Address(base58'3N4cnhtT2pA1kqePSCZcmyfAhPVWHjcy2Be') | |
5 | + | ||
6 | + | let lotteryOwner = "3MrcjYoMpyT1YVmsjv9kGGPPDw9DkVnZS7D" | |
7 | + | ||
8 | + | let ownerPubKey = base58'AyC6hxspEkzdnui1NLRQkQM1vn2qT2irGJ4q8LyL7q61' | |
9 | + | ||
10 | + | let dAppRandomAddress = Address(base58'3Mrfc2ejF2XxbxUUJyGQ2C7herLKhms9Anj') | |
11 | + | ||
12 | + | @Callable(contextObj) | |
13 | + | func registerRandomRequestTx (randomRequestTx) = if (isDefined(getString(this, "randomRequestTx"))) | |
14 | + | then throw("randomRequestTx is already in the state") | |
15 | + | else if (isDefined(transactionHeightById(fromBase58String(randomRequestTx)))) | |
16 | + | then throw("You try register tx which is already in blockchain") | |
17 | + | else if ((contextObj.caller == addressFromString(lotteryOwner))) | |
18 | + | then WriteSet([DataEntry("randomRequestTx", randomRequestTx)]) | |
19 | + | else throw("only owner can start the lottery") | |
20 | + | ||
21 | + | ||
22 | + | ||
23 | + | @Callable(contextObj) | |
24 | + | func checkRandom () = { | |
25 | + | let randomRequestCommitedTxId = getStringValue(this, "randomRequestTx") | |
26 | + | let randomResponse = getStringValue(dAppRandomAddress, randomRequestCommitedTxId) | |
27 | + | let status = split(randomResponse, "_")[0] | |
28 | + | let randomResult = split(randomResponse, "--")[1] | |
29 | + | if ((status == "FINISHED")) | |
30 | + | then WriteSet([DataEntry("randomResult", parseIntValue(randomResult))]) | |
31 | + | else throw("Incorrect random result") | |
32 | + | } | |
33 | + | ||
34 | + | ||
35 | + | ||
36 | + | @Callable(contextObj) | |
37 | + | func defineTheWinner () = { | |
38 | + | let randomResult = getIntegerValue(this, "randomResult") | |
39 | + | if (isDefined(getInteger(lotteryTicketHolder, ("winningTicket" + toString(randomResult))))) | |
40 | + | then { | |
41 | + | let ticketAmount = getIntegerValue(lotteryTicketHolder, "ticketAmount") | |
42 | + | let randomResultUpdate = if ((randomResult == ticketAmount)) | |
43 | + | then 1 | |
44 | + | else (randomResult + 1) | |
45 | + | WriteSet([DataEntry("randomResult", randomResultUpdate)]) | |
46 | + | } | |
47 | + | else { | |
48 | + | let winnerAddress = getStringValue(lotteryTicketHolder, ("ticket" + toString(randomResult))) | |
49 | + | WriteSet([DataEntry("winnerTicket", randomResult), DataEntry("winnerAddress", winnerAddress)]) | |
50 | + | } | |
51 | + | } | |
52 | + | ||
53 | + | ||
54 | + | @Verifier(tx) | |
55 | + | func verify () = { | |
56 | + | let heightStartLease = 1 | |
57 | + | let heightEndLease = 1000000000000 | |
58 | + | match tx { | |
59 | + | case l: LeaseTransaction => | |
60 | + | if (if (if ((height > heightStartLease)) | |
61 | + | then (heightEndLease > height) | |
62 | + | else false) | |
63 | + | then isDefined(getString(this, "winnerAddress")) | |
64 | + | else false) | |
65 | + | then (l.recipient == addressFromString(getStringValue(this, "winnerAddress"))) | |
66 | + | else false | |
67 | + | case lc: LeaseCancelTransaction => | |
68 | + | if ((height > heightStartLease)) | |
69 | + | then sigVerify(tx.bodyBytes, tx.proofs[0], ownerPubKey) | |
70 | + | else false | |
71 | + | case t: TransferTransaction => | |
72 | + | if ((height > heightStartLease)) | |
73 | + | then sigVerify(tx.bodyBytes, tx.proofs[0], ownerPubKey) | |
74 | + | else false | |
75 | + | case _ => | |
76 | + | sigVerify(tx.bodyBytes, tx.proofs[0], ownerPubKey) | |
77 | + | } | |
78 | + | } | |
79 | + |
github/deemru/w8io/169f3d6 23.99 ms ◑