tx · GzRbzDdEZWxK8ZvcYfTsmZjQqPDSzCvDxzkaDcT3wYJz

3N6hQF6HBBQ5JCKB8Xs17Q61wkG3VrLvbGd:  -0.10000000 Waves

2021.11.13 04:45 [1788585] smart account 3N6hQF6HBBQ5JCKB8Xs17Q61wkG3VrLvbGd > SELF 0.00000000 Waves

{ "type": 13, "id": "GzRbzDdEZWxK8ZvcYfTsmZjQqPDSzCvDxzkaDcT3wYJz", "fee": 10000000, "feeAssetId": null, "timestamp": 1636767881835, "version": 2, "chainId": 84, "sender": "3N6hQF6HBBQ5JCKB8Xs17Q61wkG3VrLvbGd", "senderPublicKey": "7Hi4o6vBstRs79NMVMjEove52dmP87RAcvNDAXN8C4Wi", "proofs": [ "5KhW7S1vopFm54FcPfA8u96ffsTTmhzBnjg8me3B25g9zMfgCDEi6EfnTrqdaxANRnzcVKSuFvkbo6F34u3puj6r" ], "script": "base64:AAIFAAAAAAAAAAwIAhIDCgEIEgMKAQgAAAANAAAAAAZjYXNpbm8CAAAAIzNONmhRRjZIQkJRNUpDS0I4WHMxN1E2MXdrRzNWckx2YkdkAAAAAAVXQVZFUwAAAAAAO5rKAAAAAAAGbWF4QmV0CQAAaAAAAAIAAAAAAAAAAGQFAAAABVdBVkVTAAAAAAlzZXBhcmF0b3ICAAAAASwBAAAACmdldE5ld0RlY2sAAAAACQAETAAAAAICAAAAAzAxQwkABEwAAAACAgAAAAMwMkMJAARMAAAAAgIAAAADMDNDCQAETAAAAAICAAAAAzA0QwkABEwAAAACAgAAAAMwNUMJAARMAAAAAgIAAAADMDZDCQAETAAAAAICAAAAAzA3QwkABEwAAAACAgAAAAMwOEMJAARMAAAAAgIAAAADMDlDCQAETAAAAAICAAAAAzEwQwkABEwAAAACAgAAAAMxMUMJAARMAAAAAgIAAAADMTJDCQAETAAAAAICAAAAAzEzQwkABEwAAAACAgAAAAMwMUQJAARMAAAAAgIAAAADMDJECQAETAAAAAICAAAAAzAzRAkABEwAAAACAgAAAAMwNEQJAARMAAAA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ykAAAACBQAAAAR0aGlzCQABLAAAAAIFAAAABW1lS2V5AgAAAAdfd2lubmVyBAAAAAljdXJTdW1CZXQJAQAAABFAZXh0ck5hdGl2ZSgxMDUwKQAAAAIFAAAABHRoaXMJAAEsAAAAAgUAAAAFbWVLZXkCAAAACF9zdW1CZXRzAwkAAAAAAAACBQAAAAljdXJTdW1CZXQAAAAAAAAAAAAJAAACAAAAAQIAAAAaWW91IHdvbiBub3RoaW5nIHRoaXMgcm91bmQDCQAAAAAAAAIFAAAABndpbm5lcgUAAAANY2FsbGVyQWRkcmVzcwkABEwAAAACCQEAAAALU3RyaW5nRW50cnkAAAACBQAAAAt3aXRoZHJhd0tleQkAAaQAAAABBQAAAAljdXJTdW1CZXQJAARMAAAAAgkBAAAADlNjcmlwdFRyYW5zZmVyAAAAAwgFAAAAAWkAAAAGY2FsbGVyBQAAAAljdXJTdW1CZXQFAAAABHVuaXQFAAAAA25pbAkAAAIAAAABAgAAABZZb3UgYXJlIG5vdCB0aGUgd2lubmVyAAAAAQAAAAJ0eAEAAAAGdmVyaWZ5AAAAAAkAAfQAAAADCAUAAAACdHgAAAAJYm9keUJ5dGVzCQABkQAAAAIIBQAAAAJ0eAAAAAZwcm9vZnMAAAAAAAAAAAAIBQAAAAJ0eAAAAA9zZW5kZXJQdWJsaWNLZXky2qMF", "height": 1788585, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 8r6zEhmDQC5HyZvmCqe6vA8AB8WgkWQ54J8s65o4UPHY Next: GDQ1cPy9CCeFH4kceDc89HpCxDzq7DsNNcmt9aXwkDqZ Diff:
OldNewDifferences
11 {-# STDLIB_VERSION 5 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
4+let casino = "3N6hQF6HBBQ5JCKB8Xs17Q61wkG3VrLvbGd"
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 getDeck (deck) = if ((0 >= size(deck)))
16+ then getNewDeck()
17+ else deck
18+
19+
20+func getRandomNumber (salt1,salt2,answersCount) = {
21+ let hash = sha256(toBytes((salt1 + salt2)))
22+ let index = toInt(hash)
23+ let rand = (index % answersCount)
24+ if ((0 > rand))
25+ then ((-1 * rand) + 1)
26+ else (rand + 1)
27+ }
28+
29+
30+func getPreviousRandomNumber (address) = match getInteger(this, (address + "_LastRandonNumber")) {
31+ case n: Int =>
32+ toString(n)
33+ case _ =>
34+ address
35+}
36+
37+
38+func getAmountOrZero (this,key) = match getInteger(this, key) {
39+ case a: Int =>
40+ a
41+ case _ =>
42+ 0
43+}
44+
45+
46+func getPayment (i) = if ((size(i.payments) == 0))
47+ then throw("Payment must be attached")
48+ else {
49+ let pmt = i.payments[0]
50+ if (isDefined(pmt.assetId))
51+ then throw("This function accepts WAVES tokens only")
52+ else pmt.amount
53+ }
54+
55+
56+func getCardValue (stringCard) = parseIntValue(take(stringCard, 2))
57+
58+
59+func getWinner (cardPlayer,cardCasino,callerAddress,casino) = {
60+ let p = getCardValue(cardPlayer)
61+ let o = getCardValue(cardCasino)
62+ if ((p > o))
63+ then callerAddress
64+ else casino
65+ }
66+
67+
68+func getAvailableDeck (this,availableProp) = if (isDefined(getString(this, availableProp)))
69+ then {
70+ let stringDeck = getStringValue(this, availableProp)
71+ let deck = split(stringDeck, separator)
72+ if ((size(deck) == 0))
73+ then getNewDeck()
74+ else deck
75+ }
76+ else getNewDeck()
477
578
679 @Callable(i)
7-func bet2 (round) = {
80+func bet (round) = {
881 let callerAddress = toBase58String(i.caller.bytes)
982 let meKey = ((round + "_") + callerAddress)
10-[StringEntry(meKey, round)]
83+ let p = getPayment(i)
84+ let roundBetsKey = (meKey + "_sumBets")
85+ let curSumBets = getAmountOrZero(this, roundBetsKey)
86+ let currentDraws = match getInteger(this, (meKey + "_drawSequence")) {
87+ case a: Int =>
88+ (a + 1)
89+ case _ =>
90+ 0
91+ }
92+ let availableProp = (meKey + "_available")
93+ let newSumBets = (curSumBets + p)
94+ if (if (isDefined(getBoolean(this, (round + "_stop"))))
95+ then true
96+ else isDefined(getString(this, round)))
97+ then throw("This round is already played")
98+ else if ((newSumBets > maxBet))
99+ then throw(((("Maximum amount of bets for round " + toString(maxBet)) + ". With your bet it's ") + toString(newSumBets)))
100+ else {
101+ let avDeck = getAvailableDeck(this, availableProp)
102+ let cardPositionPlayer = getRandomNumber((meKey + makeString(avDeck, separator)), getPreviousRandomNumber(callerAddress), size(avDeck))
103+ let cardPlayer = avDeck[(cardPositionPlayer % size(avDeck))]
104+ let avDeck1 = removeByIndex(avDeck, (cardPositionPlayer % size(avDeck)))
105+ let avDeck2 = getDeck(avDeck1)
106+ let cardPositionCasino = getRandomNumber((meKey + makeString(avDeck2, separator)), getPreviousRandomNumber(callerAddress), size(avDeck2))
107+ let cardCasino = avDeck2[(cardPositionCasino % size(avDeck2))]
108+ let avDeck3 = removeByIndex(avDeck2, (cardPositionPlayer % size(avDeck2)))
109+ if ((getCardValue(cardPlayer) == getCardValue(cardCasino)))
110+ then [StringEntry(availableProp, makeString(avDeck3, separator)), StringEntry((meKey + "_salt_debug"), meKey), IntegerEntry((meKey + "_LastRandonNumber"), cardPositionCasino), IntegerEntry((meKey + "_sumBets"), newSumBets), StringEntry((meKey + "_playerCard"), cardPlayer), StringEntry((meKey + "_casinoCard"), cardCasino), IntegerEntry((meKey + "_drawSequence"), (currentDraws + 1))]
111+ else {
112+ let winner = getWinner(cardPlayer, cardCasino, callerAddress, casino)
113+[StringEntry(availableProp, makeString(avDeck3, separator)), StringEntry((meKey + "_salt_debug"), meKey), IntegerEntry((meKey + "_LastRandonNumber"), cardPositionCasino), IntegerEntry((meKey + "_sumBets"), newSumBets), StringEntry((meKey + "_playerCard"), cardPlayer), StringEntry((meKey + "_casinoCard"), cardCasino), BooleanEntry((meKey + "_stop"), true), StringEntry((meKey + "_winner"), winner)]
114+ }
115+ }
116+ }
117+
118+
119+
120+@Callable(i)
121+func withdraw (round) = {
122+ let callerAddress = toBase58String(i.caller.bytes)
123+ let meKey = ((round + "_") + callerAddress)
124+ let withdrawKey = (meKey + "_withdraw")
125+ if (isDefined(getString(this, withdrawKey)))
126+ then throw("You have already got your prize")
127+ else if (isDefined(getInteger(this, (meKey + "_drawSequence"))))
128+ then throw("There is no winner, it was a draw")
129+ else if (!(isDefined(getString(this, (meKey + "_winner")))))
130+ then throw("There is no winner")
131+ else {
132+ let winner = getStringValue(this, (meKey + "_winner"))
133+ let curSumBet = getIntegerValue(this, (meKey + "_sumBets"))
134+ if ((curSumBet == 0))
135+ then throw("You won nothing this round")
136+ else if ((winner == callerAddress))
137+ then [StringEntry(withdrawKey, toString(curSumBet)), ScriptTransfer(i.caller, curSumBet, unit)]
138+ else throw("You are not the winner")
139+ }
11140 }
12141
13142
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 5 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
4+let casino = "3N6hQF6HBBQ5JCKB8Xs17Q61wkG3VrLvbGd"
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 getDeck (deck) = if ((0 >= size(deck)))
16+ then getNewDeck()
17+ else deck
18+
19+
20+func getRandomNumber (salt1,salt2,answersCount) = {
21+ let hash = sha256(toBytes((salt1 + salt2)))
22+ let index = toInt(hash)
23+ let rand = (index % answersCount)
24+ if ((0 > rand))
25+ then ((-1 * rand) + 1)
26+ else (rand + 1)
27+ }
28+
29+
30+func getPreviousRandomNumber (address) = match getInteger(this, (address + "_LastRandonNumber")) {
31+ case n: Int =>
32+ toString(n)
33+ case _ =>
34+ address
35+}
36+
37+
38+func getAmountOrZero (this,key) = match getInteger(this, key) {
39+ case a: Int =>
40+ a
41+ case _ =>
42+ 0
43+}
44+
45+
46+func getPayment (i) = if ((size(i.payments) == 0))
47+ then throw("Payment must be attached")
48+ else {
49+ let pmt = i.payments[0]
50+ if (isDefined(pmt.assetId))
51+ then throw("This function accepts WAVES tokens only")
52+ else pmt.amount
53+ }
54+
55+
56+func getCardValue (stringCard) = parseIntValue(take(stringCard, 2))
57+
58+
59+func getWinner (cardPlayer,cardCasino,callerAddress,casino) = {
60+ let p = getCardValue(cardPlayer)
61+ let o = getCardValue(cardCasino)
62+ if ((p > o))
63+ then callerAddress
64+ else casino
65+ }
66+
67+
68+func getAvailableDeck (this,availableProp) = if (isDefined(getString(this, availableProp)))
69+ then {
70+ let stringDeck = getStringValue(this, availableProp)
71+ let deck = split(stringDeck, separator)
72+ if ((size(deck) == 0))
73+ then getNewDeck()
74+ else deck
75+ }
76+ else getNewDeck()
477
578
679 @Callable(i)
7-func bet2 (round) = {
80+func bet (round) = {
881 let callerAddress = toBase58String(i.caller.bytes)
982 let meKey = ((round + "_") + callerAddress)
10-[StringEntry(meKey, round)]
83+ let p = getPayment(i)
84+ let roundBetsKey = (meKey + "_sumBets")
85+ let curSumBets = getAmountOrZero(this, roundBetsKey)
86+ let currentDraws = match getInteger(this, (meKey + "_drawSequence")) {
87+ case a: Int =>
88+ (a + 1)
89+ case _ =>
90+ 0
91+ }
92+ let availableProp = (meKey + "_available")
93+ let newSumBets = (curSumBets + p)
94+ if (if (isDefined(getBoolean(this, (round + "_stop"))))
95+ then true
96+ else isDefined(getString(this, round)))
97+ then throw("This round is already played")
98+ else if ((newSumBets > maxBet))
99+ then throw(((("Maximum amount of bets for round " + toString(maxBet)) + ". With your bet it's ") + toString(newSumBets)))
100+ else {
101+ let avDeck = getAvailableDeck(this, availableProp)
102+ let cardPositionPlayer = getRandomNumber((meKey + makeString(avDeck, separator)), getPreviousRandomNumber(callerAddress), size(avDeck))
103+ let cardPlayer = avDeck[(cardPositionPlayer % size(avDeck))]
104+ let avDeck1 = removeByIndex(avDeck, (cardPositionPlayer % size(avDeck)))
105+ let avDeck2 = getDeck(avDeck1)
106+ let cardPositionCasino = getRandomNumber((meKey + makeString(avDeck2, separator)), getPreviousRandomNumber(callerAddress), size(avDeck2))
107+ let cardCasino = avDeck2[(cardPositionCasino % size(avDeck2))]
108+ let avDeck3 = removeByIndex(avDeck2, (cardPositionPlayer % size(avDeck2)))
109+ if ((getCardValue(cardPlayer) == getCardValue(cardCasino)))
110+ then [StringEntry(availableProp, makeString(avDeck3, separator)), StringEntry((meKey + "_salt_debug"), meKey), IntegerEntry((meKey + "_LastRandonNumber"), cardPositionCasino), IntegerEntry((meKey + "_sumBets"), newSumBets), StringEntry((meKey + "_playerCard"), cardPlayer), StringEntry((meKey + "_casinoCard"), cardCasino), IntegerEntry((meKey + "_drawSequence"), (currentDraws + 1))]
111+ else {
112+ let winner = getWinner(cardPlayer, cardCasino, callerAddress, casino)
113+[StringEntry(availableProp, makeString(avDeck3, separator)), StringEntry((meKey + "_salt_debug"), meKey), IntegerEntry((meKey + "_LastRandonNumber"), cardPositionCasino), IntegerEntry((meKey + "_sumBets"), newSumBets), StringEntry((meKey + "_playerCard"), cardPlayer), StringEntry((meKey + "_casinoCard"), cardCasino), BooleanEntry((meKey + "_stop"), true), StringEntry((meKey + "_winner"), winner)]
114+ }
115+ }
116+ }
117+
118+
119+
120+@Callable(i)
121+func withdraw (round) = {
122+ let callerAddress = toBase58String(i.caller.bytes)
123+ let meKey = ((round + "_") + callerAddress)
124+ let withdrawKey = (meKey + "_withdraw")
125+ if (isDefined(getString(this, withdrawKey)))
126+ then throw("You have already got your prize")
127+ else if (isDefined(getInteger(this, (meKey + "_drawSequence"))))
128+ then throw("There is no winner, it was a draw")
129+ else if (!(isDefined(getString(this, (meKey + "_winner")))))
130+ then throw("There is no winner")
131+ else {
132+ let winner = getStringValue(this, (meKey + "_winner"))
133+ let curSumBet = getIntegerValue(this, (meKey + "_sumBets"))
134+ if ((curSumBet == 0))
135+ then throw("You won nothing this round")
136+ else if ((winner == callerAddress))
137+ then [StringEntry(withdrawKey, toString(curSumBet)), ScriptTransfer(i.caller, curSumBet, unit)]
138+ else throw("You are not the winner")
139+ }
11140 }
12141
13142
14143 @Verifier(tx)
15144 func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
16145

github/deemru/w8io/026f985 
40.04 ms