tx · 6UaytaAqatP8mJLuMg1XZhDcTtryQAbZEiXbAANT5kBV

3N8rHcpcL8GstFYbE3Mrx8sSpB7XfZiae4X:  -0.01000000 Waves

2019.11.25 16:33 [780856] smart account 3N8rHcpcL8GstFYbE3Mrx8sSpB7XfZiae4X > SELF 0.00000000 Waves

{ "type": 13, "id": "6UaytaAqatP8mJLuMg1XZhDcTtryQAbZEiXbAANT5kBV", "fee": 1000000, "feeAssetId": null, "timestamp": 1574688909443, "version": 1, "sender": "3N8rHcpcL8GstFYbE3Mrx8sSpB7XfZiae4X", "senderPublicKey": "8oJVUSCNoYu2bBMgfucKMbp6zq3WVFckz8szCi5xrUgc", "proofs": [ "xkkUvKeyKdTjmDLDxNC5H57Wy2x2p5MRXXft4YgtoExhBrEUBzSNTw9Ephu6NaaiXhqz8rusMehQSKfKhJ8GVYj" ], "script": "base64:AAIDAAAAAAAAABAIARIDCgEIEgASAwoBCBIAAAAABAAAAAAQbG90dGVyeVRpY2tldEh1YgkBAAAAB0FkZHJlc3MAAAABAQAAABoBVC+39ATLfj9WOsEULw1eayn3FgAYcG7bNQAAAAAMbG90dGVyeU93bmVyAgAAACMzTjhySGNwY0w4R3N0RlliRTNNcng4c1NwQjdYZlppYWU0WAAAAAALb3duZXJQdWJLZXkBAAAAIHPeTYB0wsJXl2G/5/wLNjtiWzCpL4zg9mGK36x3wucdAAAAABFkQXBwUmFuZG9tQWRkcmVzcwkBAAAAB0FkZHJlc3MAAAABAQAAABoBVFTgBTBlDW2NX5U+rtvuCzEEwtlJZ2tEoQAAAAQAAAAKY29udGV4dE9iagEAAAAXcmVnaXN0ZXJSYW5kb21SZXF1ZXN0VHgAAAABAAAAD3JhbmRvbVJlcXVlc3RUeAMJAQAAAAlpc0RlZmluZWQAAAABCQAEHQAAAAIFAAAABHRoaXMCAAAAD3JhbmRvbVJlcXVlc3RUeAkAAAIAAAABAgAAACdyYW5kb21SZXF1ZXN0VHggaXMgYWxyZWFkeSBpbiB0aGUgc3RhdGUD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AAABHRoaXMFAAAABHVuaXQFAAAABHVuaXQFAAAAA25pbAMDCQAAAAAAAAIIBQAAAApjb250ZXh0T2JqAAAABmNhbGxlcgkBAAAAHEBleHRyVXNlcihhZGRyZXNzRnJvbVN0cmluZykAAAABBQAAAAxsb3R0ZXJ5T3duZXIJAABmAAAAAgUAAAAGaGVpZ2h0CQAAZAAAAAIFAAAACXdpbkhlaWdodAUAAAAFbW9udGgHCQEAAAALVHJhbnNmZXJTZXQAAAABCQAETAAAAAIJAQAAAA5TY3JpcHRUcmFuc2ZlcgAAAAMFAAAADG93bmVyQWRkcmVzcwkAA+sAAAACBQAAAAR0aGlzBQAAAAR1bml0BQAAAAR1bml0BQAAAANuaWwJAAACAAAAAQIAAAAceW91IGNhbid0IHdpdGhkcmF3IHRoZSBmdW5kcwAAAADAdZFi", "chainId": 84, "height": 780856, "spentComplexity": 0 } View: original | compacted Prev: none Next: none Full:
OldNewDifferences
1-# no script
1+{-# STDLIB_VERSION 3 #-}
2+{-# SCRIPT_TYPE ACCOUNT #-}
3+{-# CONTENT_TYPE DAPP #-}
4+let lotteryTicketHub = Address(base58'3MtGPuEE7F7KiERmknemXpaJNoFeYXAW2zG')
5+
6+let lotteryOwner = "3N8rHcpcL8GstFYbE3Mrx8sSpB7XfZiae4X"
7+
8+let ownerPubKey = base58'8oJVUSCNoYu2bBMgfucKMbp6zq3WVFckz8szCi5xrUgc'
9+
10+let dAppRandomAddress = Address(base58'3MweruEcWpkJfUFpshvfLRU1c87u4bXK5Qk')
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)])
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/169f3d6 
21.93 ms