tx · 3eVZNBN2xzb5FjUVbhS4R7aKHULmu9kS9syKe8DSWzJL

3MzY5rPcYeDsexRLXDecfTEUXmmQjPMEMxg:  -0.01000000 Waves

2022.07.31 23:31 [2164484] smart account 3MzY5rPcYeDsexRLXDecfTEUXmmQjPMEMxg > SELF 0.00000000 Waves

{ "type": 13, "id": "3eVZNBN2xzb5FjUVbhS4R7aKHULmu9kS9syKe8DSWzJL", "fee": 1000000, "feeAssetId": null, "timestamp": 1659299615324, "version": 2, "chainId": 84, "sender": "3MzY5rPcYeDsexRLXDecfTEUXmmQjPMEMxg", "senderPublicKey": "E3sTYW6kXgYN8FDpWknNKTTQPMxPLjMPcQiB9Jz9tyz3", "proofs": [ "3nBvV1qUfZADDqdMwv83HDhJN5cT9VwYjM4hs1H3DAsrkKDQMZ8iFSRcjcXe8Sus8B3qQ8H3HUq2krhp6iFzAhkx" ], "script": "base64:BgIjCAISAwoBCBIAEgUKAwgIARIECgIIARIAEgUKAwgICBIAEgAQAAV3YXZlcwCAwtcvAA50aWNrZXRQcmljZUludADAhD0AC3RpY2tldFByaWNlBQ50aWNrZXRQcmljZUludAAGaW52RmVlAKDCHgASd2l0aGRyYXdGZWVQZXJjZW50AAUAFmZlZUNvbGxlY3RvckFkZHJlc3NLZXkCE2ZlZUNvbGxlY3RvckFkZHJlc3MADmRlcG9zaXRBc3NldElkAiw1dWUxZml1VjZqNlVCcjZYZjI4UW1zNnk1RnF6S3RxdmF4eGh3dTdoVFE1OAENdHJ5R2V0SW50ZWdlcgEDa2V5BAckbWF0Y2gwCQCaCAIFBHRoaXMFA2tleQMJAAECBQckbWF0Y2gwAgNJbnQEAWIFByRtYXRjaDAFAWIAAAESZ2V0VGlja2V0c0NvdW50S2V5AQ1hZGRyZXNzU3RyaW5nCQCsAgIFDWFkZHJlc3NTdHJpbmcCDV90aWNrZXRzQ291bnQBDWdhbWVXaW5uZXJLZXkBBmdhbWVJZAkArAICBQZnYW1lSWQCB193aW5uZXIBGGFkZHJlc3NB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AAkA9AMDCAUCdHgJYm9keUJ5dGVzCQCRAwIIBQJ0eAZwcm9vZnMAAAgFAnR4D3NlbmRlclB1YmxpY0tleSWyjhs=", "height": 2164484, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: none Next: none Full:
OldNewDifferences
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+let depositAssetId = "5ue1fiuV6j6UBr6Xf28Qms6y5FqzKtqvaxxhwu7hTQ58"
17+
18+func tryGetInteger (key) = match getInteger(this, key) {
19+ case b: Int =>
20+ b
21+ case _ =>
22+ 0
23+}
24+
25+
26+func getTicketsCountKey (addressString) = (addressString + "_ticketsCount")
27+
28+
29+func gameWinnerKey (gameId) = (gameId + "_winner")
30+
31+
32+func addressAvailableFundsKey (address) = (address + "_availableFunds")
33+
34+
35+func addressTotalLockedFundsKey (address) = (address + "_totalLockedFunds")
36+
37+
38+func addressLockedFundsForGame (address,gameId) = ((address + "_lockedFunds_") + gameId)
39+
40+
41+func addressAvailableRewardsKey (address) = (address + "_availableRewards")
42+
43+
44+func getTicketsCount (addressString) = tryGetInteger(getTicketsCountKey(addressString))
45+
46+
47+func consumeTicket (playerAddr) = {
48+ let currentTicketCount = getTicketsCount(playerAddr)
49+ let newCurrentTicketCount = (currentTicketCount - 1)
50+ if ((0 > newCurrentTicketCount))
51+ then 0
52+ else newCurrentTicketCount
53+ }
54+
55+
56+@Callable(i)
57+func setFeeCollectorAddress (collectorAddr) = if ((i.caller != this))
58+ then throw("Admin Only")
59+ else [StringEntry(feeCollectorAddressKey, collectorAddr)]
60+
61+
62+
63+@Callable(i)
64+func depositFunds () = {
65+ let pmt = if ((size(i.payments) == 1))
66+ then i.payments[0]
67+ else throw("Please attach exactly one payment")
68+ if ((pmt.assetId != fromBase58String(depositAssetId)))
69+ then throw("You can only deposit USDN")
70+ else {
71+ let callerAddrStr = toBase58String(i.caller.bytes)
72+ let currentAvailableFunds = tryGetInteger(addressAvailableFundsKey(callerAddrStr))
73+ $Tuple2([IntegerEntry(addressAvailableFundsKey(callerAddrStr), (currentAvailableFunds + pmt.amount))], 1)
74+ }
75+ }
76+
77+
78+
79+@Callable(i)
80+func playerExitGame (gameId,playerAddr,exitStackAmount) = if ((i.caller != this))
81+ then throw("Admin Only")
82+ else {
83+ let currentTotalLockedFunds = tryGetInteger(addressTotalLockedFundsKey(playerAddr))
84+ let currentAvailableFunds = tryGetInteger(addressAvailableFundsKey(playerAddr))
85+ let currentGameLockedAmountForPlayer = tryGetInteger(addressLockedFundsForGame(playerAddr, gameId))
86+ $Tuple2([IntegerEntry(addressAvailableFundsKey(playerAddr), (currentAvailableFunds + exitStackAmount)), IntegerEntry(addressTotalLockedFundsKey(playerAddr), (currentTotalLockedFunds - currentGameLockedAmountForPlayer))], 1)
87+ }
88+
89+
90+
91+@Callable(i)
92+func lockFundsForGame (gameId,amountToLock) = {
93+ let callerAddrStr = toBase58String(i.caller.bytes)
94+ let currentAvailableFunds = tryGetInteger(addressAvailableFundsKey(callerAddrStr))
95+ let currentTotalLockedFunds = tryGetInteger(addressTotalLockedFundsKey(callerAddrStr))
96+ if ((amountToLock > currentAvailableFunds))
97+ then throw("Not enough available funds to lock")
98+ else $Tuple2([IntegerEntry(addressAvailableFundsKey(callerAddrStr), (currentAvailableFunds - amountToLock)), IntegerEntry(addressTotalLockedFundsKey(callerAddrStr), (currentTotalLockedFunds + amountToLock)), IntegerEntry(addressLockedFundsForGame(callerAddrStr, gameId), amountToLock)], 1)
99+ }
100+
101+
102+
103+@Callable(i)
104+func withdrawFunds () = {
105+ let callerAddrStr = toBase58String(i.caller.bytes)
106+ let feeCollectorAddr = addressFromStringValue(getStringValue(feeCollectorAddressKey))
107+ let currentAvailableFunds = tryGetInteger(addressAvailableFundsKey(callerAddrStr))
108+ let withdrawFee = fraction(currentAvailableFunds, withdrawFeePercent, 100)
109+ let actualAvailableFunds = (currentAvailableFunds - withdrawFee)
110+ if ((0 >= actualAvailableFunds))
111+ then throw("No available funds to withdraw")
112+ else [IntegerEntry(addressAvailableFundsKey(callerAddrStr), 0), ScriptTransfer(i.caller, actualAvailableFunds, fromBase58String(depositAssetId)), ScriptTransfer(feeCollectorAddr, withdrawFee, fromBase58String(depositAssetId))]
113+ }
114+
115+
116+
117+@Callable(i)
118+func setWinnerHeadsUp (gameId,winnerAddrStr,otherPlayerAddr) = if ((i.caller != this))
119+ then throw("Admin Only")
120+ else {
121+ let availableRewardsKey = addressAvailableRewardsKey(winnerAddrStr)
122+ let currentAvailableRewards = tryGetInteger(availableRewardsKey)
123+ let newTicketCountWinner = consumeTicket(winnerAddrStr)
124+ let newTicketCountOtherPlayer = consumeTicket(otherPlayerAddr)
125+[StringEntry(gameWinnerKey(gameId), winnerAddrStr), IntegerEntry(availableRewardsKey, (currentAvailableRewards + (ticketPrice * 2))), IntegerEntry(getTicketsCountKey(winnerAddrStr), newTicketCountWinner), IntegerEntry(getTicketsCountKey(otherPlayerAddr), newTicketCountOtherPlayer)]
126+ }
127+
128+
129+
130+@Callable(i)
131+func withdrawRewards () = {
132+ let callerAddrStr = toBase58String(i.caller.bytes)
133+ let feeCollectorAddr = addressFromStringValue(getStringValue(feeCollectorAddressKey))
134+ let currentAvailableRewards = tryGetInteger(addressAvailableRewardsKey(callerAddrStr))
135+ let withdrawFee = fraction(currentAvailableRewards, withdrawFeePercent, 100)
136+ let actualAvailableRewards = ((currentAvailableRewards - invFee) - withdrawFee)
137+ if ((0 >= currentAvailableRewards))
138+ then throw("No available rewards to withdraw")
139+ else [IntegerEntry(addressAvailableRewardsKey(callerAddrStr), 0), ScriptTransfer(i.caller, actualAvailableRewards, unit), ScriptTransfer(feeCollectorAddr, withdrawFee, unit)]
140+ }
141+
142+
143+
144+@Callable(i)
145+func buyTickets () = {
146+ let pmt = if ((size(i.payments) == 1))
147+ then i.payments[0]
148+ else throw("Please attach exactly one payment")
149+ if (isDefined(pmt.assetId))
150+ then throw("Tickets can only ibe purchased in Waves")
151+ else if ((pmt.amount != ticketPrice))
152+ then throw((("The payment must be of exactly " + toString(ticketPriceInt)) + " waves"))
153+ else {
154+ let callerAddrStr = toBase58String(i.caller.bytes)
155+ let currentTicketsCount = tryGetInteger(getTicketsCountKey(callerAddrStr))
156+ $Tuple2([IntegerEntry(getTicketsCountKey(callerAddrStr), (currentTicketsCount + 1))], 1)
157+ }
158+ }
159+
160+
161+@Verifier(tx)
162+func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
163+

github/deemru/w8io/169f3d6 
21.39 ms