tx · Efr4ht9gZXz9zwiu7VpEEZWRR1phKwv3UtXifdSwPmQm 3MwAWzsrC9ArFFhHoArjM9Kpqkoo4u8RDe7: -0.01000000 Waves 2019.11.25 15:21 [780778] smart account 3MwAWzsrC9ArFFhHoArjM9Kpqkoo4u8RDe7 > SELF 0.00000000 Waves
{ "type": 13, "id": "Efr4ht9gZXz9zwiu7VpEEZWRR1phKwv3UtXifdSwPmQm", "fee": 1000000, "feeAssetId": null, "timestamp": 1574684469351, "version": 1, "sender": "3MwAWzsrC9ArFFhHoArjM9Kpqkoo4u8RDe7", "senderPublicKey": "1ZX9ie63Rz7X8FXA8GQRP8LbUCwGbjTua1oHfX6eD1o", "proofs": [ "4cSsTV88YQrqUqxB5koZLwB9AzQkFZjvqKXyDocme8CQj6CNiHMycQH4wRwiFL4J5qWmXfXpJVce8M6MjjXKCNqb" ], "script": "base64:AAIDAAAAAAAAAA4IARIDCgEIEgASAwoBCAAAAAQAAAAAEGxvdHRlcnlUaWNrZXRIdWIJAQAAAAdBZGRyZXNzAAAAAQEAAAAaAVS3c8KhZZqP/0Hgp2DgOzq/4eSqBnyXS3IAAAAADGxvdHRlcnlPd25lcgIAAAAjM013QVd6c3JDOUFyRkZoSG9BcmpNOUtwcWtvbzR1OFJEZTcAAAAAC293bmVyUHViS2V5AQAAACAAJMUx4FEFQZUQv4ZlV084IGd3q4aimkSoetUvcoXXNgAAAAARZEFwcFJhbmRvbUFkZHJlc3MJAQAAAAdBZGRyZXNzAAAAAQEAAAAaAVR69Gble9L7ZAlkIRDez4s9orqMbsXhOU4AAAADAAAACmNvbnRleHRPYmoBAAAAF3JlZ2lzdGVyUmFuZG9tUmVxdWVzdFR4AAAAAQAAAA9yYW5kb21SZXF1ZXN0VHgDCQEAAAAJaXNEZWZpbmVkAAAAAQkABB0AAAACBQAAAAR0aGlzAgAAAA9yYW5kb21SZXF1ZXN0VHgJAAACAAAAAQIAAAAncmFuZG9tUmVxdWVzdFR4IGlzIGFscmVhZHkgaW4g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GNoMAMJAABmAAAAAgUAAAAGaGVpZ2h0BQAAAA5oZWlnaHRFbmRMZWFzZQkAAfQAAAADCAUAAAACdHgAAAAJYm9keUJ5dGVzCQABkQAAAAIIBQAAAAJ0eAAAAAZwcm9vZnMAAAAAAAAAAAAFAAAAC293bmVyUHViS2V5BwMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAATVHJhbnNmZXJUcmFuc2FjdGlvbgQAAAABdAUAAAAHJG1hdGNoMAMJAABmAAAAAgUAAAAGaGVpZ2h0BQAAAA5oZWlnaHRFbmRMZWFzZQkAAfQAAAADCAUAAAACdHgAAAAJYm9keUJ5dGVzCQABkQAAAAIIBQAAAAJ0eAAAAAZwcm9vZnMAAAAAAAAAAAAFAAAAC293bmVyUHViS2V5BwkAAfQAAAADCAUAAAACdHgAAAAJYm9keUJ5dGVzCQABkQAAAAIIBQAAAAJ0eAAAAAZwcm9vZnMAAAAAAAAAAAAFAAAAC293bmVyUHViS2V5aSiaeg==", "chainId": 84, "height": 780778, "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 lotteryTicketHub = Address(base58'3N6e67BztDWhitY4MicKwLRkjrmJ3U4or2M') | |
5 | + | ||
6 | + | let lotteryOwner = "3MwAWzsrC9ArFFhHoArjM9Kpqkoo4u8RDe7" | |
7 | + | ||
8 | + | let ownerPubKey = base58'1ZX9ie63Rz7X8FXA8GQRP8LbUCwGbjTua1oHfX6eD1o' | |
9 | + | ||
10 | + | let dAppRandomAddress = Address(base58'3N18CzfiNb2vhRRgVqMc3Y5kHezHWp9PowB') | |
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 (ticketsInHubKey) = { | |
38 | + | let randomResult = getIntegerValue(this, "randomResult") | |
39 | + | if (isDefined(getInteger(lotteryTicketHub, ("winningTicket" + toString(randomResult))))) | |
40 | + | then { | |
41 | + | let ticketAmount = getIntegerValue(lotteryTicketHub, "ticketAmount") | |
42 | + | let randomResultUpdate = if ((randomResult == ticketAmount)) | |
43 | + | then 1 | |
44 | + | else (randomResult + 1) | |
45 | + | WriteSet([DataEntry("randomResult", randomResultUpdate)]) | |
46 | + | } | |
47 | + | else { | |
48 | + | let ticketFrom = parseIntValue(split(split(ticketsInHubKey, "To")[0], "ticketsFrom")[1]) | |
49 | + | let ticketTo = parseIntValue(split(ticketsInHubKey, "To")[1]) | |
50 | + | if (if ((randomResult >= ticketFrom)) | |
51 | + | then (ticketTo >= randomResult) | |
52 | + | else false) | |
53 | + | then { | |
54 | + | let winnerAddress = getStringValue(lotteryTicketHub, ticketsInHubKey) | |
55 | + | WriteSet([DataEntry("winnerTicket", randomResult), DataEntry("winnerAddress", winnerAddress)]) | |
56 | + | } | |
57 | + | else throw("these tickets didn't win") | |
58 | + | } | |
59 | + | } | |
60 | + | ||
61 | + | ||
62 | + | @Verifier(tx) | |
63 | + | func verify () = { | |
64 | + | let heightStartLease = 1 | |
65 | + | let heightEndLease = 1000000000000 | |
66 | + | match tx { | |
67 | + | case l: LeaseTransaction => | |
68 | + | if (if (if ((height > heightStartLease)) | |
69 | + | then (heightEndLease > height) | |
70 | + | else false) | |
71 | + | then isDefined(getString(this, "winnerAddress")) | |
72 | + | else false) | |
73 | + | then (l.recipient == addressFromString(getStringValue(this, "winnerAddress"))) | |
74 | + | else false | |
75 | + | case lc: LeaseCancelTransaction => | |
76 | + | if ((height > heightEndLease)) | |
77 | + | then sigVerify(tx.bodyBytes, tx.proofs[0], ownerPubKey) | |
78 | + | else false | |
79 | + | case t: TransferTransaction => | |
80 | + | if ((height > heightEndLease)) | |
81 | + | then sigVerify(tx.bodyBytes, tx.proofs[0], ownerPubKey) | |
82 | + | else false | |
83 | + | case _ => | |
84 | + | sigVerify(tx.bodyBytes, tx.proofs[0], ownerPubKey) | |
85 | + | } | |
86 | + | } | |
87 | + |
github/deemru/w8io/169f3d6 25.26 ms ◑