tx · 9fPgE3PKFfTBeTmYH4pnMTy9G25XKu7CTnYYkxnK3KP9

3N6hQF6HBBQ5JCKB8Xs17Q61wkG3VrLvbGd:  -0.10001000 Waves

2021.12.03 00:18 [1817186] smart account 3N6hQF6HBBQ5JCKB8Xs17Q61wkG3VrLvbGd > SELF 0.00000000 Waves

{ "type": 13, "id": "9fPgE3PKFfTBeTmYH4pnMTy9G25XKu7CTnYYkxnK3KP9", "fee": 10001000, "feeAssetId": null, "timestamp": 1638479928381, "version": 2, "chainId": 84, "sender": "3N6hQF6HBBQ5JCKB8Xs17Q61wkG3VrLvbGd", "senderPublicKey": "7Hi4o6vBstRs79NMVMjEove52dmP87RAcvNDAXN8C4Wi", "proofs": [ "5VngX9HKnqFP31cREQgLhKyp9uoC8VKfFPM2YbRS8LWRzJCUujYaai5SwVHZ6BUBcBuj4w35qg5bgycyGYR5DVWm" ], "script": "base64:AAIFAAAAAAAAADwIAhIDCgEIEgMKAQgaCwoCYTESBXJvdW5kGhMKAmEyEg1jYWxsZXJBZGRyZXNzGgwKAmEzEgZ2ZXJpZnkAAAAAAAAAAgAAAAFpAQAAAARiZXQyAAAAAQAAAAJhMQQAAAACYTIJAAJYAAAAAQgIBQAAAAFpAAAABmNhbGxlcgAAAAVieXRlcwkAAAIAAAABAgAAAAZjYWxsZWQAAAABaQEAAAAJd2l0aGRyYXcyAAAAAQAAAAJhMQQAAAACYTIJAAJYAAAAAQgIBQAAAAFpAAAABmNhbGxlcgAAAAVieXRlcwkAAAIAAAABAgAAAAZjYWxsZWQAAAABAAAAAnR4AQAAAAJhMwAAAAAJAAH0AAAAAwgFAAAAAnR4AAAACWJvZHlCeXRlcwkAAZEAAAACCAUAAAACdHgAAAAGcHJvb2ZzAAAAAAAAAAAACAUAAAACdHgAAAAPc2VuZGVyUHVibGljS2V52A62wQ==", "height": 1817186, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 22efvLwL6mvigxDy8pVp1cXt7J2sjskUcPNDr6uXZiZm Next: BKBVVHDwFe1JT9XgqBJMMPXGUskqegrYKpdFwGHgL35r Diff:
OldNewDifferences
11 {-# STDLIB_VERSION 5 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
4-let casino = "3MtaCL4v1bjTabUqs7oU4ofS8fbai34WM1i"
5-
6-let WAVES = 1000000000
7-
8-let maxBet = (100 * WAVES)
9-
10-let separator = ","
11-
12-func getNewDeck () = ["01C", "02C", "03C", "04C", "05C", "06C", "07C", "08C", "09C", "10C", "11C", "12C", "13C", "01D", "02D", "03D", "04D", "05D", "06D", "07D", "08D", "09D", "10D", "11D", "12D", "13D", "01H", "02H", "03H", "04H", "05H", "06H", "07H", "08H", "09H", "10H", "11H", "12H", "13H", "01S", "02S", "03S", "04S", "05S", "06S", "07S", "08S", "09S", "10S", "11S", "12S", "13S"]
13-
14-
15-func getSixNewDecks () = (((((getNewDeck() ++ getNewDeck()) ++ getNewDeck()) ++ getNewDeck()) ++ getNewDeck()) ++ getNewDeck())
16-
17-
18-func getDeck (deck) = if ((0 >= size(deck)))
19- then getSixNewDecks()
20- else deck
21-
22-
23-func getRandomNumber (salt1,salt2,answersCount) = {
24- let hash = sha256(toBytes((salt1 + salt2)))
25- let index = toInt(hash)
26- let rand = (index % answersCount)
27- if ((0 > rand))
28- then ((-1 * rand) + 1)
29- else (rand + 1)
30- }
31-
32-
33-func getPreviousRandomNumber (address) = match getInteger(this, (address + "_LastRandonNumber")) {
34- case n: Int =>
35- toString(n)
36- case _ =>
37- address
38-}
39-
40-
41-func getAmountOrZero (this,key) = match getInteger(this, key) {
42- case a: Int =>
43- a
44- case _ =>
45- 0
46-}
47-
48-
49-func getPayment (i) = if ((size(i.payments) == 0))
50- then throw("Payment must be attached")
51- else {
52- let pmt = i.payments[0]
53- if (isDefined(pmt.assetId))
54- then throw("This function accepts WAVES tokens only")
55- else pmt.amount
56- }
57-
58-
59-func getCardValue (stringCard) = {
60- let p = parseIntValue(take(stringCard, 2))
61- if ((p == 1))
62- then 20
63- else p
64- }
65-
66-
67-func getWinner (cardPlayer,cardCasino,callerAddress,casino) = {
68- let p = getCardValue(cardPlayer)
69- let o = getCardValue(cardCasino)
70- if ((p > o))
71- then callerAddress
72- else casino
73- }
74-
75-
76-func Exit () = if ((1 >= 1))
77- then throw("exit")
78- else throw("message")
79-
80-
81-func getAvailableDeck (this,availableProp) = if (isDefined(getString(this, availableProp)))
82- then {
83- let stringDeck = getStringValue(this, availableProp)
84- let deck = split(stringDeck, separator)
85- getDeck(deck)
86- }
87- else getSixNewDecks()
88-
89-
90-func getPlayerCardAndPositionAndUpdateDeck (meKey,callerAddress,deck) = {
91- let avDeck2 = getDeck(deck)
92- let cardPosition = getRandomNumber(((meKey + makeString(avDeck2, separator)) + callerAddress), getPreviousRandomNumber(callerAddress), size(avDeck2))
93- let card = avDeck2[(cardPosition % size(avDeck2))]
94- let avDeck3 = removeByIndex(avDeck2, (cardPosition % size(avDeck2)))
95- $Tuple3(card, cardPosition, avDeck3)
96- }
974
985
996 @Callable(i)
100-func bet1 (round) = {
7+func bet2 (round) = {
1018 let callerAddress = toBase58String(i.caller.bytes)
102- let exit = Exit()
103- let meKey = round
104- let p = getPayment(i)
105- let curSumBets = getAmountOrZero(c2, (round + "_sumBets"))
106- let currentDraws = match getInteger(c2, (round + "_drawSequence")) {
107- case a: Int =>
108- (a + 1)
109- case _ =>
110- 0
111- }
112- let currentPlayer = match getString(c2, (round + "_player")) {
113- case a: String =>
114- a
115- case _ =>
116- unit
117- }
118- let initialBet = match getInteger(c2, (round + "_initialBet")) {
119- case a: Int =>
120- a
121- case _ =>
122- p
123- }
124- let availableProp = (meKey + "_available")
125- let newSumBets = (curSumBets + p)
126- if (if (isDefined(getBoolean(c2, (round + "_stop"))))
127- then true
128- else isDefined(getString(c2, round)))
129- then throw("This round is already played")
130- else if (if (isDefined(getString(c2, (round + "_player"))))
131- then (currentPlayer != callerAddress)
132- else false)
133- then throw("This is not your game")
134- else if ((newSumBets > maxBet))
135- then throw(((("Maximum amount of bets for round " + toString(maxBet)) + ". With your bet it's ") + toString(newSumBets)))
136- else if ((initialBet != p))
137- then throw(((("Initial bet not maching original:" + toString(initialBet)) + ", actual:") + toString(p)))
138- else {
139- let avDeck = getAvailableDeck(c2, availableProp)
140- let $t040774192 = getPlayerCardAndPositionAndUpdateDeck(meKey, callerAddress, avDeck)
141- let cardPlayer = $t040774192._1
142- let cardPositionPlayer = $t040774192._2
143- let avDeck1 = $t040774192._3
144- let $t041974313 = getPlayerCardAndPositionAndUpdateDeck(meKey, callerAddress, avDeck1)
145- let cardCasino = $t041974313._1
146- let cardPositionCasino = $t041974313._2
147- let avDeck2 = $t041974313._3
148- if ((getCardValue(cardPlayer) == getCardValue(cardCasino)))
149- then [StringEntry(availableProp, makeString(avDeck2, separator)), StringEntry((round + "_player"), callerAddress), IntegerEntry((round + "_initialBet"), initialBet), StringEntry((meKey + "_salt_debug"), meKey), IntegerEntry((meKey + "_LastRandonNumber"), cardPositionCasino), IntegerEntry((round + "_sumBets"), newSumBets), StringEntry((meKey + "_playerCard"), cardPlayer), StringEntry((meKey + "_casinoCard"), cardCasino), IntegerEntry((round + "_drawSequence"), (currentDraws + 1))]
150- else {
151- let winner = getWinner(cardPlayer, cardCasino, callerAddress, casino)
152-[StringEntry(availableProp, makeString(avDeck2, separator)), StringEntry((round + "_player"), callerAddress), IntegerEntry((round + "_initialBet"), initialBet), StringEntry((meKey + "_salt_debug"), meKey), IntegerEntry((meKey + "_LastRandonNumber"), cardPositionCasino), IntegerEntry((round + "_sumBets"), newSumBets), StringEntry((meKey + "_playerCard"), cardPlayer), StringEntry((meKey + "_casinoCard"), cardCasino), BooleanEntry((round + "_stop"), true), StringEntry((round + "_winner"), winner)]
153- }
154- }
9+ throw("called")
15510 }
15611
15712
15813
15914 @Callable(i)
160-func withdraw1 (round) = {
15+func withdraw2 (round) = {
16116 let callerAddress = toBase58String(i.caller.bytes)
162- let meKey = ((round + "_") + callerAddress)
163- let withdrawKey = (round + "_withdraw")
164- if (isDefined(getString(c2, withdrawKey)))
165- then throw("You have already got your prize")
166- else if (!(isDefined(getString(c2, (round + "_winner")))))
167- then throw("There is no winner, it was a draw")
168- else {
169- let winner = getStringValue(c2, (round + "_winner"))
170- let player = getStringValue(c2, (round + "_player"))
171- let curSumBet = getIntegerValue(c2, (round + "_sumBets"))
172- if ((curSumBet == 0))
173- then throw("You won nothing this round")
174- else if (if ((winner == callerAddress))
175- then (winner == casino)
176- else false)
177- then [StringEntry(withdrawKey, toString(curSumBet)), ScriptTransfer(i.caller, curSumBet, unit)]
178- else if (if ((winner == callerAddress))
179- then (winner == player)
180- else false)
181- then [StringEntry(withdrawKey, toString((curSumBet * 2))), ScriptTransfer(i.caller, (curSumBet * 2), unit)]
182- else throw("You are not the winner")
183- }
17+ throw("called")
18418 }
18519
18620
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 5 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
4-let casino = "3MtaCL4v1bjTabUqs7oU4ofS8fbai34WM1i"
5-
6-let WAVES = 1000000000
7-
8-let maxBet = (100 * WAVES)
9-
10-let separator = ","
11-
12-func getNewDeck () = ["01C", "02C", "03C", "04C", "05C", "06C", "07C", "08C", "09C", "10C", "11C", "12C", "13C", "01D", "02D", "03D", "04D", "05D", "06D", "07D", "08D", "09D", "10D", "11D", "12D", "13D", "01H", "02H", "03H", "04H", "05H", "06H", "07H", "08H", "09H", "10H", "11H", "12H", "13H", "01S", "02S", "03S", "04S", "05S", "06S", "07S", "08S", "09S", "10S", "11S", "12S", "13S"]
13-
14-
15-func getSixNewDecks () = (((((getNewDeck() ++ getNewDeck()) ++ getNewDeck()) ++ getNewDeck()) ++ getNewDeck()) ++ getNewDeck())
16-
17-
18-func getDeck (deck) = if ((0 >= size(deck)))
19- then getSixNewDecks()
20- else deck
21-
22-
23-func getRandomNumber (salt1,salt2,answersCount) = {
24- let hash = sha256(toBytes((salt1 + salt2)))
25- let index = toInt(hash)
26- let rand = (index % answersCount)
27- if ((0 > rand))
28- then ((-1 * rand) + 1)
29- else (rand + 1)
30- }
31-
32-
33-func getPreviousRandomNumber (address) = match getInteger(this, (address + "_LastRandonNumber")) {
34- case n: Int =>
35- toString(n)
36- case _ =>
37- address
38-}
39-
40-
41-func getAmountOrZero (this,key) = match getInteger(this, key) {
42- case a: Int =>
43- a
44- case _ =>
45- 0
46-}
47-
48-
49-func getPayment (i) = if ((size(i.payments) == 0))
50- then throw("Payment must be attached")
51- else {
52- let pmt = i.payments[0]
53- if (isDefined(pmt.assetId))
54- then throw("This function accepts WAVES tokens only")
55- else pmt.amount
56- }
57-
58-
59-func getCardValue (stringCard) = {
60- let p = parseIntValue(take(stringCard, 2))
61- if ((p == 1))
62- then 20
63- else p
64- }
65-
66-
67-func getWinner (cardPlayer,cardCasino,callerAddress,casino) = {
68- let p = getCardValue(cardPlayer)
69- let o = getCardValue(cardCasino)
70- if ((p > o))
71- then callerAddress
72- else casino
73- }
74-
75-
76-func Exit () = if ((1 >= 1))
77- then throw("exit")
78- else throw("message")
79-
80-
81-func getAvailableDeck (this,availableProp) = if (isDefined(getString(this, availableProp)))
82- then {
83- let stringDeck = getStringValue(this, availableProp)
84- let deck = split(stringDeck, separator)
85- getDeck(deck)
86- }
87- else getSixNewDecks()
88-
89-
90-func getPlayerCardAndPositionAndUpdateDeck (meKey,callerAddress,deck) = {
91- let avDeck2 = getDeck(deck)
92- let cardPosition = getRandomNumber(((meKey + makeString(avDeck2, separator)) + callerAddress), getPreviousRandomNumber(callerAddress), size(avDeck2))
93- let card = avDeck2[(cardPosition % size(avDeck2))]
94- let avDeck3 = removeByIndex(avDeck2, (cardPosition % size(avDeck2)))
95- $Tuple3(card, cardPosition, avDeck3)
96- }
974
985
996 @Callable(i)
100-func bet1 (round) = {
7+func bet2 (round) = {
1018 let callerAddress = toBase58String(i.caller.bytes)
102- let exit = Exit()
103- let meKey = round
104- let p = getPayment(i)
105- let curSumBets = getAmountOrZero(c2, (round + "_sumBets"))
106- let currentDraws = match getInteger(c2, (round + "_drawSequence")) {
107- case a: Int =>
108- (a + 1)
109- case _ =>
110- 0
111- }
112- let currentPlayer = match getString(c2, (round + "_player")) {
113- case a: String =>
114- a
115- case _ =>
116- unit
117- }
118- let initialBet = match getInteger(c2, (round + "_initialBet")) {
119- case a: Int =>
120- a
121- case _ =>
122- p
123- }
124- let availableProp = (meKey + "_available")
125- let newSumBets = (curSumBets + p)
126- if (if (isDefined(getBoolean(c2, (round + "_stop"))))
127- then true
128- else isDefined(getString(c2, round)))
129- then throw("This round is already played")
130- else if (if (isDefined(getString(c2, (round + "_player"))))
131- then (currentPlayer != callerAddress)
132- else false)
133- then throw("This is not your game")
134- else if ((newSumBets > maxBet))
135- then throw(((("Maximum amount of bets for round " + toString(maxBet)) + ". With your bet it's ") + toString(newSumBets)))
136- else if ((initialBet != p))
137- then throw(((("Initial bet not maching original:" + toString(initialBet)) + ", actual:") + toString(p)))
138- else {
139- let avDeck = getAvailableDeck(c2, availableProp)
140- let $t040774192 = getPlayerCardAndPositionAndUpdateDeck(meKey, callerAddress, avDeck)
141- let cardPlayer = $t040774192._1
142- let cardPositionPlayer = $t040774192._2
143- let avDeck1 = $t040774192._3
144- let $t041974313 = getPlayerCardAndPositionAndUpdateDeck(meKey, callerAddress, avDeck1)
145- let cardCasino = $t041974313._1
146- let cardPositionCasino = $t041974313._2
147- let avDeck2 = $t041974313._3
148- if ((getCardValue(cardPlayer) == getCardValue(cardCasino)))
149- then [StringEntry(availableProp, makeString(avDeck2, separator)), StringEntry((round + "_player"), callerAddress), IntegerEntry((round + "_initialBet"), initialBet), StringEntry((meKey + "_salt_debug"), meKey), IntegerEntry((meKey + "_LastRandonNumber"), cardPositionCasino), IntegerEntry((round + "_sumBets"), newSumBets), StringEntry((meKey + "_playerCard"), cardPlayer), StringEntry((meKey + "_casinoCard"), cardCasino), IntegerEntry((round + "_drawSequence"), (currentDraws + 1))]
150- else {
151- let winner = getWinner(cardPlayer, cardCasino, callerAddress, casino)
152-[StringEntry(availableProp, makeString(avDeck2, separator)), StringEntry((round + "_player"), callerAddress), IntegerEntry((round + "_initialBet"), initialBet), StringEntry((meKey + "_salt_debug"), meKey), IntegerEntry((meKey + "_LastRandonNumber"), cardPositionCasino), IntegerEntry((round + "_sumBets"), newSumBets), StringEntry((meKey + "_playerCard"), cardPlayer), StringEntry((meKey + "_casinoCard"), cardCasino), BooleanEntry((round + "_stop"), true), StringEntry((round + "_winner"), winner)]
153- }
154- }
9+ throw("called")
15510 }
15611
15712
15813
15914 @Callable(i)
160-func withdraw1 (round) = {
15+func withdraw2 (round) = {
16116 let callerAddress = toBase58String(i.caller.bytes)
162- let meKey = ((round + "_") + callerAddress)
163- let withdrawKey = (round + "_withdraw")
164- if (isDefined(getString(c2, withdrawKey)))
165- then throw("You have already got your prize")
166- else if (!(isDefined(getString(c2, (round + "_winner")))))
167- then throw("There is no winner, it was a draw")
168- else {
169- let winner = getStringValue(c2, (round + "_winner"))
170- let player = getStringValue(c2, (round + "_player"))
171- let curSumBet = getIntegerValue(c2, (round + "_sumBets"))
172- if ((curSumBet == 0))
173- then throw("You won nothing this round")
174- else if (if ((winner == callerAddress))
175- then (winner == casino)
176- else false)
177- then [StringEntry(withdrawKey, toString(curSumBet)), ScriptTransfer(i.caller, curSumBet, unit)]
178- else if (if ((winner == callerAddress))
179- then (winner == player)
180- else false)
181- then [StringEntry(withdrawKey, toString((curSumBet * 2))), ScriptTransfer(i.caller, (curSumBet * 2), unit)]
182- else throw("You are not the winner")
183- }
17+ throw("called")
18418 }
18519
18620
18721 @Verifier(tx)
18822 func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
18923

github/deemru/w8io/169f3d6 
36.99 ms