tx · 2sdEjgd8AdujWEJSgNHpwR4TQMrXXPVXgndUxE4vNW4f

3My4eUKeXJ96GouuSpcxPG2wJ3JXUp4esm5:  -0.01000000 Waves

2022.07.12 00:17 [2135606] smart account 3My4eUKeXJ96GouuSpcxPG2wJ3JXUp4esm5 > SELF 0.00000000 Waves

{ "type": 13, "id": "2sdEjgd8AdujWEJSgNHpwR4TQMrXXPVXgndUxE4vNW4f", "fee": 1000000, "feeAssetId": null, "timestamp": 1657574292013, "version": 2, "chainId": 84, "sender": "3My4eUKeXJ96GouuSpcxPG2wJ3JXUp4esm5", "senderPublicKey": "EDYdCWxjxRLLMu2VrTTUTwhsgjecLCAFyKyaZ4QT1YAU", "proofs": [ "3GUD9rS1u4nnpa8HsQzx3NETVasEw7hQbgjqCFFYg5a35T1QLgxTh3DjWNoS6SB7MYc6jn9efQNWxKMwUyjJEvrh" ], "script": "base64:BgISCAISAwoBCBIFCgMICAgSABIADAAFd2F2ZXMAgMLXLwAOdGlja2V0UHJpY2VJbnQAwIQ9AAt0aWNrZXRQcmljZQUOdGlja2V0UHJpY2VJbnQABmludkZlZQDQhgMAEndpdGhkcmF3RmVlUGVyY2VudAAFABZmZWVDb2xsZWN0b3JBZGRyZXNzS2V5AhNmZWVDb2xsZWN0b3JBZGRyZXNzAQ10cnlHZXRJbnRlZ2VyAQNrZXkEByRtYXRjaDAJAJoIAgUEdGhpcwUDa2V5AwkAAQIFByRtYXRjaDACA0ludAQBYgUHJG1hdGNoMAUBYgAAARJnZXRUaWNrZXRzQ291bnRLZXkBDWFkZHJlc3NTdHJpbmcJAKwCAgUNYWRkcmVzc1N0cmluZwINX3RpY2tldHNDb3VudAENZ2FtZVdpbm5lcktleQEGZ2FtZUlkCQCsAgIFBmdhbWVJZAIHX3dpbm5lcgEaYWRkcmVzc0F2YWlsYWJsZVJld2FyZHNLZXkBB2FkZHJlc3MJAKwCAgUHYWRkcmVzcwIRX2F2YWlsYWJsZVJld2FyZHMBD2dldFRpY2tldHNDb3V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2xsZWN0b3JBZGRyZXNzS2V5BQt3aXRoZHJhd0ZlZQUEdW5pdAUDbmlsAWkBCmJ1eVRpY2tldHMABANwbXQDCQAAAgkAkAMBCAUBaQhwYXltZW50cwABCQCRAwIIBQFpCHBheW1lbnRzAAAJAAIBAiFQbGVhc2UgYXR0YWNoIGV4YWN0bHkgb25lIHBheW1lbnQDCQEJaXNEZWZpbmVkAQgFA3BtdAdhc3NldElkCQACAQInVGlja2V0cyBjYW4gb25seSBpYmUgcHVyY2hhc2VkIGluIFdhdmVzAwkBAiE9AggFA3BtdAZhbW91bnQFC3RpY2tldFByaWNlCQACAQkArAICCQCsAgICH1RoZSBwYXltZW50IG11c3QgYmUgb2YgZXhhY3RseSAJAKQDAQUOdGlja2V0UHJpY2VJbnQCBiB3YXZlcwQNY2FsbGVyQWRkclN0cgkA2AQBCAgFAWkGY2FsbGVyBWJ5dGVzBBNjdXJyZW50VGlja2V0c0NvdW50CQENdHJ5R2V0SW50ZWdlcgEJARJnZXRUaWNrZXRzQ291bnRLZXkBBQ1jYWxsZXJBZGRyU3RyCQCUCgIJAMwIAgkBDEludGVnZXJFbnRyeQIJARJnZXRUaWNrZXRzQ291bnRLZXkBBQ1jYWxsZXJBZGRyU3RyCQBkAgUTY3VycmVudFRpY2tldHNDb3VudAABBQNuaWwAAQECdHgBBnZlcmlmeQAJAPQDAwgFAnR4CWJvZHlCeXRlcwkAkQMCCAUCdHgGcHJvb2ZzAAAIBQJ0eA9zZW5kZXJQdWJsaWNLZXm4EVwM", "height": 2135606, "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 = 50000
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 addressAvailableRewardsKey (address) = (address + "_availableRewards")
31+
32+
33+func getTicketsCount (addressString) = tryGetInteger(getTicketsCountKey(addressString))
34+
35+
36+func consumeTicket (playerAddr) = {
37+ let currentTicketCount = getTicketsCount(playerAddr)
38+ let newCurrentTicketCount = (currentTicketCount - 1)
39+ if ((0 > newCurrentTicketCount))
40+ then 0
41+ else newCurrentTicketCount
42+ }
43+
44+
45+@Callable(i)
46+func setFeeCollectorAddress (collectorAddr) = if ((i.caller != this))
47+ then throw("Admin Only")
48+ else [StringEntry(feeCollectorAddressKey, collectorAddr)]
49+
50+
51+
52+@Callable(i)
53+func setWinnerHeadsUp (gameId,winnerAddrStr,otherPlayerAddr) = if ((i.caller != this))
54+ then throw("Admin Only")
55+ else {
56+ let availableRewardsKey = addressAvailableRewardsKey(winnerAddrStr)
57+ let currentAvailableRewards = tryGetInteger(availableRewardsKey)
58+ let newTicketCountWinner = consumeTicket(winnerAddrStr)
59+ let newTicketCountOtherPlayer = consumeTicket(otherPlayerAddr)
60+[StringEntry(gameWinnerKey(gameId), winnerAddrStr), IntegerEntry(availableRewardsKey, (currentAvailableRewards + (ticketPrice * 2))), IntegerEntry(getTicketsCountKey(winnerAddrStr), newTicketCountWinner), IntegerEntry(getTicketsCountKey(otherPlayerAddr), newTicketCountOtherPlayer)]
61+ }
62+
63+
64+
65+@Callable(i)
66+func withdrawRewards () = {
67+ let callerAddrStr = toBase58String(i.caller.bytes)
68+ let currentAvailableRewards = tryGetInteger(addressAvailableRewardsKey(callerAddrStr))
69+ let withdrawFee = fraction(currentAvailableRewards, withdrawFeePercent, 100)
70+ let actualAvailableRewards = ((currentAvailableRewards - invFee) - withdrawFee)
71+ if ((0 >= currentAvailableRewards))
72+ then throw("No available rewards to withdraw")
73+ else [IntegerEntry(addressAvailableRewardsKey(callerAddrStr), 0), ScriptTransfer(i.caller, actualAvailableRewards, unit), ScriptTransfer(Address(toBytes(getStringValue(feeCollectorAddressKey))), withdrawFee, unit)]
74+ }
75+
76+
77+
78+@Callable(i)
79+func buyTickets () = {
80+ let pmt = if ((size(i.payments) == 1))
81+ then i.payments[0]
82+ else throw("Please attach exactly one payment")
83+ if (isDefined(pmt.assetId))
84+ then throw("Tickets can only ibe purchased in Waves")
85+ else if ((pmt.amount != ticketPrice))
86+ then throw((("The payment must be of exactly " + toString(ticketPriceInt)) + " waves"))
87+ else {
88+ let callerAddrStr = toBase58String(i.caller.bytes)
89+ let currentTicketsCount = tryGetInteger(getTicketsCountKey(callerAddrStr))
90+ $Tuple2([IntegerEntry(getTicketsCountKey(callerAddrStr), (currentTicketsCount + 1))], 1)
91+ }
92+ }
93+
94+
95+@Verifier(tx)
96+func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
97+

github/deemru/w8io/169f3d6 
31.37 ms