tx · 9JYKWaPS6XB8LUzaGmP2oLMuA42DSvexEXnczxrtBWmF 3N3dmyiBdj7pmjnQrzTTvmfzKSqndSzCMmk: -0.00500000 Waves 2022.07.31 01:39 [2163167] smart account 3N3dmyiBdj7pmjnQrzTTvmfzKSqndSzCMmk > SELF 0.00000000 Waves
{ "type": 13, "id": "9JYKWaPS6XB8LUzaGmP2oLMuA42DSvexEXnczxrtBWmF", "fee": 500000, "feeAssetId": null, "timestamp": 1659220877337, "version": 2, "chainId": 84, "sender": "3N3dmyiBdj7pmjnQrzTTvmfzKSqndSzCMmk", "senderPublicKey": "AR4BeE6hYADMvKxgRQs4ADN3krEqb2j8WE3WfJxzL3zE", "proofs": [ "4ko88WWLkQBTXk14mPczLaGerW6Eos6cY4GBJorLqctHB8Lox7vkAw7szMzvqdxDhv45TKn6xMzEQVYWnnNQp4Nj" ], "script": "base64:BgIcCAISAwoBCBIAEgQKAggBEgASBQoDCAgIEgASAA8ABXdhdmVzAIDC1y8ADnRpY2tldFByaWNlSW50AMCEPQALdGlja2V0UHJpY2UFDnRpY2tldFByaWNlSW50AAZpbnZGZWUAoMIeABJ3aXRoZHJhd0ZlZVBlcmNlbnQABQAWZmVlQ29sbGVjdG9yQWRkcmVzc0tleQITZmVlQ29sbGVjdG9yQWRkcmVzcwENdHJ5R2V0SW50ZWdlcgEDa2V5BAckbWF0Y2gwCQCaCAIFBHRoaXMFA2tleQMJAAECBQckbWF0Y2gwAgNJbnQEAWIFByRtYXRjaDAFAWIAAAESZ2V0VGlja2V0c0NvdW50S2V5AQ1hZGRyZXNzU3RyaW5nCQCsAgIFDWFkZHJlc3NTdHJpbmcCDV90aWNrZXRzQ291bnQBDWdhbWVXaW5uZXJLZXkBBmdhbWVJZAkArAICBQZnYW1lSWQCB193aW5uZXIBGGFkZHJlc3NBdmFpbGFibGVGdW5kc0tleQEHYWRkcmVzcwkArAICBQdhZGRyZXNzAg9fYXZhaWxhYmxlRnVuZHMBGmFkZHJlc3NUb3RhbExvY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ZXMJAJEDAggFAnR4BnByb29mcwAACAUCdHgPc2VuZGVyUHVibGljS2V5cRk3ng==", "height": 2163167, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: BFPQYPEHQ8S5prJqM48KBJEP3QA8RbTaLGvvgH46qqEp Next: D7jnBhUFhJ2cbCEEHRXR6wcBdVX587wXSiaQ2B1URxSW Diff:
Old | New | Differences | |
---|---|---|---|
28 | 28 | ||
29 | 29 | ||
30 | 30 | func addressAvailableFundsKey (address) = (address + "_availableFunds") | |
31 | + | ||
32 | + | ||
33 | + | func addressTotalLockedFundsKey (address) = (address + "_totalLockedFunds") | |
34 | + | ||
35 | + | ||
36 | + | func addressLockedFundsForGame (address,gameId) = ((address + "_LockedFunds_") + gameId) | |
31 | 37 | ||
32 | 38 | ||
33 | 39 | func addressAvailableRewardsKey (address) = (address + "_availableRewards") | |
63 | 69 | let callerAddrStr = toBase58String(i.caller.bytes) | |
64 | 70 | $Tuple2([IntegerEntry(addressAvailableFundsKey(callerAddrStr), pmt.amount)], 1) | |
65 | 71 | } | |
72 | + | } | |
73 | + | ||
74 | + | ||
75 | + | ||
76 | + | @Callable(i) | |
77 | + | func lockFundsForGame (gameId,amountToLock) = { | |
78 | + | let callerAddrStr = toBase58String(i.caller.bytes) | |
79 | + | let currentAvailableFunds = tryGetInteger(addressAvailableFundsKey(callerAddrStr)) | |
80 | + | let currentTotalLockedFunds = tryGetInteger(addressTotalLockedFundsKey(callerAddrStr)) | |
81 | + | if ((amountToLock > currentAvailableFunds)) | |
82 | + | then throw("Not enough available funds to lock") | |
83 | + | else $Tuple2([IntegerEntry(addressAvailableFundsKey(callerAddrStr), (currentAvailableFunds - amountToLock)), IntegerEntry(addressTotalLockedFundsKey(callerAddrStr), (currentTotalLockedFunds + amountToLock)), IntegerEntry(addressLockedFundsForGame(callerAddrStr, gameId), amountToLock)], 1) | |
66 | 84 | } | |
67 | 85 | ||
68 | 86 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let waves = 100000000 | |
5 | 5 | ||
6 | 6 | let ticketPriceInt = 1000000 | |
7 | 7 | ||
8 | 8 | let ticketPrice = ticketPriceInt | |
9 | 9 | ||
10 | 10 | let invFee = 500000 | |
11 | 11 | ||
12 | 12 | let withdrawFeePercent = 5 | |
13 | 13 | ||
14 | 14 | let feeCollectorAddressKey = "feeCollectorAddress" | |
15 | 15 | ||
16 | 16 | func tryGetInteger (key) = match getInteger(this, key) { | |
17 | 17 | case b: Int => | |
18 | 18 | b | |
19 | 19 | case _ => | |
20 | 20 | 0 | |
21 | 21 | } | |
22 | 22 | ||
23 | 23 | ||
24 | 24 | func getTicketsCountKey (addressString) = (addressString + "_ticketsCount") | |
25 | 25 | ||
26 | 26 | ||
27 | 27 | func gameWinnerKey (gameId) = (gameId + "_winner") | |
28 | 28 | ||
29 | 29 | ||
30 | 30 | func addressAvailableFundsKey (address) = (address + "_availableFunds") | |
31 | + | ||
32 | + | ||
33 | + | func addressTotalLockedFundsKey (address) = (address + "_totalLockedFunds") | |
34 | + | ||
35 | + | ||
36 | + | func addressLockedFundsForGame (address,gameId) = ((address + "_LockedFunds_") + gameId) | |
31 | 37 | ||
32 | 38 | ||
33 | 39 | func addressAvailableRewardsKey (address) = (address + "_availableRewards") | |
34 | 40 | ||
35 | 41 | ||
36 | 42 | func getTicketsCount (addressString) = tryGetInteger(getTicketsCountKey(addressString)) | |
37 | 43 | ||
38 | 44 | ||
39 | 45 | func consumeTicket (playerAddr) = { | |
40 | 46 | let currentTicketCount = getTicketsCount(playerAddr) | |
41 | 47 | let newCurrentTicketCount = (currentTicketCount - 1) | |
42 | 48 | if ((0 > newCurrentTicketCount)) | |
43 | 49 | then 0 | |
44 | 50 | else newCurrentTicketCount | |
45 | 51 | } | |
46 | 52 | ||
47 | 53 | ||
48 | 54 | @Callable(i) | |
49 | 55 | func setFeeCollectorAddress (collectorAddr) = if ((i.caller != this)) | |
50 | 56 | then throw("Admin Only") | |
51 | 57 | else [StringEntry(feeCollectorAddressKey, collectorAddr)] | |
52 | 58 | ||
53 | 59 | ||
54 | 60 | ||
55 | 61 | @Callable(i) | |
56 | 62 | func depositFunds () = { | |
57 | 63 | let pmt = if ((size(i.payments) == 1)) | |
58 | 64 | then i.payments[0] | |
59 | 65 | else throw("Please attach exactly one payment") | |
60 | 66 | if (isDefined(pmt.assetId)) | |
61 | 67 | then throw("You can only deposit USDN") | |
62 | 68 | else { | |
63 | 69 | let callerAddrStr = toBase58String(i.caller.bytes) | |
64 | 70 | $Tuple2([IntegerEntry(addressAvailableFundsKey(callerAddrStr), pmt.amount)], 1) | |
65 | 71 | } | |
72 | + | } | |
73 | + | ||
74 | + | ||
75 | + | ||
76 | + | @Callable(i) | |
77 | + | func lockFundsForGame (gameId,amountToLock) = { | |
78 | + | let callerAddrStr = toBase58String(i.caller.bytes) | |
79 | + | let currentAvailableFunds = tryGetInteger(addressAvailableFundsKey(callerAddrStr)) | |
80 | + | let currentTotalLockedFunds = tryGetInteger(addressTotalLockedFundsKey(callerAddrStr)) | |
81 | + | if ((amountToLock > currentAvailableFunds)) | |
82 | + | then throw("Not enough available funds to lock") | |
83 | + | else $Tuple2([IntegerEntry(addressAvailableFundsKey(callerAddrStr), (currentAvailableFunds - amountToLock)), IntegerEntry(addressTotalLockedFundsKey(callerAddrStr), (currentTotalLockedFunds + amountToLock)), IntegerEntry(addressLockedFundsForGame(callerAddrStr, gameId), amountToLock)], 1) | |
66 | 84 | } | |
67 | 85 | ||
68 | 86 | ||
69 | 87 | ||
70 | 88 | @Callable(i) | |
71 | 89 | func withdrawFunds () = { | |
72 | 90 | let callerAddrStr = toBase58String(i.caller.bytes) | |
73 | 91 | let feeCollectorAddr = addressFromStringValue(getStringValue(feeCollectorAddressKey)) | |
74 | 92 | let currentAvailableFunds = tryGetInteger(addressAvailableFundsKey(callerAddrStr)) | |
75 | 93 | let withdrawFee = fraction(currentAvailableFunds, withdrawFeePercent, 100) | |
76 | 94 | let actualAvailableFunds = (currentAvailableFunds - withdrawFee) | |
77 | 95 | if ((0 >= actualAvailableFunds)) | |
78 | 96 | then throw("No available funds to withdraw") | |
79 | 97 | else [IntegerEntry(addressAvailableFundsKey(callerAddrStr), 0), ScriptTransfer(i.caller, actualAvailableFunds, unit), ScriptTransfer(feeCollectorAddr, withdrawFee, unit)] | |
80 | 98 | } | |
81 | 99 | ||
82 | 100 | ||
83 | 101 | ||
84 | 102 | @Callable(i) | |
85 | 103 | func setWinnerHeadsUp (gameId,winnerAddrStr,otherPlayerAddr) = if ((i.caller != this)) | |
86 | 104 | then throw("Admin Only") | |
87 | 105 | else { | |
88 | 106 | let availableRewardsKey = addressAvailableRewardsKey(winnerAddrStr) | |
89 | 107 | let currentAvailableRewards = tryGetInteger(availableRewardsKey) | |
90 | 108 | let newTicketCountWinner = consumeTicket(winnerAddrStr) | |
91 | 109 | let newTicketCountOtherPlayer = consumeTicket(otherPlayerAddr) | |
92 | 110 | [StringEntry(gameWinnerKey(gameId), winnerAddrStr), IntegerEntry(availableRewardsKey, (currentAvailableRewards + (ticketPrice * 2))), IntegerEntry(getTicketsCountKey(winnerAddrStr), newTicketCountWinner), IntegerEntry(getTicketsCountKey(otherPlayerAddr), newTicketCountOtherPlayer)] | |
93 | 111 | } | |
94 | 112 | ||
95 | 113 | ||
96 | 114 | ||
97 | 115 | @Callable(i) | |
98 | 116 | func withdrawRewards () = { | |
99 | 117 | let callerAddrStr = toBase58String(i.caller.bytes) | |
100 | 118 | let feeCollectorAddr = addressFromStringValue(getStringValue(feeCollectorAddressKey)) | |
101 | 119 | let currentAvailableRewards = tryGetInteger(addressAvailableRewardsKey(callerAddrStr)) | |
102 | 120 | let withdrawFee = fraction(currentAvailableRewards, withdrawFeePercent, 100) | |
103 | 121 | let actualAvailableRewards = ((currentAvailableRewards - invFee) - withdrawFee) | |
104 | 122 | if ((0 >= currentAvailableRewards)) | |
105 | 123 | then throw("No available rewards to withdraw") | |
106 | 124 | else [IntegerEntry(addressAvailableRewardsKey(callerAddrStr), 0), ScriptTransfer(i.caller, actualAvailableRewards, unit), ScriptTransfer(feeCollectorAddr, withdrawFee, unit)] | |
107 | 125 | } | |
108 | 126 | ||
109 | 127 | ||
110 | 128 | ||
111 | 129 | @Callable(i) | |
112 | 130 | func buyTickets () = { | |
113 | 131 | let pmt = if ((size(i.payments) == 1)) | |
114 | 132 | then i.payments[0] | |
115 | 133 | else throw("Please attach exactly one payment") | |
116 | 134 | if (isDefined(pmt.assetId)) | |
117 | 135 | then throw("Tickets can only ibe purchased in Waves") | |
118 | 136 | else if ((pmt.amount != ticketPrice)) | |
119 | 137 | then throw((("The payment must be of exactly " + toString(ticketPriceInt)) + " waves")) | |
120 | 138 | else { | |
121 | 139 | let callerAddrStr = toBase58String(i.caller.bytes) | |
122 | 140 | let currentTicketsCount = tryGetInteger(getTicketsCountKey(callerAddrStr)) | |
123 | 141 | $Tuple2([IntegerEntry(getTicketsCountKey(callerAddrStr), (currentTicketsCount + 1))], 1) | |
124 | 142 | } | |
125 | 143 | } | |
126 | 144 | ||
127 | 145 | ||
128 | 146 | @Verifier(tx) | |
129 | 147 | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
130 | 148 |
github/deemru/w8io/169f3d6 27.81 ms ◑