tx · BXr2uvuVGWYWtXrpdiNs6qTrzq2Ed5egDxuHMWsRyHg

3MzNxkE6otE41cM8JeheYNDt7QtDJrUqh9K:  -0.01000000 Waves

2019.11.29 17:53 [786789] smart account 3MzNxkE6otE41cM8JeheYNDt7QtDJrUqh9K > SELF 0.00000000 Waves

{ "type": 13, "id": "BXr2uvuVGWYWtXrpdiNs6qTrzq2Ed5egDxuHMWsRyHg", "fee": 1000000, "feeAssetId": null, "timestamp": 1575039227936, "version": 1, "sender": "3MzNxkE6otE41cM8JeheYNDt7QtDJrUqh9K", "senderPublicKey": "2iffALrXw8w9gqkRoY6WB7ne66w9sf3DtXSLfKsDxTAz", "proofs": [ "5tkCVTxCq9uYwhj6ssF3jqYo4cqfupgMpKcc4FxCYF7QuVJCP9Vi3LqMJz4cGeNvjT1kgVR17JXUYQmiesBiuALE" ], "script": "base64:AAIDAAAAAAAAAA4IARIDCgEIEgMKAQgSAAAAAAQAAAAADG93bmVyQWRkcmVzcwkBAAAAB0FkZHJlc3MAAAABAQAAABoBVBjzmHLth4DINEYU5skLKl0RBMt23vfe8gAAAAAQbG90dGVyeVRpY2tldEh1YgkBAAAAB0FkZHJlc3MAAAABAQAAABoBVMZsUhMojkmM9OQGjsOeJ+EuamWLydhBtwAAAAATbG90dGVyeUFkbWluQWRkcmVzcwkBAAAAB0FkZHJlc3MAAAABAQAAABoBVBjzmHLth4DINEYU5skLKl0RBMt23vfe8gAAAAARZEFwcFJhbmRvbUFkZHJlc3MJAQAAAAdBZGRyZXNzAAAAAQEAAAAaAVTYd3wK66/85GBgt/BmwoJSEx86L5VE0B4AAAADAAAACmNvbnRleHRPYmoBAAAAF3JlZ2lzdGVyUmFuZG9tUmVxdWVzdFR4AAAAAQAAAA9yYW5kb21SZXF1ZXN0VHgDCQEAAAAJaXNEZWZpbmVkAAAAAQkABB0AAAACBQAAAAR0aGlzAgAAAA9yYW5kb21SZXF1ZXN0VHgJAAACAAAAAQIAAAAncmFuZG9tUmVxdWVzdFR4I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AAAAZjYWxsZXIFAAAADG93bmVyQWRkcmVzcwkAAGYAAAACBQAAAAZoZWlnaHQJAABkAAAAAgUAAAALc3RhcnRIZWlnaHQFAAAABW1vbnRoBwkBAAAAC1RyYW5zZmVyU2V0AAAAAQkABEwAAAACCQEAAAAOU2NyaXB0VHJhbnNmZXIAAAADBQAAAAxvd25lckFkZHJlc3MJAQAAAAx3YXZlc0JhbGFuY2UAAAABBQAAAAR0aGlzBQAAAAR1bml0BQAAAANuaWwJAAACAAAAAQIAAAAceW91IGNhbid0IHdpdGhkcmF3IHRoZSBmdW5kcwAAAACo+fe0", "chainId": 84, "height": 786789, "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 ownerAddress = Address(base58'3MrC1oqVCoLkfHabhJtrLJS6GxcooQwRWuP')
5+
6+let lotteryTicketHub = Address(base58'3N81FL9geQ6nECKpq6G7WzouQ3jPzezM6Xg')
7+
8+let lotteryAdminAddress = Address(base58'3MrC1oqVCoLkfHabhJtrLJS6GxcooQwRWuP')
9+
10+let dAppRandomAddress = Address(base58'3N9eesHd6PajVcDJKT3tLDp71DQmm9zWXkH')
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 == lotteryAdminAddress))
18+ then WriteSet([DataEntry("randomRequestTx", randomRequestTx), DataEntry("startHeight", height)])
19+ else throw("only loteryOwner can start the lottery")
20+
21+
22+
23+@Callable(contextObj)
24+func defineTheWinner (ticketsInHubKey) = {
25+ let randomRequestCommitedTxId = getStringValue(this, "randomRequestTx")
26+ let randomResponse = getStringValue(dAppRandomAddress, randomRequestCommitedTxId)
27+ let status = split(randomResponse, "_")[0]
28+ let randomResultString = split(randomResponse, "--")[1]
29+ let randomResult = parseIntValue(randomResultString)
30+ if (isDefined(getInteger(lotteryTicketHub, ("winningTicket" + randomResultString))))
31+ then {
32+ let ticketAmount = getIntegerValue(lotteryTicketHub, "ticketAmount")
33+ let randomResultUpdate = if ((randomResult == ticketAmount))
34+ then 1
35+ else (randomResult + 1)
36+ WriteSet([DataEntry("randomResult", randomResultUpdate)])
37+ }
38+ else {
39+ let ticketFrom = parseIntValue(split(split(ticketsInHubKey, "To")[0], "ticketsFrom")[1])
40+ let ticketTo = parseIntValue(split(ticketsInHubKey, "To")[1])
41+ if (if ((randomResult >= ticketFrom))
42+ then (ticketTo >= randomResult)
43+ else false)
44+ then {
45+ let winnerAddress = getStringValue(lotteryTicketHub, ticketsInHubKey)
46+ WriteSet([DataEntry("winnerTicket", randomResult), DataEntry("winnerAddress", winnerAddress)])
47+ }
48+ else throw("these tickets didn't win")
49+ }
50+ }
51+
52+
53+
54+@Callable(contextObj)
55+func withdraw () = {
56+ let winnerAddress = addressFromStringValue(getStringValue(this, "winnerAddress"))
57+ let startHeight = getIntegerValue(this, "startHeight")
58+ let month = 43200
59+ if (if ((contextObj.caller == winnerAddress))
60+ then ((startHeight + month) >= height)
61+ else false)
62+ then ScriptResult(WriteSet([DataEntry("withdrawn", true)]), TransferSet([ScriptTransfer(winnerAddress, wavesBalance(this), unit)]))
63+ else if (if (if ((contextObj.caller == lotteryAdminAddress))
64+ then true
65+ else (contextObj.caller == ownerAddress))
66+ then (height > (startHeight + month))
67+ else false)
68+ then TransferSet([ScriptTransfer(ownerAddress, wavesBalance(this), unit)])
69+ else throw("you can't withdraw the funds")
70+ }
71+
72+

github/deemru/w8io/169f3d6 
26.55 ms