tx · 3jXmNjd7QRYPfYbjNMH3ykcpCfeG7UCMHmZjgJH7rCTQ

3MurT4EMaSfFpRoTrzq1jrvZ2Ju4qQXMLx3:  -0.01000000 Waves

2019.12.02 19:41 [791311] smart account 3MurT4EMaSfFpRoTrzq1jrvZ2Ju4qQXMLx3 > SELF 0.00000000 Waves

{ "type": 13, "id": "3jXmNjd7QRYPfYbjNMH3ykcpCfeG7UCMHmZjgJH7rCTQ", "fee": 1000000, "feeAssetId": null, "timestamp": 1575304971078, "version": 1, "sender": "3MurT4EMaSfFpRoTrzq1jrvZ2Ju4qQXMLx3", "senderPublicKey": "BLXF7nFr2qwNH9eMAhLzVEDeS8AmLTiuq1krBwNn6p79", "proofs": [ "3e1WuFGcT7MU9DYVWvsqZfoC3hsJc9Wh228KcEtGhW2x6fyMFDYdFPz8d1M6cVnd6yo9WZ9S2BnwoSRLQiwH6Gjc" ], "script": "base64:AAIDAAAAAAAAAA4IARIDCgEIEgMKAQgSAAAAAAQAAAAADG93bmVyQWRkcmVzcwkBAAAAB0FkZHJlc3MAAAABAQAAABoBVCKO49UfdVacf8Y0Qj59HGp7V9voyjFs/QAAAAAQbG90dGVyeVRpY2tldEh1YgkBAAAAB0FkZHJlc3MAAAABAQAAABoBVO/iqJ5gKLCraDGzw/VYaAggIjFM2W4Y1AAAAAATbG90dGVyeUFkbWluQWRkcmVzcwkBAAAAB0FkZHJlc3MAAAABAQAAABoBVCKO49UfdVacf8Y0Qj59HGp7V9voyjFs/QAAAAARZEFwcFJhbmRvbUFkZHJlc3MJAQAAAAdBZGRyZXNzAAAAAQEAAAAaAVR/3h+0vhWDWUmsiM56YVr/pP+eTzi9ZtkAAAADAAAACmNvbnRleHRPYmoBAAAAF3JlZ2lzdGVyUmFuZG9tUmVxdWVzdFR4AAAAAQAAAA9yYW5kb21SZXF1ZXN0VHgDCQEAAAAJaXNEZWZpbmVkAAAAAQkABB0AAAACBQAAAAR0aGlzAgAAAA9yYW5kb21SZXF1ZXN0VHgJAAAC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NzBgkAAAAAAAACCAUAAAAKY29udGV4dE9iagAAAAZjYWxsZXIFAAAADG93bmVyQWRkcmVzcwkAAGYAAAACBQAAAAZoZWlnaHQJAABkAAAAAgUAAAALc3RhcnRIZWlnaHQFAAAABW1vbnRoBwkBAAAAC1RyYW5zZmVyU2V0AAAAAQkABEwAAAACCQEAAAAOU2NyaXB0VHJhbnNmZXIAAAADBQAAAAxvd25lckFkZHJlc3MJAQAAAAx3YXZlc0JhbGFuY2UAAAABBQAAAAR0aGlzBQAAAAR1bml0BQAAAANuaWwJAAACAAAAAQIAAAAceW91IGNhbid0IHdpdGhkcmF3IHRoZSBmdW5kcwAAAAACXwgx", "chainId": 84, "height": 791311, "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'3Ms4ovcT1Rtq2BExHqRbBMUeKCYmDSSGGV2')
5+
6+let lotteryTicketHub = Address(base58'3NBnUoHfxSDfoqjnDU2JGaXyK2fYJaB5JyZ')
7+
8+let lotteryAdminAddress = Address(base58'3Ms4ovcT1Rtq2BExHqRbBMUeKCYmDSSGGV2')
9+
10+let dAppRandomAddress = Address(base58'3N1aBgieFCpxDJorNX7i41KWaP974Ci9roS')
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 
19.98 ms