tx · DeqC5myYHUVZNQJVjeEizHP5h3fn99KWZcLbVWR9WxvN 3N6NcqW6gxZoSLUNH4VK85DGMA5uenu4coG: -0.01000000 Waves 2022.07.08 00:01 [2129798] smart account 3N6NcqW6gxZoSLUNH4VK85DGMA5uenu4coG > SELF 0.00000000 Waves
{ "type": 13, "id": "DeqC5myYHUVZNQJVjeEizHP5h3fn99KWZcLbVWR9WxvN", "fee": 1000000, "feeAssetId": null, "timestamp": 1657227703587, "version": 2, "chainId": 84, "sender": "3N6NcqW6gxZoSLUNH4VK85DGMA5uenu4coG", "senderPublicKey": "E1hzWCdpcJXEQDcxVnazfZ1fPk56UCFfCqUoMAyLQC53", "proofs": [ "3gfvZqU7mmN6HZEWv5F3FKrTPd3vGohwdtJtgmyq8YbCY7ZMBE89GaVgruSyRMEpGaFy8bxKsHVRgqnzcf6G7Neu" ], "script": "base64:BgINCAISBQoDCAgIEgASAAkABXdhdmVzAIDC1y8ADnRpY2tldFByaWNlSW50AMCEPQALdGlja2V0UHJpY2UFDnRpY2tldFByaWNlSW50AQ10cnlHZXRJbnRlZ2VyAQNrZXkEByRtYXRjaDAJAJoIAgUEdGhpcwUDa2V5AwkAAQIFByRtYXRjaDACA0ludAQBYgUHJG1hdGNoMAUBYgAAARJnZXRUaWNrZXRzQ291bnRLZXkBDWFkZHJlc3NTdHJpbmcJAKwCAgUNYWRkcmVzc1N0cmluZwINX3RpY2tldHNDb3VudAENZ2FtZVdpbm5lcktleQEGZ2FtZUlkCQCsAgIFBmdhbWVJZAIHX3dpbm5lcgEaYWRkcmVzc0F2YWlsYWJsZVJld2FyZHNLZXkBB2FkZHJlc3MJAKwCAgUHYWRkcmVzcwIRX2F2YWlsYWJsZVJld2FyZHMBD2dldFRpY2tldHNDb3VudAENYWRkcmVzc1N0cmluZwkBDXRyeUdldEludGVnZXIBCQESZ2V0VGlja2V0c0NvdW50S2V5AQUNYWRkcmVzc1N0cmluZwENY29uc3VtZVRpY2tldAEKcGxheWVyQWRkcgQS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N0cgkAZAIFE2N1cnJlbnRUaWNrZXRzQ291bnQAAQUDbmlsAAEBAnR4AQZ2ZXJpZnkACQD0AwMIBQJ0eAlib2R5Qnl0ZXMJAJEDAggFAnR4BnByb29mcwAACAUCdHgPc2VuZGVyUHVibGljS2V5CyRiMg==", "height": 2129798, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: none Next: none Full:
Old | New | Differences | |
---|---|---|---|
1 | - | # no script | |
1 | + | {-# STDLIB_VERSION 6 #-} | |
2 | + | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | + | {-# CONTENT_TYPE DAPP #-} | |
4 | + | let waves = 100000000 | |
5 | + | ||
6 | + | let ticketPriceInt = 1000000 | |
7 | + | ||
8 | + | let ticketPrice = ticketPriceInt | |
9 | + | ||
10 | + | func tryGetInteger (key) = match getInteger(this, key) { | |
11 | + | case b: Int => | |
12 | + | b | |
13 | + | case _ => | |
14 | + | 0 | |
15 | + | } | |
16 | + | ||
17 | + | ||
18 | + | func getTicketsCountKey (addressString) = (addressString + "_ticketsCount") | |
19 | + | ||
20 | + | ||
21 | + | func gameWinnerKey (gameId) = (gameId + "_winner") | |
22 | + | ||
23 | + | ||
24 | + | func addressAvailableRewardsKey (address) = (address + "_availableRewards") | |
25 | + | ||
26 | + | ||
27 | + | func getTicketsCount (addressString) = tryGetInteger(getTicketsCountKey(addressString)) | |
28 | + | ||
29 | + | ||
30 | + | func consumeTicket (playerAddr) = { | |
31 | + | let currentTicketCount = getTicketsCount(playerAddr) | |
32 | + | let newCurrentTicketCount = (currentTicketCount - 1) | |
33 | + | if ((0 > newCurrentTicketCount)) | |
34 | + | then 0 | |
35 | + | else newCurrentTicketCount | |
36 | + | } | |
37 | + | ||
38 | + | ||
39 | + | @Callable(i) | |
40 | + | func setWinnerHeadsUp (gameId,winnerAddrStr,otherPlayerAddr) = if ((i.caller != this)) | |
41 | + | then throw("Admin Only") | |
42 | + | else { | |
43 | + | let availableRewardsKey = addressAvailableRewardsKey(winnerAddrStr) | |
44 | + | let currentAvailableRewards = tryGetInteger(availableRewardsKey) | |
45 | + | let newTicketCountWinner = consumeTicket(winnerAddrStr) | |
46 | + | let newTicketCountOtherPlayer = consumeTicket(otherPlayerAddr) | |
47 | + | [StringEntry(gameWinnerKey(gameId), winnerAddrStr), IntegerEntry(availableRewardsKey, (currentAvailableRewards + (ticketPrice * 2))), IntegerEntry(getTicketsCountKey(winnerAddrStr), newTicketCountWinner), IntegerEntry(getTicketsCountKey(otherPlayerAddr), newTicketCountOtherPlayer)] | |
48 | + | } | |
49 | + | ||
50 | + | ||
51 | + | ||
52 | + | @Callable(i) | |
53 | + | func withdrawRewards () = { | |
54 | + | let callerAddrStr = toBase58String(i.caller.bytes) | |
55 | + | let currentAvailableRewards = tryGetInteger(addressAvailableRewardsKey(callerAddrStr)) | |
56 | + | if ((0 >= currentAvailableRewards)) | |
57 | + | then throw("No available rewards to withdraw") | |
58 | + | else [IntegerEntry(addressAvailableRewardsKey(callerAddrStr), 0), ScriptTransfer(i.caller, currentAvailableRewards, unit)] | |
59 | + | } | |
60 | + | ||
61 | + | ||
62 | + | ||
63 | + | @Callable(i) | |
64 | + | func buyTickets () = { | |
65 | + | let pmt = if ((size(i.payments) == 1)) | |
66 | + | then i.payments[0] | |
67 | + | else throw("Please attach exactly one payment") | |
68 | + | if (isDefined(pmt.assetId)) | |
69 | + | then throw("Tickets can only ibe purchased in Waves") | |
70 | + | else if ((pmt.amount != ticketPrice)) | |
71 | + | then throw((("The payment must be of exactly " + toString(ticketPriceInt)) + " waves")) | |
72 | + | else { | |
73 | + | let callerAddrStr = toBase58String(i.caller.bytes) | |
74 | + | let currentTicketsCount = tryGetInteger(getTicketsCountKey(callerAddrStr)) | |
75 | + | $Tuple2([IntegerEntry(getTicketsCountKey(callerAddrStr), (currentTicketsCount + 1))], 1) | |
76 | + | } | |
77 | + | } | |
78 | + | ||
79 | + | ||
80 | + | @Verifier(tx) | |
81 | + | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
82 | + |
github/deemru/w8io/169f3d6 25.31 ms ◑