tx · BfDmeWniqjeMRSNmqUnAk3hGYMvEpACHnaBEmmAngkh9 3MxUc3EY15cLQ5DC2RFHip9fhgvfYXMBJWC: -0.01000000 Waves 2019.11.18 15:57 [770594] smart account 3MxUc3EY15cLQ5DC2RFHip9fhgvfYXMBJWC > SELF 0.00000000 Waves
{ "type": 13, "id": "BfDmeWniqjeMRSNmqUnAk3hGYMvEpACHnaBEmmAngkh9", "fee": 1000000, "feeAssetId": null, "timestamp": 1574081862670, "version": 1, "sender": "3MxUc3EY15cLQ5DC2RFHip9fhgvfYXMBJWC", "senderPublicKey": "43T1oshbTi2AGge8rNsGJT8NcwcQRuQECwjQbqVNoatk", "proofs": [ "5jgjtBXGdi6TLPNALe3VqANKgQoLqvMomZWm6zShT4kWjdj18UFBX3Aos8T9jyuZBXhUcVZRjxpP7kZcyXEFXyuo" ], "script": "base64:AAIDAAAAAAAAAAsIARIDCgEIEgASAAAAAAQAAAAAE2xvdHRlcnlUaWNrZXRIb2xkZXIJAQAAAAdBZGRyZXNzAAAAAQEAAAAaAVQ4P5nX6vSfyUWDKUd2jZ8m1z30aeOCEYkAAAAADGxvdHRlcnlPd25lcgIAAAAjM014VWMzRVkxNWNMUTVEQzJSRkhpcDlmaGd2ZllYTUJKV0MAAAAAC293bmVyUHViS2V5AQAAACAtM6LuI4Ki6d46xtYv3fKoiMOpWfPJHt2lEDbAVH+MXQAAAAARZEFwcFJhbmRvbUFkZHJlc3MJAQAAAAdBZGRyZXNzAAAAAQEAAAAaAVQuUBI6cLpNCWqtTFL7swar/kDqojwMmeQAAAADAAAACmNvbnRleHRPYmoBAAAAF3JlZ2lzdGVyUmFuZG9tUmVxdWVzdFR4AAAAAQAAAA9yYW5kb21SZXF1ZXN0VHgDCQEAAAAJaXNEZWZpbmVkAAAAAQkABB0AAAACBQAAAAR0aGlzAgAAAA9yYW5kb21SZXF1ZXN0VHgJAAACAAAAAQIAAAAncmFuZG9tUmVxdWVzdFR4IGlzIGFscmVhZHkgaW4gdGhlIH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ZXkHCQAB9AAAAAMIBQAAAAJ0eAAAAAlib2R5Qnl0ZXMJAAGRAAAAAggFAAAAAnR4AAAABnByb29mcwAAAAAAAAAAAAUAAAALb3duZXJQdWJLZXnD5/D3", "chainId": 84, "height": 770594, "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'3Mu3VojZPzNywADRSzwWC7ituSvQbNaVqvx') | |
5 | + | ||
6 | + | let lotteryOwner = "3MxUc3EY15cLQ5DC2RFHip9fhgvfYXMBJWC" | |
7 | + | ||
8 | + | let ownerPubKey = base58'43T1oshbTi2AGge8rNsGJT8NcwcQRuQECwjQbqVNoatk' | |
9 | + | ||
10 | + | let dAppRandomAddress = Address(base58'3Mt8xnBwt6AmXbKaNXGB9oQYYbKAQoEKaxj') | |
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/026f985 29.48 ms ◑