tx · 7j8iC2QBCuu45sRrRc62wwE919qAnWjYVZQTLsjNDg9w 3NBvMkycoGXckMZw88L1KPjGruPkprceAM9: -0.01000000 Waves 2019.11.25 17:58 [780943] smart account 3NBvMkycoGXckMZw88L1KPjGruPkprceAM9 > SELF 0.00000000 Waves
{ "type": 13, "id": "7j8iC2QBCuu45sRrRc62wwE919qAnWjYVZQTLsjNDg9w", "fee": 1000000, "feeAssetId": null, "timestamp": 1574693927105, "version": 1, "sender": "3NBvMkycoGXckMZw88L1KPjGruPkprceAM9", "senderPublicKey": "8gJTvzPRWvqkQkKFxvDwsEZxDc3nA8tk7NocuoXTBKiM", "proofs": [ "3xkKDjwYCpkM6umrgTQDS89GrC3wWAjBQ1azSYcgqFrh39onZrDrXh6DmGP1MJv1VbuW7kivvyHnDEoiKNpzoAG6" ], "script": "base64:AAIDAAAAAAAAABAIARIDCgEIEgASAwoBCBIAAAAABAAAAAAQbG90dGVyeVRpY2tldEh1YgkBAAAAB0FkZHJlc3MAAAABAQAAABoBVLAxFDiKcOe/A4E/gtkpN4vyI0jCpeXNWAAAAAAMbG90dGVyeU93bmVyAgAAACMzTkJ2TWt5Y29HWGNrTVp3ODhMMUtQakdydVBrcHJjZUFNOQAAAAALb3duZXJQdWJLZXkBAAAAIHITNP7ZANzAszbVR04jTypTMT5TBAxZe46lSofHbTxWAAAAABFkQXBwUmFuZG9tQWRkcmVzcwkBAAAAB0FkZHJlc3MAAAABAQAAABoBVFgY9oIV562zxiMZNh64cTo/PIu2IVXCDgAAAAQAAAAKY29udGV4dE9iagEAAAAXcmVnaXN0ZXJSYW5kb21SZXF1ZXN0VHgAAAABAAAAD3JhbmRvbVJlcXVlc3RUeAMJAQAAAAlpc0RlZmluZWQAAAABCQAEHQAAAAIFAAAABHRoaXMCAAAAD3JhbmRvbVJlcXVlc3RUeAkAAAIAAAABAgAAACdyYW5kb21SZXF1ZXN0VHggaXMgYWxyZWFkeSBpbiB0aGUgc3RhdGUDCQEAAAAJaXNEZWZp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AAAAAwUAAAANd2lubmVyQWRkcmVzcwkAA+sAAAACBQAAAAR0aGlzBQAAAAR1bml0BQAAAAR1bml0BQAAAANuaWwDAwkAAAAAAAACCAUAAAAKY29udGV4dE9iagAAAAZjYWxsZXIJAQAAABxAZXh0clVzZXIoYWRkcmVzc0Zyb21TdHJpbmcpAAAAAQUAAAAMbG90dGVyeU93bmVyCQAAZgAAAAIFAAAABmhlaWdodAkAAGQAAAACBQAAAAl3aW5IZWlnaHQFAAAABW1vbnRoBwkBAAAAC1RyYW5zZmVyU2V0AAAAAQkABEwAAAACCQEAAAAOU2NyaXB0VHJhbnNmZXIAAAADBQAAAAxvd25lckFkZHJlc3MJAAPrAAAAAgUAAAAEdGhpcwUAAAAEdW5pdAUAAAAEdW5pdAUAAAADbmlsCQAAAgAAAAECAAAAHHlvdSBjYW4ndCB3aXRoZHJhdyB0aGUgZnVuZHMAAAAAp7X17w==", "chainId": 84, "height": 780943, "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'3N5yhVkV6JS3NNqsQuLoVFJ1j3YP7uDzoQ3') | |
5 | + | ||
6 | + | let lotteryOwner = "3NBvMkycoGXckMZw88L1KPjGruPkprceAM9" | |
7 | + | ||
8 | + | let ownerPubKey = base58'8gJTvzPRWvqkQkKFxvDwsEZxDc3nA8tk7NocuoXTBKiM' | |
9 | + | ||
10 | + | let dAppRandomAddress = Address(base58'3Mwwu9Fo2QwnwrHtz9PoGn758MTbEt5sZnm') | |
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 loteryOwner 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), DataEntry("winHeight", height)]) | |
56 | + | } | |
57 | + | else throw("these tickets didn't win") | |
58 | + | } | |
59 | + | } | |
60 | + | ||
61 | + | ||
62 | + | ||
63 | + | @Callable(contextObj) | |
64 | + | func withdraw () = { | |
65 | + | let winnerAddress = addressFromStringValue(getStringValue(this, "winnerAddress")) | |
66 | + | let winHeight = getIntegerValue(this, "winHeight") | |
67 | + | let ownerAddress = addressFromPublicKey(ownerPubKey) | |
68 | + | let month = 43200 | |
69 | + | if (if ((contextObj.caller == winnerAddress)) | |
70 | + | then ((winHeight + month) >= height) | |
71 | + | else false) | |
72 | + | then TransferSet([ScriptTransfer(winnerAddress, assetBalance(this, unit), unit)]) | |
73 | + | else if (if ((contextObj.caller == addressFromStringValue(lotteryOwner))) | |
74 | + | then (height > (winHeight + month)) | |
75 | + | else false) | |
76 | + | then TransferSet([ScriptTransfer(ownerAddress, assetBalance(this, unit), unit)]) | |
77 | + | else throw("you can't withdraw the funds") | |
78 | + | } | |
79 | + | ||
80 | + |
github/deemru/w8io/026f985 35.37 ms ◑