tx · 65TyhCmJjseze6WvXstDDEZ5YvLzGcNiBJqkfFsjR3C2

3MyFXnLeXYYqkJ3ub4y56wJCHEquvQi7xK3:  -0.01000000 Waves

2022.09.12 00:43 [2224995] smart account 3MyFXnLeXYYqkJ3ub4y56wJCHEquvQi7xK3 > SELF 0.00000000 Waves

{ "type": 13, "id": "65TyhCmJjseze6WvXstDDEZ5YvLzGcNiBJqkfFsjR3C2", "fee": 1000000, "feeAssetId": null, "timestamp": 1662932670363, "version": 2, "chainId": 84, "sender": "3MyFXnLeXYYqkJ3ub4y56wJCHEquvQi7xK3", "senderPublicKey": "FjxiNm6yG2bAMJDSy72PSsGQArUNm7ynbaYFDC4sFNhi", "proofs": [ "8THiy1k1jf6sdFCrScnZNYXU8sNZE3anR5tRcWfSJr5Sv15e8vcfnS7e1hXUCXQaGkZLejNCvc6B1ud5SLJ8xxE" ], "script": "base64:BgItCAISAwoBCBIAEgMKAQgSBAoCCAgSBQoDCAgBEgMKAQgSABIFCgMICAgSABIAFQAFd2F2ZXMAgMLXLwAOdGlja2V0UHJpY2VJbnQAwIQ9AAt0aWNrZXRQcmljZQUOdGlja2V0UHJpY2VJbnQABmludkZlZQCgwh4AEndpdGhkcmF3RmVlUGVyY2VudAAFABZmZWVDb2xsZWN0b3JBZGRyZXNzS2V5AhNmZWVDb2xsZWN0b3JBZGRyZXNzAA5kZXBvc2l0QXNzZXRJZAIsNXVlMWZpdVY2ajZVQnI2WGYyOFFtczZ5NUZxekt0cXZheHhod3U3aFRRNTgBDXRyeUdldEludGVnZXIBA2tleQQHJG1hdGNoMAkAmggCBQR0aGlzBQNrZXkDCQABAgUHJG1hdGNoMAIDSW50BAFiBQckbWF0Y2gwBQFiAAABEmdldFRpY2tldHNDb3VudEtleQENYWRkcmVzc1N0cmluZwkArAICBQ1hZGRyZXNzU3RyaW5nAg1fdGlja2V0c0NvdW50ARh0b3VybmFtZW50UHJpemVBbW91bnRLZXkBDHRvdXJuYW1lbnRJZAkArAICBQx0b3Vyb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AQpidXlUaWNrZXRzAAQDcG10AwkAAAIJAJADAQgFAWkIcGF5bWVudHMAAQkAkQMCCAUBaQhwYXltZW50cwAACQACAQIhUGxlYXNlIGF0dGFjaCBleGFjdGx5IG9uZSBwYXltZW50AwkBCWlzRGVmaW5lZAEIBQNwbXQHYXNzZXRJZAkAAgECJ1RpY2tldHMgY2FuIG9ubHkgaWJlIHB1cmNoYXNlZCBpbiBXYXZlcwMJAQIhPQIIBQNwbXQGYW1vdW50BQt0aWNrZXRQcmljZQkAAgEJAKwCAgkArAICAh9UaGUgcGF5bWVudCBtdXN0IGJlIG9mIGV4YWN0bHkgCQCkAwEFDnRpY2tldFByaWNlSW50AgYgd2F2ZXMEDWNhbGxlckFkZHJTdHIJANgEAQgIBQFpBmNhbGxlcgVieXRlcwQTY3VycmVudFRpY2tldHNDb3VudAkBDXRyeUdldEludGVnZXIBCQESZ2V0VGlja2V0c0NvdW50S2V5AQUNY2FsbGVyQWRkclN0cgkAlAoCCQDMCAIJAQxJbnRlZ2VyRW50cnkCCQESZ2V0VGlja2V0c0NvdW50S2V5AQUNY2FsbGVyQWRkclN0cgkAZAIFE2N1cnJlbnRUaWNrZXRzQ291bnQAAQUDbmlsAAEBAnR4AQZ2ZXJpZnkACQD0AwMIBQJ0eAlib2R5Qnl0ZXMJAJEDAggFAnR4BnByb29mcwAACAUCdHgPc2VuZGVyUHVibGljS2V51HaL/Q==", "height": 2224995, "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 tournamentPrizeAmountKey (tournamentId) = (tournamentId + "_tournamentPrizeAmount")
30+
31+
32+func tournamentPrizeAssetIdKey (tournamentId) = (tournamentId + "_tournamentPrizeAssetId")
33+
34+
35+func tournamentStatusKey (tournamentId) = (tournamentId + "_tournamentStatus")
36+
37+
38+func tournamentWinningTransactionIdKey (tournamentId) = (tournamentId + "_tournamentWinningTransactionId")
39+
40+
41+func gameWinnerKey (gameId) = (gameId + "_winner")
42+
43+
44+func addressAvailableFundsKey (address) = (address + "_availableFunds")
45+
46+
47+func addressTotalLockedFundsKey (address) = (address + "_totalLockedFunds")
48+
49+
50+func addressLockedFundsTotalHistoryKey (address) = (address + "_lockedFundsTotalHistory")
51+
52+
53+func addressLockedFundsForGameKey (address,gameId) = ((address + "_lockedFunds_") + gameId)
54+
55+
56+func addressAvailableRewardsKey (address) = (address + "_availableRewards")
57+
58+
59+func getTicketsCount (addressString) = tryGetInteger(getTicketsCountKey(addressString))
60+
61+
62+func consumeTicket (playerAddr) = {
63+ let currentTicketCount = getTicketsCount(playerAddr)
64+ let newCurrentTicketCount = (currentTicketCount - 1)
65+ if ((0 > newCurrentTicketCount))
66+ then 0
67+ else newCurrentTicketCount
68+ }
69+
70+
71+@Callable(i)
72+func setFeeCollectorAddress (collectorAddr) = if ((i.caller != this))
73+ then throw("Admin Only")
74+ else [StringEntry(feeCollectorAddressKey, collectorAddr)]
75+
76+
77+
78+@Callable(i)
79+func depositFunds () = {
80+ let pmt = if ((size(i.payments) == 1))
81+ then i.payments[0]
82+ else throw("Please attach exactly one payment")
83+ if ((pmt.assetId != fromBase58String(depositAssetId)))
84+ then throw("You can only deposit USDN")
85+ else {
86+ let callerAddrStr = toBase58String(i.caller.bytes)
87+ let currentAvailableFunds = tryGetInteger(addressAvailableFundsKey(callerAddrStr))
88+ $Tuple2([IntegerEntry(addressAvailableFundsKey(callerAddrStr), (currentAvailableFunds + pmt.amount))], 1)
89+ }
90+ }
91+
92+
93+
94+@Callable(i)
95+func createTournament (tournamentId) = {
96+ let pmt = if ((size(i.payments) == 1))
97+ then i.payments[0]
98+ else throw("Please attach exactly one payment")
99+ let prizeAssetId = match pmt.assetId {
100+ case b: Unit =>
101+ ""
102+ case b: ByteVector =>
103+ toBase58String(b)
104+ case _ =>
105+ throw("Match error")
106+ }
107+ $Tuple2([IntegerEntry(tournamentPrizeAmountKey(tournamentId), pmt.amount), StringEntry(tournamentPrizeAssetIdKey(tournamentId), prizeAssetId), StringEntry(tournamentStatusKey(tournamentId), "registration")], 1)
108+ }
109+
110+
111+
112+@Callable(i)
113+func finishTournament (tournamentId,winningTransfertTransactionId) = if ((i.caller != this))
114+ then throw("Admin Only")
115+ else $Tuple2([StringEntry(tournamentWinningTransactionIdKey(tournamentId), winningTransfertTransactionId), StringEntry(tournamentStatusKey(tournamentId), "finished")], 1)
116+
117+
118+
119+@Callable(i)
120+func playerExitGame (gameId,playerAddr,exitStackAmount) = if ((i.caller != this))
121+ then throw("Admin Only")
122+ else {
123+ let currentTotalLockedFunds = tryGetInteger(addressTotalLockedFundsKey(playerAddr))
124+ let currentGameLockedAmountForPlayer = tryGetInteger(addressLockedFundsForGameKey(playerAddr, gameId))
125+ $Tuple2([IntegerEntry(addressTotalLockedFundsKey(playerAddr), (currentTotalLockedFunds - currentGameLockedAmountForPlayer)), IntegerEntry(addressLockedFundsForGameKey(playerAddr, gameId), 0), ScriptTransfer(addressFromStringValue(playerAddr), exitStackAmount, fromBase58String(depositAssetId))], 1)
126+ }
127+
128+
129+
130+@Callable(i)
131+func lockFundsForGame (gameId) = {
132+ let pmt = if ((size(i.payments) == 1))
133+ then i.payments[0]
134+ else throw("Please attach exactly one payment")
135+ if ((pmt.assetId != fromBase58String(depositAssetId)))
136+ then throw("You can only deposit USDN")
137+ else {
138+ let callerAddrStr = toBase58String(i.caller.bytes)
139+ let currentTotalLockedFunds = tryGetInteger(addressTotalLockedFundsKey(callerAddrStr))
140+ let currentLockedFundsTotalHistory = tryGetInteger(addressLockedFundsTotalHistoryKey(callerAddrStr))
141+ $Tuple2([IntegerEntry(addressTotalLockedFundsKey(callerAddrStr), (currentTotalLockedFunds + pmt.amount)), IntegerEntry(addressLockedFundsTotalHistoryKey(callerAddrStr), (currentLockedFundsTotalHistory + pmt.amount)), IntegerEntry(addressLockedFundsForGameKey(callerAddrStr, gameId), pmt.amount)], 1)
142+ }
143+ }
144+
145+
146+
147+@Callable(i)
148+func withdrawFunds () = {
149+ let callerAddrStr = toBase58String(i.caller.bytes)
150+ let feeCollectorAddr = addressFromStringValue(getStringValue(feeCollectorAddressKey))
151+ let currentAvailableFunds = tryGetInteger(addressAvailableFundsKey(callerAddrStr))
152+ let withdrawFee = fraction(currentAvailableFunds, withdrawFeePercent, 100)
153+ let actualAvailableFunds = (currentAvailableFunds - withdrawFee)
154+ if ((0 >= actualAvailableFunds))
155+ then throw("No available funds to withdraw")
156+ else [IntegerEntry(addressAvailableFundsKey(callerAddrStr), 0), ScriptTransfer(i.caller, actualAvailableFunds, fromBase58String(depositAssetId)), ScriptTransfer(feeCollectorAddr, withdrawFee, fromBase58String(depositAssetId))]
157+ }
158+
159+
160+
161+@Callable(i)
162+func setWinnerHeadsUp (gameId,winnerAddrStr,otherPlayerAddr) = if ((i.caller != this))
163+ then throw("Admin Only")
164+ else {
165+ let availableRewardsKey = addressAvailableRewardsKey(winnerAddrStr)
166+ let currentAvailableRewards = tryGetInteger(availableRewardsKey)
167+ let newTicketCountWinner = consumeTicket(winnerAddrStr)
168+ let newTicketCountOtherPlayer = consumeTicket(otherPlayerAddr)
169+[StringEntry(gameWinnerKey(gameId), winnerAddrStr), IntegerEntry(availableRewardsKey, (currentAvailableRewards + (ticketPrice * 2))), IntegerEntry(getTicketsCountKey(winnerAddrStr), newTicketCountWinner), IntegerEntry(getTicketsCountKey(otherPlayerAddr), newTicketCountOtherPlayer)]
170+ }
171+
172+
173+
174+@Callable(i)
175+func withdrawRewards () = {
176+ let callerAddrStr = toBase58String(i.caller.bytes)
177+ let feeCollectorAddr = addressFromStringValue(getStringValue(feeCollectorAddressKey))
178+ let currentAvailableRewards = tryGetInteger(addressAvailableRewardsKey(callerAddrStr))
179+ let withdrawFee = fraction(currentAvailableRewards, withdrawFeePercent, 100)
180+ let actualAvailableRewards = ((currentAvailableRewards - invFee) - withdrawFee)
181+ if ((0 >= currentAvailableRewards))
182+ then throw("No available rewards to withdraw")
183+ else [IntegerEntry(addressAvailableRewardsKey(callerAddrStr), 0), ScriptTransfer(i.caller, actualAvailableRewards, unit), ScriptTransfer(feeCollectorAddr, withdrawFee, unit)]
184+ }
185+
186+
187+
188+@Callable(i)
189+func buyTickets () = {
190+ let pmt = if ((size(i.payments) == 1))
191+ then i.payments[0]
192+ else throw("Please attach exactly one payment")
193+ if (isDefined(pmt.assetId))
194+ then throw("Tickets can only ibe purchased in Waves")
195+ else if ((pmt.amount != ticketPrice))
196+ then throw((("The payment must be of exactly " + toString(ticketPriceInt)) + " waves"))
197+ else {
198+ let callerAddrStr = toBase58String(i.caller.bytes)
199+ let currentTicketsCount = tryGetInteger(getTicketsCountKey(callerAddrStr))
200+ $Tuple2([IntegerEntry(getTicketsCountKey(callerAddrStr), (currentTicketsCount + 1))], 1)
201+ }
202+ }
203+
204+
205+@Verifier(tx)
206+func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
207+

github/deemru/w8io/026f985 
19.48 ms