tx · EptzKjYFXRQCYRH7khqdC3GXXhc7iXajNXDundbJrN7A

3MtPWAEpfZeZ4zb21uwEJVwpkvDpHTDiq9b:  -0.01000000 Waves

2022.07.07 22:40 [2129712] smart account 3MtPWAEpfZeZ4zb21uwEJVwpkvDpHTDiq9b > SELF 0.00000000 Waves

{ "type": 13, "id": "EptzKjYFXRQCYRH7khqdC3GXXhc7iXajNXDundbJrN7A", "fee": 1000000, "feeAssetId": null, "timestamp": 1657222845960, "version": 2, "chainId": 84, "sender": "3MtPWAEpfZeZ4zb21uwEJVwpkvDpHTDiq9b", "senderPublicKey": "9R79UjEK1C688KvMyu4DjXPu1upQi7sELuUpGqWoDu7e", "proofs": [ "5xMQNyEvSNfijDnTTK8mLGHvEr85WTohEWYFkgHj1YRho2r5MiXKixf3xZvdn5SZpKxzjgQit6LXdgu3ebEXFC4T" ], "script": "base64:BgINCAISBQoDCAEIEgASAAgABXdhdmVzAIDC1y8AC3RpY2tldFByaWNlCQBoAgkAaQIAAQBkBQV3YXZlcwENdHJ5R2V0SW50ZWdlcgEDa2V5BAckbWF0Y2gwCQCaCAIFBHRoaXMFA2tleQMJAAECBQckbWF0Y2gwAgNJbnQEAWIFByRtYXRjaDAFAWIAAAESZ2V0VGlja2V0c0NvdW50S2V5AQ1hZGRyZXNzU3RyaW5nCQCsAgIFDWFkZHJlc3NTdHJpbmcCDV90aWNrZXRzQ291bnQBDWdhbWVXaW5uZXJLZXkBBmdhbWVJZAkArAICBQZnYW1lSWQCB193aW5uZXIBGmFkZHJlc3NBdmFpbGFibGVSZXdhcmRzS2V5AQdhZGRyZXNzCQCsAgIFB2FkZHJlc3MCEV9hdmFpbGFibGVSZXdhcmRzAQ9nZXRUaWNrZXRzQ291bnQBDWFkZHJlc3NTdHJpbmcJAQ10cnlHZXRJbnRlZ2VyAQkBEmdldFRpY2tldHNDb3VudEtleQEFDWFkZHJlc3NTdHJpbmcBDWNvbnN1bWVUaWNrZXQBCnBsYXllckFkZHIEEmN1cnJlb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aWxhYmxlIHJld2FyZHMgdG8gd2l0aGRyYXcJAMwIAgkBDEludGVnZXJFbnRyeQIJARphZGRyZXNzQXZhaWxhYmxlUmV3YXJkc0tleQEFDWNhbGxlckFkZHJTdHIAAAkAzAgCCQEOU2NyaXB0VHJhbnNmZXIDCAUBaQZjYWxsZXIFF2N1cnJlbnRBdmFpbGFibGVSZXdhcmRzBQR1bml0BQNuaWwBaQEJYnV5VGlja2V0AAQDcG10AwkAAAIJAJADAQgFAWkIcGF5bWVudHMAAQkAkQMCCAUBaQhwYXltZW50cwAACQACAQIhUGxlYXNlIGF0dGFjaCBleGFjdGx5IG9uZSBwYXltZW50AwkBCWlzRGVmaW5lZAEIBQNwbXQHYXNzZXRJZAkAAgECJ1RpY2tldHMgY2FuIG9ubHkgaWJlIHB1cmNoYXNlZCBpbiBXYXZlcwMJAQIhPQIIBQNwbXQGYW1vdW50BQt0aWNrZXRQcmljZQkAAgEJAKwCAgkArAICAh9UaGUgcGF5bWVudCBtdXN0IGJlIG9mIGV4YWN0bHkgCQCkAwEJAGkCBQt0aWNrZXRQcmljZQUFd2F2ZXMCBiB3YXZlcwQNY2FsbGVyQWRkclN0cgkA2AQBCAgFAWkGY2FsbGVyBWJ5dGVzBBNjdXJyZW50VGlja2V0c0NvdW50CQENdHJ5R2V0SW50ZWdlcgEJARJnZXRUaWNrZXRzQ291bnRLZXkBBQ1jYWxsZXJBZGRyU3RyCQCUCgIJAMwIAgkBDEludGVnZXJFbnRyeQIJARJnZXRUaWNrZXRzQ291bnRLZXkBBQ1jYWxsZXJBZGRyU3RyCQBkAgUTY3VycmVudFRpY2tldHNDb3VudAABBQNuaWwAAQECdHgBBnZlcmlmeQAJAPQDAwgFAnR4CWJvZHlCeXRlcwkAkQMCCAUCdHgGcHJvb2ZzAAAIBQJ0eA9zZW5kZXJQdWJsaWNLZXltXxsa", "height": 2129712, "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 = ((1 / 100) * waves)
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 buyTicket () = {
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))) + " 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/026f985 
16.07 ms