tx · 5SgyXf7BaMXSPfBz2sRmGGWVAhhAe86w9v5EGqRHwDQz

3NApe984cUyvomn4b2FuBmUcXCA4htsgvHT:  -0.01000000 Waves

2022.07.07 22:52 [2129727] smart account 3NApe984cUyvomn4b2FuBmUcXCA4htsgvHT > SELF 0.00000000 Waves

{ "type": 13, "id": "5SgyXf7BaMXSPfBz2sRmGGWVAhhAe86w9v5EGqRHwDQz", "fee": 1000000, "feeAssetId": null, "timestamp": 1657223569617, "version": 2, "chainId": 84, "sender": "3NApe984cUyvomn4b2FuBmUcXCA4htsgvHT", "senderPublicKey": "BGbxpaZUVsDusojZijDL9KF6AUeVQjQoj3HitG2czUim", "proofs": [ "2UT9gL2b2yZr6USqpPLjddBJXdpbxGHD5hxyScXVtLvp4TfgfVg6r6YyYMXGgfDSJoXB32LVotC6vBcfrkceDshU" ], "script": "base64:BgINCAISBQoDCAEIEgASAAgABXdhdmVzAIDC1y8AC3RpY2tldFByaWNlAMCEPQENdHJ5R2V0SW50ZWdlcgEDa2V5BAckbWF0Y2gwCQCaCAIFBHRoaXMFA2tleQMJAAECBQckbWF0Y2gwAgNJbnQEAWIFByRtYXRjaDAFAWIAAAESZ2V0VGlja2V0c0NvdW50S2V5AQ1hZGRyZXNzU3RyaW5nCQCsAgIFDWFkZHJlc3NTdHJpbmcCDV90aWNrZXRzQ291bnQBDWdhbWVXaW5uZXJLZXkBBmdhbWVJZAkArAICBQZnYW1lSWQCB193aW5uZXIBGmFkZHJlc3NBdmFpbGFibGVSZXdhcmRzS2V5AQdhZGRyZXNzCQCsAgIFB2FkZHJlc3MCEV9hdmFpbGFibGVSZXdhcmRzAQ9nZXRUaWNrZXRzQ291bnQBDWFkZHJlc3NTdHJpbmcJAQ10cnlHZXRJbnRlZ2VyAQkBEmdldFRpY2tldHNDb3VudEtleQEFDWFkZHJlc3NTdHJpbmcBDWNvbnN1bWVUaWNrZXQBCnBsYXllckFkZHIEEmN1cnJlbnRUaWNrZXRDb3VudAkBD2dldFRpY2t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GRyYXcJAMwIAgkBDEludGVnZXJFbnRyeQIJARphZGRyZXNzQXZhaWxhYmxlUmV3YXJkc0tleQEFDWNhbGxlckFkZHJTdHIAAAkAzAgCCQEOU2NyaXB0VHJhbnNmZXIDCAUBaQZjYWxsZXIFF2N1cnJlbnRBdmFpbGFibGVSZXdhcmRzBQR1bml0BQNuaWwBaQEKYnV5VGlja2V0cwAEA3BtdAMJAAACCQCQAwEIBQFpCHBheW1lbnRzAAEJAJEDAggFAWkIcGF5bWVudHMAAAkAAgECIVBsZWFzZSBhdHRhY2ggZXhhY3RseSBvbmUgcGF5bWVudAMJAQlpc0RlZmluZWQBCAUDcG10B2Fzc2V0SWQJAAIBAidUaWNrZXRzIGNhbiBvbmx5IGliZSBwdXJjaGFzZWQgaW4gV2F2ZXMDCQECIT0CCAUDcG10BmFtb3VudAULdGlja2V0UHJpY2UJAAIBCQCsAgIJAKwCAgIfVGhlIHBheW1lbnQgbXVzdCBiZSBvZiBleGFjdGx5IAkApAMBBQt0aWNrZXRQcmljZQIGIHdhdmVzBA1jYWxsZXJBZGRyU3RyCQDYBAEICAUBaQZjYWxsZXIFYnl0ZXMEE2N1cnJlbnRUaWNrZXRzQ291bnQJAQ10cnlHZXRJbnRlZ2VyAQkBEmdldFRpY2tldHNDb3VudEtleQEFDWNhbGxlckFkZHJTdHIJAJQKAgkAzAgCCQEMSW50ZWdlckVudHJ5AgkBEmdldFRpY2tldHNDb3VudEtleQEFDWNhbGxlckFkZHJTdHIJAGQCBRNjdXJyZW50VGlja2V0c0NvdW50AAEFA25pbAABAQJ0eAEGdmVyaWZ5AAkA9AMDCAUCdHgJYm9keUJ5dGVzCQCRAwIIBQJ0eAZwcm9vZnMAAAgFAnR4D3NlbmRlclB1YmxpY0tleTmtEIk=", "height": 2129727, "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 ticketPrice = 1000000
7+
8+func tryGetInteger (key) = match getInteger(this, key) {
9+ case b: Int =>
10+ b
11+ case _ =>
12+ 0
13+}
14+
15+
16+func getTicketsCountKey (addressString) = (addressString + "_ticketsCount")
17+
18+
19+func gameWinnerKey (gameId) = (gameId + "_winner")
20+
21+
22+func addressAvailableRewardsKey (address) = (address + "_availableRewards")
23+
24+
25+func getTicketsCount (addressString) = tryGetInteger(getTicketsCountKey(addressString))
26+
27+
28+func consumeTicket (playerAddr) = {
29+ let currentTicketCount = getTicketsCount(playerAddr)
30+ let newCurrentTicketCount = (currentTicketCount - 1)
31+ if ((0 > currentTicketCount))
32+ then IntegerEntry(getTicketsCountKey(playerAddr), 0)
33+ else IntegerEntry(getTicketsCountKey(playerAddr), currentTicketCount)
34+ }
35+
36+
37+@Callable(i)
38+func setWinner (gameId,playersCount,winnerAddrStr) = if ((i.caller != this))
39+ then throw("Admin Only")
40+ else {
41+ let availableRewardsKey = addressAvailableRewardsKey(winnerAddrStr)
42+ let currentAvailableRewards = tryGetInteger(availableRewardsKey)
43+[StringEntry(gameWinnerKey(gameId), winnerAddrStr), IntegerEntry(availableRewardsKey, (currentAvailableRewards + (ticketPrice * playersCount)))]
44+ }
45+
46+
47+
48+@Callable(i)
49+func withdrawRewards () = {
50+ let callerAddrStr = toBase58String(i.caller.bytes)
51+ let currentAvailableRewards = tryGetInteger(addressAvailableRewardsKey(callerAddrStr))
52+ if ((0 >= currentAvailableRewards))
53+ then throw("No available rewards to withdraw")
54+ else [IntegerEntry(addressAvailableRewardsKey(callerAddrStr), 0), ScriptTransfer(i.caller, currentAvailableRewards, unit)]
55+ }
56+
57+
58+
59+@Callable(i)
60+func buyTickets () = {
61+ let pmt = if ((size(i.payments) == 1))
62+ then i.payments[0]
63+ else throw("Please attach exactly one payment")
64+ if (isDefined(pmt.assetId))
65+ then throw("Tickets can only ibe purchased in Waves")
66+ else if ((pmt.amount != ticketPrice))
67+ then throw((("The payment must be of exactly " + toString(ticketPrice)) + " waves"))
68+ else {
69+ let callerAddrStr = toBase58String(i.caller.bytes)
70+ let currentTicketsCount = tryGetInteger(getTicketsCountKey(callerAddrStr))
71+ $Tuple2([IntegerEntry(getTicketsCountKey(callerAddrStr), (currentTicketsCount + 1))], 1)
72+ }
73+ }
74+
75+
76+@Verifier(tx)
77+func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
78+

github/deemru/w8io/169f3d6 
17.38 ms