tx · Afqz8Yp6kzoaChDERnaN9TLEeBEj6X3zCMT9XvZAWktf 3MugaWDovwskWUMov8XUjB1zsWAUSznheXZ: -0.01000000 Waves 2019.11.21 16:15 [774995] smart account 3MugaWDovwskWUMov8XUjB1zsWAUSznheXZ > SELF 0.00000000 Waves
{ "type": 13, "id": "Afqz8Yp6kzoaChDERnaN9TLEeBEj6X3zCMT9XvZAWktf", "fee": 1000000, "feeAssetId": null, "timestamp": 1574342163666, "version": 1, "sender": "3MugaWDovwskWUMov8XUjB1zsWAUSznheXZ", "senderPublicKey": "AYLh5PtxU74Z83Sdi1CZbuoXWRsubEaFw1FLQxjWDjqP", "proofs": [ "9tofnP495hX2mAPonxzQQY3HHVUWfD6ecCkUzm7GNdxdjZ3MGpZHXvofSdcidPCztkCWc5WFJ4cJTJxNhrgqqfQ" ], "script": "base64:AAIDAAAAAAAAAA4IARIDCgEIEgASAwoBCAAAAAQAAAAAEGxvdHRlcnlUaWNrZXRIdWIJAQAAAAdBZGRyZXNzAAAAAQEAAAAaAVSC55hpYARw/MBFqc24rdbL0z1qhgL8B1oAAAAADGxvdHRlcnlPd25lcgIAAAAjM011Z2FXRG92d3NrV1VNb3Y4WFVqQjF6c1dBVVN6bmhlWFoAAAAAC293bmVyUHViS2V5AQAAACCNwHO6L9pJ14g8N8Z7UpPEWTMZicTTiaTuie5VyMOsDgAAAAARZEFwcFJhbmRvbUFkZHJlc3MJAQAAAAdBZGRyZXNzAAAAAQEAAAAaAVSCOmgm+YYukYEdK0aRU3x2fI8wwLXo1f8AAAADAAAACmNvbnRleHRPYmoBAAAAF3JlZ2lzdGVyUmFuZG9tUmVxdWVzdFR4AAAAAQAAAA9yYW5kb21SZXF1ZXN0VHgDCQEAAAAJaXNEZWZpbmVkAAAAAQkABB0AAAACBQAAAAR0aGlzAgAAAA9yYW5kb21SZXF1ZXN0VHgJAAACAAAAAQIAAAAncmFuZG9tUmVxdWVzdFR4IGlzIGFscmVhZHkgaW4gdGhlIHN0YXRlAw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AAAAGaGVpZ2h0BQAAAA5oZWlnaHRFbmRMZWFzZQkAAfQAAAADCAUAAAACdHgAAAAJYm9keUJ5dGVzCQABkQAAAAIIBQAAAAJ0eAAAAAZwcm9vZnMAAAAAAAAAAAAFAAAAC293bmVyUHViS2V5BwMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAATVHJhbnNmZXJUcmFuc2FjdGlvbgQAAAABdAUAAAAHJG1hdGNoMAMJAABmAAAAAgUAAAAGaGVpZ2h0BQAAAA5oZWlnaHRFbmRMZWFzZQkAAfQAAAADCAUAAAACdHgAAAAJYm9keUJ5dGVzCQABkQAAAAIIBQAAAAJ0eAAAAAZwcm9vZnMAAAAAAAAAAAAFAAAAC293bmVyUHViS2V5BwkAAfQAAAADCAUAAAACdHgAAAAJYm9keUJ5dGVzCQABkQAAAAIIBQAAAAJ0eAAAAAZwcm9vZnMAAAAAAAAAAAAFAAAAC293bmVyUHViS2V5eJPpSQ==", "chainId": 84, "height": 774995, "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'3N1rF4PLyqW2W7f24LjoVB4AtKEVMssx31T') | |
5 | + | ||
6 | + | let lotteryOwner = "3MugaWDovwskWUMov8XUjB1zsWAUSznheXZ" | |
7 | + | ||
8 | + | let ownerPubKey = base58'AYLh5PtxU74Z83Sdi1CZbuoXWRsubEaFw1FLQxjWDjqP' | |
9 | + | ||
10 | + | let dAppRandomAddress = Address(base58'3N1nfb37S1VkVNNmhYN5F3hr6UjRs67rLar') | |
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 owner 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(ticketsInHubKey, "To")[1]) | |
49 | + | let ticketTo = parseIntValue(split(split(ticketsInHubKey, "To")[0], "ticketsFrom")[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 | + | @Verifier(tx) | |
63 | + | func verify () = { | |
64 | + | let heightStartLease = 1 | |
65 | + | let heightEndLease = 1000000000000 | |
66 | + | match tx { | |
67 | + | case l: LeaseTransaction => | |
68 | + | if (if (if ((height > heightStartLease)) | |
69 | + | then (heightEndLease > height) | |
70 | + | else false) | |
71 | + | then isDefined(getString(this, "winnerAddress")) | |
72 | + | else false) | |
73 | + | then (l.recipient == addressFromString(getStringValue(this, "winnerAddress"))) | |
74 | + | else false | |
75 | + | case lc: LeaseCancelTransaction => | |
76 | + | if ((height > heightEndLease)) | |
77 | + | then sigVerify(tx.bodyBytes, tx.proofs[0], ownerPubKey) | |
78 | + | else false | |
79 | + | case t: TransferTransaction => | |
80 | + | if ((height > heightEndLease)) | |
81 | + | then sigVerify(tx.bodyBytes, tx.proofs[0], ownerPubKey) | |
82 | + | else false | |
83 | + | case _ => | |
84 | + | sigVerify(tx.bodyBytes, tx.proofs[0], ownerPubKey) | |
85 | + | } | |
86 | + | } | |
87 | + |
github/deemru/w8io/169f3d6 15.54 ms ◑