tx · DmPVrnTDS4vjZWtCZmeKVdTPHttJ2uG9PZJ7ST5rWWjS 3MyiV6o2LFnsoyTfoA2wbNy4vGSqCqNc3Vp: -0.01000000 Waves 2022.07.31 00:58 [2163126] smart account 3MyiV6o2LFnsoyTfoA2wbNy4vGSqCqNc3Vp > SELF 0.00000000 Waves
{ "type": 13, "id": "DmPVrnTDS4vjZWtCZmeKVdTPHttJ2uG9PZJ7ST5rWWjS", "fee": 1000000, "feeAssetId": null, "timestamp": 1659218395310, "version": 2, "chainId": 84, "sender": "3MyiV6o2LFnsoyTfoA2wbNy4vGSqCqNc3Vp", "senderPublicKey": "2vjjM7MyWP2NThGs81A3c1dG5yBFP5RkHYjMRtGV9ard", "proofs": [ "3w1F7mUo5c2VW7wWvLAWXFF46uvvrTVUPPZAKvN3Y2itVDC6Rwr5oHngDEJ9KWt7bnpSiLjfrtbnNugFEDDF3z2W" ], "script": "base64:BgIUCAISAwoBCBIAEgUKAwgICBIAEgANAAV3YXZlcwCAwtcvAA50aWNrZXRQcmljZUludADAhD0AC3RpY2tldFByaWNlBQ50aWNrZXRQcmljZUludAAGaW52RmVlAKDCHgASd2l0aGRyYXdGZWVQZXJjZW50AAUAFmZlZUNvbGxlY3RvckFkZHJlc3NLZXkCE2ZlZUNvbGxlY3RvckFkZHJlc3MBDXRyeUdldEludGVnZXIBA2tleQQHJG1hdGNoMAkAmggCBQR0aGlzBQNrZXkDCQABAgUHJG1hdGNoMAIDSW50BAFiBQckbWF0Y2gwBQFiAAABEmdldFRpY2tldHNDb3VudEtleQENYWRkcmVzc1N0cmluZwkArAICBQ1hZGRyZXNzU3RyaW5nAg1fdGlja2V0c0NvdW50AQ1nYW1lV2lubmVyS2V5AQZnYW1lSWQJAKwCAgUGZ2FtZUlkAgdfd2lubmVyARhhZGRyZXNzQXZhaWxhYmxlRnVuZHNLZXkBB2FkZHJlc3MJAKwCAgUHYWRkcmVzcwIPX2F2YWlsYWJsZUZ1bmRzARphZGRyZXNzQXZhaWxhY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bnQJAQ10cnlHZXRJbnRlZ2VyAQkBEmdldFRpY2tldHNDb3VudEtleQEFDWNhbGxlckFkZHJTdHIJAJQKAgkAzAgCCQEMSW50ZWdlckVudHJ5AgkBEmdldFRpY2tldHNDb3VudEtleQEFDWNhbGxlckFkZHJTdHIJAGQCBRNjdXJyZW50VGlja2V0c0NvdW50AAEFA25pbAABAQJ0eAEGdmVyaWZ5AAkA9AMDCAUCdHgJYm9keUJ5dGVzCQCRAwIIBQJ0eAZwcm9vZnMAAAgFAnR4D3NlbmRlclB1YmxpY0tleascQtQ=", "height": 2163126, "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 setWinnerHeadsUp (gameId,winnerAddrStr,otherPlayerAddr) = if ((i.caller != this)) | |
72 | + | then throw("Admin Only") | |
73 | + | else { | |
74 | + | let availableRewardsKey = addressAvailableRewardsKey(winnerAddrStr) | |
75 | + | let currentAvailableRewards = tryGetInteger(availableRewardsKey) | |
76 | + | let newTicketCountWinner = consumeTicket(winnerAddrStr) | |
77 | + | let newTicketCountOtherPlayer = consumeTicket(otherPlayerAddr) | |
78 | + | [StringEntry(gameWinnerKey(gameId), winnerAddrStr), IntegerEntry(availableRewardsKey, (currentAvailableRewards + (ticketPrice * 2))), IntegerEntry(getTicketsCountKey(winnerAddrStr), newTicketCountWinner), IntegerEntry(getTicketsCountKey(otherPlayerAddr), newTicketCountOtherPlayer)] | |
79 | + | } | |
80 | + | ||
81 | + | ||
82 | + | ||
83 | + | @Callable(i) | |
84 | + | func withdrawRewards () = { | |
85 | + | let callerAddrStr = toBase58String(i.caller.bytes) | |
86 | + | let feeCollectorAddr = addressFromStringValue(getStringValue(feeCollectorAddressKey)) | |
87 | + | let currentAvailableRewards = tryGetInteger(addressAvailableRewardsKey(callerAddrStr)) | |
88 | + | let withdrawFee = fraction(currentAvailableRewards, withdrawFeePercent, 100) | |
89 | + | let actualAvailableRewards = ((currentAvailableRewards - invFee) - withdrawFee) | |
90 | + | if ((0 >= currentAvailableRewards)) | |
91 | + | then throw("No available rewards to withdraw") | |
92 | + | else [IntegerEntry(addressAvailableRewardsKey(callerAddrStr), 0), ScriptTransfer(i.caller, actualAvailableRewards, unit), ScriptTransfer(feeCollectorAddr, withdrawFee, unit)] | |
93 | + | } | |
94 | + | ||
95 | + | ||
96 | + | ||
97 | + | @Callable(i) | |
98 | + | func buyTickets () = { | |
99 | + | let pmt = if ((size(i.payments) == 1)) | |
100 | + | then i.payments[0] | |
101 | + | else throw("Please attach exactly one payment") | |
102 | + | if (isDefined(pmt.assetId)) | |
103 | + | then throw("Tickets can only ibe purchased in Waves") | |
104 | + | else if ((pmt.amount != ticketPrice)) | |
105 | + | then throw((("The payment must be of exactly " + toString(ticketPriceInt)) + " waves")) | |
106 | + | else { | |
107 | + | let callerAddrStr = toBase58String(i.caller.bytes) | |
108 | + | let currentTicketsCount = tryGetInteger(getTicketsCountKey(callerAddrStr)) | |
109 | + | $Tuple2([IntegerEntry(getTicketsCountKey(callerAddrStr), (currentTicketsCount + 1))], 1) | |
110 | + | } | |
111 | + | } | |
112 | + | ||
113 | + | ||
114 | + | @Verifier(tx) | |
115 | + | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
116 | + |
github/deemru/w8io/169f3d6 27.53 ms ◑