tx · 4ok5mZo25s1fKumHAB6qVcwf1yRWYHAWxyUw3jStafmC

3N4boZRUJ2LxY5jLyp6hmxGktqnawQidu6H:  -0.00100000 Waves

2022.09.07 20:48 [2219017] smart account 3N4boZRUJ2LxY5jLyp6hmxGktqnawQidu6H > SELF 0.00000000 Waves

{ "type": 13, "id": "4ok5mZo25s1fKumHAB6qVcwf1yRWYHAWxyUw3jStafmC", "fee": 100000, "feeAssetId": null, "timestamp": 1662572895077, "version": 2, "chainId": 84, "sender": "3N4boZRUJ2LxY5jLyp6hmxGktqnawQidu6H", "senderPublicKey": "BDeCphaaC4MZvfmbJqQZ78EvuEBZTJ1VEW7fbxue8BUu", "proofs": [ "666biJJ1YCf5nY58Zu5JCGTgxHY21QzPqeXEzPNzym4Uai9wvynrf7HyyDJ8kTBHiZniGpkD7gKQo5KjWnJ7TobK" ], "script": "base64:BgIGCAISABIABAAMa1VzZXJQYXltZW50AgdQYXltZW50AARrV29uAgNXb24BCXJhbmRvbWl6ZQIFYnl0ZXMFcmFuZ2UEBGhhc2gJAPcDAQUFYnl0ZXMEBWluZGV4CQCxCQEFBGhhc2gJAGoCBQVpbmRleAUFcmFuZ2UBCGNvdW50aW5nAQVieXRlcwQFY291bnQJAQlyYW5kb21pemUCBQVieXRlcwAKAwkAZwIFBWNvdW50AAQJAQxCb29sZWFuRW50cnkCBQRrV29uBwkBDEJvb2xlYW5FbnRyeQIFBGtXb24GAgFpAQtwYXJzZVN0cnVjdAADCQECIT0CCAUBaQZjYWxsZXIFBHRoaXMJAAIBAgpPbmx5IG93bmVyBAx3aW5uZXJTdHJ1Y3QJAQhjb3VudGluZwEIBQFpDXRyYW5zYWN0aW9uSWQJAMwIAgUMd2lubmVyU3RydWN0BQNuaWwBaQEJc3RhcnRHYW1lAAQGYW1vdW50CQEFdmFsdWUBCAkAkQMCCAUBaQhwYXltZW50cwAABmFtb3VudAMJAQIhPQIICQCRAwIIBQFpCHBheW1lbnRzAAAHYXNzZXRJZAUEdW5pdAkAAgECDFBheSBpbiB3YXZlcwQNbnVsbEluaXRTdG9yZQkA/AcEBQR0aGlzAgtwYXJzZVN0cnVjdAUDbmlsBQNuaWwDCQAAAgUNbnVsbEluaXRTdG9yZQUNbnVsbEluaXRTdG9yZQQDd29uCQETdmFsdWVPckVycm9yTWVzc2FnZQIJAJsIAgUEdGhpcwUEa1dvbgISU3RvcmFnZSByZWFkIGVycm9yAwUDd29uCQDMCAIJAQ5TY3JpcHRUcmFuc2ZlcgMIBQFpBmNhbGxlcgkAaAIFBmFtb3VudAACBQR1bml0BQNuaWwFA25pbAkAAgECJFN0cmljdCB2YWx1ZSBpcyBub3QgZXF1YWwgdG8gaXRzZWxmLgAZzlM7", "height": 2219017, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 8um1kaQxHSi7JQKysUUV1sXXN9J9weYWsQUiVCawNfk2 Next: E1t2f8ivUBNzS5n4anzwnXF4M5X19xqNydmrgtkxfHFW Full:
OldNewDifferences
11 {-# STDLIB_VERSION 6 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
4-let separator = "_"
4+let kUserPayment = "Payment"
55
6-let kGame = "game"
6+let kWon = "Won"
77
8-let kRound = "round"
9-
10-let kPlayer = "player"
11-
12-let kTotal = "total"
13-
14-let kCount = "count"
15-
16-let kPot = "pot"
17-
18-let kAsset = "asset"
19-
20-let kBet = "bet"
21-
22-let kMin = "min"
23-
24-let kMax = "max"
25-
26-let kNext = "next"
27-
28-let kLast = "last"
29-
30-let kBankroll = "bankroll"
31-
32-let kBank = "bank"
33-
34-let kDefault = "default"
35-
36-let kStatus = "status"
37-
38-let kBalance = "balance"
39-
40-func getGameKey (gameId) = makeString([kGame, gameId], separator)
41-
42-
43-func getGamePlayerKey (gameId,playerAddress) = makeString([getGameKey(gameId), kPlayer, playerAddress], separator)
44-
45-
46-func getGamePlayerCounterKey (gameId) = makeString([getGameKey(gameId), kPlayer, kCount], separator)
47-
48-
49-func getGamePlayerTotalKey (gameId) = makeString([getGameKey(gameId), kPlayer, kTotal], separator)
50-
51-
52-func getNextBetPlayerKey (gameId) = makeString([getGameKey(gameId), kNext, kBet, kPlayer], separator)
53-
54-
55-func getGamePlayerStatusKey (gameId,playerAddress) = makeString([getGameKey(gameId), kStatus, kPlayer, playerAddress], separator)
56-
57-
58-func getGameRoundKey (gameId) = makeString([getGameKey(gameId), kRound], separator)
59-
60-
61-func getGamePotKey (gameId) = makeString([getGameKey(gameId), kPot], separator)
62-
63-
64-func getGameAssetKey (gameId) = makeString([getGameKey(gameId), kAsset], separator)
65-
66-
67-func getGameMinBetKey (gameId) = makeString([getGameKey(gameId), kMin, kBet], separator)
68-
69-
70-func getGameLastBetKey (gameId) = makeString([getGameKey(gameId), kLast, kBet], separator)
71-
72-
73-func getGameBankrollKey (gameId) = makeString([getGameKey(gameId), kBankroll], separator)
74-
75-
76-func getGameBankKey (gameId) = makeString([getGameKey(gameId), kBank], separator)
77-
78-
79-func getGamePlayerBalanceKey (gameId,playerAddress) = makeString([getGameKey(gameId), kPlayer, playerAddress, kBalance], separator)
80-
81-
82-func setGame (gameId,flag) = BooleanEntry(getGameKey(gameId), flag)
83-
84-
85-func setGamePlayer (gameId,playerAddress,playerId) = IntegerEntry(getGamePlayerKey(gameId, playerAddress), playerId)
86-
87-
88-func setGamePlayerCounter (gameId,counter) = IntegerEntry(getGamePlayerCounterKey(gameId), counter)
89-
90-
91-func setGamePlayerTotal (gameId,totalPlayers) = IntegerEntry(getGamePlayerTotalKey(gameId), totalPlayers)
92-
93-
94-func setNextBetPlayer (gameId,playerId) = IntegerEntry(getNextBetPlayerKey(gameId), playerId)
95-
96-
97-func setGamePlayerStatus (gameId,playerAddress,flag) = BooleanEntry(getGamePlayerStatusKey(gameId, playerAddress), flag)
98-
99-
100-func setGameRound (gameId,round) = IntegerEntry(getGameRoundKey(gameId), round)
101-
102-
103-func setGamePot (gameId,pot) = IntegerEntry(getGamePotKey(gameId), pot)
104-
105-
106-func setGameLastBet (gameId,lastBet) = IntegerEntry(getGameLastBetKey(gameId), lastBet)
107-
108-
109-func setGameAsset (gameId,gameAsset) = match gameAsset {
110- case token: ByteVector =>
111- StringEntry(getGameAssetKey(gameId), toBase58String(token))
112- case _ =>
113- StringEntry(getGameAssetKey(gameId), "WAVES")
114-}
115-
116-
117-func setGameMinBet (gameId,minBet) = IntegerEntry(getGameMinBetKey(gameId), minBet)
118-
119-
120-func setGameBankroll (gameId,bankroll) = IntegerEntry(getGameBankrollKey(gameId), bankroll)
121-
122-
123-func setGameBank (gameId,bank) = IntegerEntry(getGameBankrollKey(gameId), bank)
124-
125-
126-func setGamePlayerBalance (gameId,playerAddress,currentBalance) = IntegerEntry(getGamePlayerBalanceKey(gameId, playerAddress), currentBalance)
127-
128-
129-func getGame (gameId) = getBoolean(this, getGameKey(gameId))
130-
131-
132-func getGamePlayer (gameId,playerAddress) = getStringValue(this, getGamePlayerKey(gameId, playerAddress))
133-
134-
135-func getGamePlayerCounter (gameId) = valueOrElse(getInteger(this, getGamePlayerCounterKey(gameId)), 0)
136-
137-
138-func getGamePlayerTotal (gameId) = getIntegerValue(this, getGamePlayerTotalKey(gameId))
139-
140-
141-func getNextBetPlayer (gameId) = getInteger(this, getNextBetPlayerKey(gameId))
142-
143-
144-func getGamePlayerStatus (gameId,playerAddress) = getBoolean(this, getGamePlayerStatusKey(gameId, playerAddress))
145-
146-
147-func getGameRound (gameId) = getInteger(this, getGameRoundKey(gameId))
148-
149-
150-func getGamePot (gameId) = getIntegerValue(this, getGamePotKey(gameId))
151-
152-
153-func getGameLastBet (gameId) = getInteger(this, getGameLastBetKey(gameId))
154-
155-
156-func getGameAsset (gameId) = getStringValue(this, getGameAssetKey(gameId))
157-
158-
159-func getGameMinBet (gameId) = getInteger(this, getGameMinBetKey(gameId))
160-
161-
162-func getGameBankroll (gameId) = getIntegerValue(this, getGameBankrollKey(gameId))
163-
164-
165-func getGameBank (gameId) = getIntegerValue(this, getGameBankKey(gameId))
166-
167-
168-func getGamePlayerBalance (gameId,playerAddress) = getInteger(this, getGamePlayerBalanceKey(gameId, playerAddress))
169-
170-
171-func isGameExist (gameId) = isDefined(getGame(gameId))
172-
173-
174-func isGameStarted (gameId) = valueOrElse(getGame(gameId), false)
175-
176-
177-func isRequiredPlayer (gameId) = (getGamePlayerTotal(gameId) > getGamePlayerCounter(gameId))
178-
179-
180-func isCorrectAsset (gameId,asset) = {
181- let gameAsset = getGameAsset(gameId)
182- if ((gameAsset == "WAVES"))
183- then (asset == unit)
184- else (asset == fromBase58String(gameAsset))
8+func randomize (bytes,range) = {
9+ let hash = sha256(bytes)
10+ let index = toInt(hash)
11+ (index % range)
18512 }
18613
18714
188-func isEnougthDeposit (gameId,amount) = (amount >= getGameBankroll(gameId))
189-
190-
191-func fold (gameId,playerTotal,caller) = {
192- let structPlayerStatus = setGamePlayerStatus(gameId, toString(caller), false)
193- let playerTotalStruct = setGamePlayerTotal(gameId, (playerTotal - 1))
194- $Tuple2(structPlayerStatus, playerTotalStruct)
15+func counting (bytes) = {
16+ let count = randomize(bytes, 10)
17+ if ((count >= 4))
18+ then BooleanEntry(kWon, false)
19+ else BooleanEntry(kWon, true)
19520 }
19621
19722
198-func raise (amount,playerBalance,lastBet,gameId,caller) = if (if ((amount > playerBalance))
199- then true
200- else (lastBet > amount))
201- then throw("insufficient funds")
23+@Callable(i)
24+func parseStruct () = if ((i.caller != this))
25+ then throw("Only owner")
20226 else {
203- let lastBetStruct = setGameLastBet(gameId, amount)
204- let bankStruct = setGameBank(gameId, (getGameBank(gameId) + amount))
205- let playerBalanceStruct = setGamePlayerBalance(gameId, toString(caller), (playerBalance - amount))
206- $Tuple3(lastBetStruct, bankStruct, playerBalanceStruct)
27+ let winnerStruct = counting(i.transactionId)
28+[winnerStruct]
20729 }
20830
20931
210-func checkOrCall (playerBalance,lastBet,gameId,caller) = if ((lastBet > playerBalance))
211- then throw("insufficient funds")
212- else {
213- let bankStruct = setGameBank(gameId, (getGameBank(gameId) + lastBet))
214- let playerBalanceStruct = setGamePlayerBalance(gameId, toString(caller), (playerBalance - lastBet))
215- $Tuple2(bankStruct, playerBalanceStruct)
216- }
217-
21832
21933 @Callable(i)
220-func move (action,gameId,amount) = {
221- let gamePlayer = getGamePlayer(gameId, toString(i.caller))
222- let lastBet = valueOrErrorMessage(getGameLastBet(gameId), "")
223- let playerBalance = valueOrErrorMessage(getGamePlayerBalance(gameId, toString(i.caller)), "")
224- let playerStatus = valueOrErrorMessage(getGamePlayerStatus(gameId, toString(i.caller)), "")
225- let playerTotal = getGamePlayerTotal(gameId)
226- if ((action == "fold"))
227- then {
228- let $t073477428 = fold(gameId, playerTotal, i.caller)
229- let structPlayerStatus = $t073477428._1
230- let playerTotalStruct = $t073477428._2
231-[structPlayerStatus, playerTotalStruct]
34+func startGame () = {
35+ let amount = value(i.payments[0].amount)
36+ if ((i.payments[0].assetId != unit))
37+ then throw("Pay in waves")
38+ else {
39+ let nullInitStore = invoke(this, "parseStruct", nil, nil)
40+ if ((nullInitStore == nullInitStore))
41+ then {
42+ let won = valueOrErrorMessage(getBoolean(this, kWon), "Storage read error")
43+ if (won)
44+ then [ScriptTransfer(i.caller, (amount * 2), unit)]
45+ else nil
46+ }
47+ else throw("Strict value is not equal to itself.")
23248 }
233- else if ((action == "raise"))
234- then {
235- let $t075427652 = raise(amount, playerBalance, lastBet, gameId, i.caller)
236- let lastBetStruct = $t075427652._1
237- let bankStruct = $t075427652._2
238- let playerBalanceStruct = $t075427652._3
239-[lastBetStruct, bankStruct, playerBalanceStruct]
240- }
241- else if ((action == "checkOrCall"))
242- then {
243- let $t077897897 = checkOrCall(playerBalance, lastBet, gameId, i.caller)
244- let bankStructCheckOrCall = $t077897897._1
245- let playerBalanceCheckOrCall = $t077897897._2
246-[bankStructCheckOrCall, playerBalanceCheckOrCall]
247- }
248- else nil
24949 }
25050
25151

github/deemru/w8io/169f3d6 
38.33 ms