tx · C3Ym9RyW4e5mayskLazdXQt7uQmdq43PeTwTzwekK37p 3Mq8jCLxabDjPsbZpNMUxJnvfRSmFYJ7yJk: -0.01000000 Waves 2022.07.31 01:24 [2163149] smart account 3Mq8jCLxabDjPsbZpNMUxJnvfRSmFYJ7yJk > SELF 0.00000000 Waves
{ "type": 13, "id": "C3Ym9RyW4e5mayskLazdXQt7uQmdq43PeTwTzwekK37p", "fee": 1000000, "feeAssetId": null, "timestamp": 1659219884799, "version": 2, "chainId": 84, "sender": "3Mq8jCLxabDjPsbZpNMUxJnvfRSmFYJ7yJk", "senderPublicKey": "CuyTtxbx5j3fHnZBXP3nCnLm93rcQTTfTUP1jz4dwnmH", "proofs": [ "tvPGB1LQ9qUPkswBSHXWcti7jHLwx4i7DpQwetZZrrnqDyuAihgBBBtcyKNwncSBZzXYHgvZX89pvXgor6a1cUF" ], "script": "base64:BgIWCAISAwoBCBIAEgASBQoDCAgIEgASAA0ABXdhdmVzAIDC1y8ADnRpY2tldFByaWNlSW50AMCEPQALdGlja2V0UHJpY2UFDnRpY2tldFByaWNlSW50AAZpbnZGZWUAoMIeABJ3aXRoZHJhd0ZlZVBlcmNlbnQABQAWZmVlQ29sbGVjdG9yQWRkcmVzc0tleQITZmVlQ29sbGVjdG9yQWRkcmVzcwENdHJ5R2V0SW50ZWdlcgEDa2V5BAckbWF0Y2gwCQCaCAIFBHRoaXMFA2tleQMJAAECBQckbWF0Y2gwAgNJbnQEAWIFByRtYXRjaDAFAWIAAAESZ2V0VGlja2V0c0NvdW50S2V5AQ1hZGRyZXNzU3RyaW5nCQCsAgIFDWFkZHJlc3NTdHJpbmcCDV90aWNrZXRzQ291bnQBDWdhbWVXaW5uZXJLZXkBBmdhbWVJZAkArAICBQZnYW1lSWQCB193aW5uZXIBGGFkZHJlc3NBdmFpbGFibGVGdW5kc0tleQEHYWRkcmVzcwkArAICBQdhZGRyZXNzAg9fYXZhaWxhYmxlRnVuZHMBGmFkZHJlc3NBdmFpbGFibGVSZ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lcwkAkQMCCAUCdHgGcHJvb2ZzAAAIBQJ0eA9zZW5kZXJQdWJsaWNLZXl0Kub8", "height": 2163149, "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 | + | let invFee = 500000 | |
11 | + | ||
12 | + | let withdrawFeePercent = 5 | |
13 | + | ||
14 | + | let feeCollectorAddressKey = "feeCollectorAddress" | |
15 | + | ||
16 | + | func tryGetInteger (key) = match getInteger(this, key) { | |
17 | + | case b: Int => | |
18 | + | b | |
19 | + | case _ => | |
20 | + | 0 | |
21 | + | } | |
22 | + | ||
23 | + | ||
24 | + | func getTicketsCountKey (addressString) = (addressString + "_ticketsCount") | |
25 | + | ||
26 | + | ||
27 | + | func gameWinnerKey (gameId) = (gameId + "_winner") | |
28 | + | ||
29 | + | ||
30 | + | func addressAvailableFundsKey (address) = (address + "_availableFunds") | |
31 | + | ||
32 | + | ||
33 | + | func addressAvailableRewardsKey (address) = (address + "_availableRewards") | |
34 | + | ||
35 | + | ||
36 | + | func getTicketsCount (addressString) = tryGetInteger(getTicketsCountKey(addressString)) | |
37 | + | ||
38 | + | ||
39 | + | func consumeTicket (playerAddr) = { | |
40 | + | let currentTicketCount = getTicketsCount(playerAddr) | |
41 | + | let newCurrentTicketCount = (currentTicketCount - 1) | |
42 | + | if ((0 > newCurrentTicketCount)) | |
43 | + | then 0 | |
44 | + | else newCurrentTicketCount | |
45 | + | } | |
46 | + | ||
47 | + | ||
48 | + | @Callable(i) | |
49 | + | func setFeeCollectorAddress (collectorAddr) = if ((i.caller != this)) | |
50 | + | then throw("Admin Only") | |
51 | + | else [StringEntry(feeCollectorAddressKey, collectorAddr)] | |
52 | + | ||
53 | + | ||
54 | + | ||
55 | + | @Callable(i) | |
56 | + | func depositFunds () = { | |
57 | + | let pmt = if ((size(i.payments) == 1)) | |
58 | + | then i.payments[0] | |
59 | + | else throw("Please attach exactly one payment") | |
60 | + | if (isDefined(pmt.assetId)) | |
61 | + | then throw("You can only deposit USDN") | |
62 | + | else { | |
63 | + | let callerAddrStr = toBase58String(i.caller.bytes) | |
64 | + | $Tuple2([IntegerEntry(addressAvailableFundsKey(callerAddrStr), pmt.amount)], 1) | |
65 | + | } | |
66 | + | } | |
67 | + | ||
68 | + | ||
69 | + | ||
70 | + | @Callable(i) | |
71 | + | func withdrawFunds () = { | |
72 | + | let callerAddrStr = toBase58String(i.caller.bytes) | |
73 | + | let feeCollectorAddr = addressFromStringValue(getStringValue(feeCollectorAddressKey)) | |
74 | + | let currentAvailableFunds = tryGetInteger(addressAvailableFundsKey(callerAddrStr)) | |
75 | + | let withdrawFee = fraction(currentAvailableFunds, withdrawFeePercent, 100) | |
76 | + | let actualAvailableFunds = (currentAvailableFunds - withdrawFee) | |
77 | + | if ((0 >= actualAvailableFunds)) | |
78 | + | then throw("No available funds to withdraw") | |
79 | + | else [IntegerEntry(addressAvailableFundsKey(callerAddrStr), 0), ScriptTransfer(i.caller, actualAvailableFunds, unit), ScriptTransfer(feeCollectorAddr, withdrawFee, unit)] | |
80 | + | } | |
81 | + | ||
82 | + | ||
83 | + | ||
84 | + | @Callable(i) | |
85 | + | func setWinnerHeadsUp (gameId,winnerAddrStr,otherPlayerAddr) = if ((i.caller != this)) | |
86 | + | then throw("Admin Only") | |
87 | + | else { | |
88 | + | let availableRewardsKey = addressAvailableRewardsKey(winnerAddrStr) | |
89 | + | let currentAvailableRewards = tryGetInteger(availableRewardsKey) | |
90 | + | let newTicketCountWinner = consumeTicket(winnerAddrStr) | |
91 | + | let newTicketCountOtherPlayer = consumeTicket(otherPlayerAddr) | |
92 | + | [StringEntry(gameWinnerKey(gameId), winnerAddrStr), IntegerEntry(availableRewardsKey, (currentAvailableRewards + (ticketPrice * 2))), IntegerEntry(getTicketsCountKey(winnerAddrStr), newTicketCountWinner), IntegerEntry(getTicketsCountKey(otherPlayerAddr), newTicketCountOtherPlayer)] | |
93 | + | } | |
94 | + | ||
95 | + | ||
96 | + | ||
97 | + | @Callable(i) | |
98 | + | func withdrawRewards () = { | |
99 | + | let callerAddrStr = toBase58String(i.caller.bytes) | |
100 | + | let feeCollectorAddr = addressFromStringValue(getStringValue(feeCollectorAddressKey)) | |
101 | + | let currentAvailableRewards = tryGetInteger(addressAvailableRewardsKey(callerAddrStr)) | |
102 | + | let withdrawFee = fraction(currentAvailableRewards, withdrawFeePercent, 100) | |
103 | + | let actualAvailableRewards = ((currentAvailableRewards - invFee) - withdrawFee) | |
104 | + | if ((0 >= currentAvailableRewards)) | |
105 | + | then throw("No available rewards to withdraw") | |
106 | + | else [IntegerEntry(addressAvailableRewardsKey(callerAddrStr), 0), ScriptTransfer(i.caller, actualAvailableRewards, unit), ScriptTransfer(feeCollectorAddr, withdrawFee, unit)] | |
107 | + | } | |
108 | + | ||
109 | + | ||
110 | + | ||
111 | + | @Callable(i) | |
112 | + | func buyTickets () = { | |
113 | + | let pmt = if ((size(i.payments) == 1)) | |
114 | + | then i.payments[0] | |
115 | + | else throw("Please attach exactly one payment") | |
116 | + | if (isDefined(pmt.assetId)) | |
117 | + | then throw("Tickets can only ibe purchased in Waves") | |
118 | + | else if ((pmt.amount != ticketPrice)) | |
119 | + | then throw((("The payment must be of exactly " + toString(ticketPriceInt)) + " waves")) | |
120 | + | else { | |
121 | + | let callerAddrStr = toBase58String(i.caller.bytes) | |
122 | + | let currentTicketsCount = tryGetInteger(getTicketsCountKey(callerAddrStr)) | |
123 | + | $Tuple2([IntegerEntry(getTicketsCountKey(callerAddrStr), (currentTicketsCount + 1))], 1) | |
124 | + | } | |
125 | + | } | |
126 | + | ||
127 | + | ||
128 | + | @Verifier(tx) | |
129 | + | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
130 | + |
github/deemru/w8io/169f3d6 17.98 ms ◑