tx · Ej3W1b6G8YstBA7rHkj6QpX2jhzzTnmEExCNkaLYh6hp 3Mx3efPKjH53t9vseaSJPYD9VX4hz84Pare: -0.01000000 Waves 2019.11.21 17:11 [775057] smart account 3Mx3efPKjH53t9vseaSJPYD9VX4hz84Pare > SELF 0.00000000 Waves
{ "type": 13, "id": "Ej3W1b6G8YstBA7rHkj6QpX2jhzzTnmEExCNkaLYh6hp", "fee": 1000000, "feeAssetId": null, "timestamp": 1574345473322, "version": 1, "sender": "3Mx3efPKjH53t9vseaSJPYD9VX4hz84Pare", "senderPublicKey": "8b3SDEDhQe9CHjzEdCfXR52EzuKDn93Ra9jFTpFWUxTz", "proofs": [ "51ujfyKGuuk2ZiS1NGbKLXiDps2XPpt1fCVH9j2d4XnC24WDwTsmTZ4nStbzambCzwHDniWiwGVbHBDF3qDRRYbx" ], "script": "base64:AAIDAAAAAAAAAA4IARIDCgEIEgASAwoBCAAAAAQAAAAAEGxvdHRlcnlUaWNrZXRIdWIJAQAAAAdBZGRyZXNzAAAAAQEAAAAaAVS7/YhZSflHDfjxlr5eD4WGpjKomrraa0IAAAAADGxvdHRlcnlPd25lcgIAAAAjM014M2VmUEtqSDUzdDl2c2VhU0pQWUQ5Vlg0aHo4NFBhcmUAAAAAC293bmVyUHViS2V5AQAAACBwuk8S7HRGFNc4em7WbuvXB1HMDBbb7wMsWM/jj5t1YQAAAAARZEFwcFJhbmRvbUFkZHJlc3MJAQAAAAdBZGRyZXNzAAAAAQEAAAAaAVTm26t3pFD5oqxsGQfHUjM3D4uQ+HaI/zYAAAADAAAACmNvbnRleHRPYmoBAAAAF3JlZ2lzdGVyUmFuZG9tUmVxdWVzdFR4AAAAAQAAAA9yYW5kb21SZXF1ZXN0VHgDCQEAAAAJaXNEZWZpbmVkAAAAAQkABB0AAAACBQAAAAR0aGlzAgAAAA9yYW5kb21SZXF1ZXN0VHgJAAACAAAAAQIAAAAncmFuZG9tUmVxdWVzdFR4IGlzIGFscmVhZHkgaW4gdGhlIHN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AAAAAgUAAAAGaGVpZ2h0BQAAAA5oZWlnaHRFbmRMZWFzZQkAAfQAAAADCAUAAAACdHgAAAAJYm9keUJ5dGVzCQABkQAAAAIIBQAAAAJ0eAAAAAZwcm9vZnMAAAAAAAAAAAAFAAAAC293bmVyUHViS2V5BwMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAATVHJhbnNmZXJUcmFuc2FjdGlvbgQAAAABdAUAAAAHJG1hdGNoMAMJAABmAAAAAgUAAAAGaGVpZ2h0BQAAAA5oZWlnaHRFbmRMZWFzZQkAAfQAAAADCAUAAAACdHgAAAAJYm9keUJ5dGVzCQABkQAAAAIIBQAAAAJ0eAAAAAZwcm9vZnMAAAAAAAAAAAAFAAAAC293bmVyUHViS2V5BwkAAfQAAAADCAUAAAACdHgAAAAJYm9keUJ5dGVzCQABkQAAAAIIBQAAAAJ0eAAAAAZwcm9vZnMAAAAAAAAAAAAFAAAAC293bmVyUHViS2V5b+DuXw==", "chainId": 84, "height": 775057, "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'3N745rYiGfbHz4Q2MoiEH9Cjwm2AxLRBmbo') | |
5 | + | ||
6 | + | let lotteryOwner = "3Mx3efPKjH53t9vseaSJPYD9VX4hz84Pare" | |
7 | + | ||
8 | + | let ownerPubKey = base58'8b3SDEDhQe9CHjzEdCfXR52EzuKDn93Ra9jFTpFWUxTz' | |
9 | + | ||
10 | + | let dAppRandomAddress = Address(base58'3NAxkLy1Jyqyh3Po6hqq2QRGg81A7FqSArq') | |
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(ticketsInHubKey, "To")[1]) | |
49 | + | let ticketTo = parseIntValue(split(split(ticketsInHubKey, "To")[0], "ticketsFrom")[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/026f985 26.05 ms ◑