tx · AZfstWeg3E6hLjCj5yvkJNE35xuDbtPdqMbwAMNxZwB4

3N3JDpKdsH3U36cnofa7gR2rJGn1RskoKp9:  -0.01000000 Waves

2019.12.05 16:14 [795475] smart account 3N3JDpKdsH3U36cnofa7gR2rJGn1RskoKp9 > SELF 0.00000000 Waves

{ "type": 13, "id": "AZfstWeg3E6hLjCj5yvkJNE35xuDbtPdqMbwAMNxZwB4", "fee": 1000000, "feeAssetId": null, "timestamp": 1575551682445, "version": 1, "sender": "3N3JDpKdsH3U36cnofa7gR2rJGn1RskoKp9", "senderPublicKey": "3KQGDRDChCU4yc6LEh4He8jVZgZacdMMLXZnEKTHEHyt", "proofs": [ "2Xz2V6zAeAMpZnU1VWp1fhYmEnT1tm964rTbah2wZ7isKAGaCJpmXdYkd8cSC5Pj3VjR7BFjdWV88ZVpC3h2euV8" ], "script": "base64:AAIDAAAAAAAAAA4IARIDCgEIEgMKAQgSAAAAAAYAAAAADG93bmVyQWRkcmVzcwkBAAAAB0FkZHJlc3MAAAABAQAAABoBVCKO49UfdVacf8Y0Qj59HGp7V9voyjFs/QAAAAAJdGlja2V0SHViCQEAAAAHQWRkcmVzcwAAAAEBAAAAGgFUBsSN2A60pEr0L803rLgzH70HWvMWeUsrAAAAABNsb3R0ZXJ5QWRtaW5BZGRyZXNzCQEAAAAHQWRkcmVzcwAAAAEBAAAAGgFUf94ftL4Vg1lJrIjOemFa/6T/nk84vWbZAAAAABFkQXBwUmFuZG9tQWRkcmVzcwkBAAAAB0FkZHJlc3MAAAABAQAAABoBVH/eH7S+FYNZSayIznphWv+k/55POL1m2QAAAAAOd2l0aGRyYXdQZXJpb2QAAAAAAAAAqMABAAAAEmV4dHJhY3RSYW5kb21WYWx1ZQAAAAAEAAAAE3JlcXVlc3RDb21taXRlZFR4SWQJAQAAABFAZXh0ck5hdGl2ZSgxMDUzKQAAAAIFAAAABHRoaXMCAAAAD3JhbmRvbVJlcXVlc3RUeAQAAAAOb3JhY2xlUmVzcG9uc2UJA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QUAAAAEdGhpcwUAAAAEdW5pdAUAAAADbmlsAwMDCQAAAAAAAAIIBQAAAApjb250ZXh0T2JqAAAABmNhbGxlcgUAAAATbG90dGVyeUFkbWluQWRkcmVzcwYJAAAAAAAAAggFAAAACmNvbnRleHRPYmoAAAAGY2FsbGVyBQAAAAxvd25lckFkZHJlc3MJAABmAAAAAgUAAAAGaGVpZ2h0CQAAZAAAAAIFAAAAC3N0YXJ0SGVpZ2h0BQAAAAVtb250aAcJAQAAAAtUcmFuc2ZlclNldAAAAAEJAARMAAAAAgkBAAAADlNjcmlwdFRyYW5zZmVyAAAAAwUAAAAMb3duZXJBZGRyZXNzCQEAAAAMd2F2ZXNCYWxhbmNlAAAAAQUAAAAEdGhpcwUAAAAEdW5pdAUAAAADbmlsCQAAAgAAAAECAAAAHHlvdSBjYW4ndCB3aXRoZHJhdyB0aGUgZnVuZHMAAAAAEq65xA==", "chainId": 84, "height": 795475, "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 ticketHub = Address(base58'3MpXsHtUSpsUJRsUdVfxpcfFQzeoQyP2GHg')
7+
8+let lotteryAdminAddress = Address(base58'3N1aBgieFCpxDJorNX7i41KWaP974Ci9roS')
9+
10+let dAppRandomAddress = Address(base58'3N1aBgieFCpxDJorNX7i41KWaP974Ci9roS')
11+
12+let withdrawPeriod = 43200
13+
14+func extractRandomValue () = {
15+ let requestCommitedTxId = getStringValue(this, "randomRequestTx")
16+ let oracleResponse = getStringValue(dAppRandomAddress, requestCommitedTxId)
17+ match getInteger(this, "randomResult") {
18+ case s: Int =>
19+ toString(s)
20+ case _ =>
21+split(oracleResponse, "--")[1]
22+ }
23+ }
24+
25+
26+@Callable(contextObj)
27+func registerRandomRequestTx (randomRequestTx) = if (isDefined(getString(this, "randomRequestTx")))
28+ then throw("randomRequestTx is already in the state")
29+ else if (isDefined(transactionHeightById(fromBase58String(randomRequestTx))))
30+ then throw("You try register tx which is already in blockchain")
31+ else if ((contextObj.caller == lotteryAdminAddress))
32+ then WriteSet([DataEntry("randomRequestTx", randomRequestTx), DataEntry("startHeight", height)])
33+ else throw("only loteryOwner can start the lottery")
34+
35+
36+
37+@Callable(contextObj)
38+func defineTheWinner (ticketsInHubKey) = {
39+ let randomResultString = extractRandomValue()
40+ let randomResult = parseIntValue(randomResultString)
41+ if (isDefined(getInteger(this, "winnerTicket")))
42+ then throw("winner is already defined")
43+ else if (isDefined(getString(ticketHub, ("winningTicket" + randomResultString))))
44+ then {
45+ let ticketAmount = getIntegerValue(ticketHub, "ticketAmountTotal")
46+ let randomResultUpdate = if ((randomResult == ticketAmount))
47+ then 1
48+ else (randomResult + 1)
49+ WriteSet([DataEntry("randomResult", randomResultUpdate)])
50+ }
51+ else {
52+ let ticketFrom = parseIntValue(split(split(ticketsInHubKey, "To")[0], "ticketsFrom")[1])
53+ let ticketTo = parseIntValue(split(ticketsInHubKey, "To")[1])
54+ if (if ((randomResult >= ticketFrom))
55+ then (ticketTo >= randomResult)
56+ else false)
57+ then {
58+ let winnerAddress = getStringValue(ticketHub, ticketsInHubKey)
59+ WriteSet([DataEntry("winnerTicket", randomResult), DataEntry("winnerAddress", winnerAddress)])
60+ }
61+ else throw("these tickets didn't win")
62+ }
63+ }
64+
65+
66+
67+@Callable(contextObj)
68+func withdraw () = {
69+ let winnerAddress = addressFromStringValue(getStringValue(this, "winnerAddress"))
70+ let startHeight = getIntegerValue(this, "startHeight")
71+ let month = withdrawPeriod
72+ if (if ((contextObj.caller == winnerAddress))
73+ then ((startHeight + month) >= height)
74+ else false)
75+ then TransferSet([ScriptTransfer(winnerAddress, wavesBalance(this), unit)])
76+ else if (if (if ((contextObj.caller == lotteryAdminAddress))
77+ then true
78+ else (contextObj.caller == ownerAddress))
79+ then (height > (startHeight + month))
80+ else false)
81+ then TransferSet([ScriptTransfer(ownerAddress, wavesBalance(this), unit)])
82+ else throw("you can't withdraw the funds")
83+ }
84+
85+

github/deemru/w8io/026f985 
30.98 ms