tx · E4R8Z8aZ6BHTn1pFVdS4SxmzPuMM14zUS6zPVQGo6DXX

3N6hQF6HBBQ5JCKB8Xs17Q61wkG3VrLvbGd:  -0.10000000 Waves

2021.11.13 03:33 [1788515] smart account 3N6hQF6HBBQ5JCKB8Xs17Q61wkG3VrLvbGd > SELF 0.00000000 Waves

{ "type": 13, "id": "E4R8Z8aZ6BHTn1pFVdS4SxmzPuMM14zUS6zPVQGo6DXX", "fee": 10000000, "feeAssetId": null, "timestamp": 1636763735295, "version": 2, "chainId": 84, "sender": "3N6hQF6HBBQ5JCKB8Xs17Q61wkG3VrLvbGd", "senderPublicKey": "7Hi4o6vBstRs79NMVMjEove52dmP87RAcvNDAXN8C4Wi", "proofs": [ "2rFLn4dqZms6oyKon6bw7vJw5e8r2spA7QAbbkWdFBh7EprRBZ5FFtCbYs4S7BCwuUTxAYZ34XEXbhegmubf7jRa" ], "script": "base64:AAIFAAAAAAAAAAcIAhIDCgEIAAAACAAAAAAJc2VwYXJhdG9yAgAAAAEsAAAAAAVXQVZFUwAAAAAAO5rKAAAAAAAGbWF4QmV0CQAAaAAAAAIAAAAAAAAAAGQFAAAABVdBVkVTAQAAAApnZXROZXdEZWNrAAAAAAkABEwAAAACAgAAAAMwMUMJAARMAAAAAgIAAAADMDJDCQAETAAAAAICAAAAAzAzQwkABEwAAAACAgAAAAMwNEMJAARMAAAAAgIAAAADMDVDCQAETAAAAAICAAAAAzA2QwkABEwAAAACAgAAAAMwN0MJAARMAAAAAgIAAAADMDhDCQAETAAAAAICAAAAAzA5QwkABEwAAAACAgAAAAMxMEMJAARMAAAAAgIAAAADMTFDCQAETAAAAAICAAAAAzEyQwkABEwAAAACAgAAAAMxM0MJAARMAAAAAgIAAAADMDFECQAETAAAAAICAAAAAzAyRAkABEwAAAACAgAAAAMwM0QJAARMAAAAAgIAAAADMDRECQAETAAAAAICAAAAAzA1RAkABEwAAAACAgAAAAMwNkQJAARMAAAAAgIAAAADMDdECQAETAAAAAICAAAAAzA4RA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Complexity": 0 } View: original | compacted Prev: 2bymUMbeiD31XfHwj4NbTPgDuJhbKgkhLkAbvbUrnjab Next: 8r6zEhmDQC5HyZvmCqe6vA8AB8WgkWQ54J8s65o4UPHY Diff:
OldNewDifferences
11 {-# STDLIB_VERSION 5 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
4-let oracle = "3MtaCL4v1bjTabUqs7oU4ofS8fbai34WM1i"
4+let separator = ","
55
66 let WAVES = 1000000000
77
88 let maxBet = (100 * WAVES)
9-
10-let separator = ","
119
1210 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"]
1311
1715 else deck
1816
1917
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-}
18+func getAvailableDeck (this,availableProp) = if (isDefined(getString(this, availableProp)))
19+ then {
20+ let stringDeck = getStringValue(this, availableProp)
21+ let deck = split(stringDeck, separator)
22+ if ((size(deck) == 0))
23+ then getNewDeck()
24+ else deck
25+ }
26+ else getNewDeck()
3627
3728
3829 func getAmountOrZero (this,key) = match getInteger(this, key) {
5344 }
5445
5546
56-func getCardValue (stringCard) = parseIntValue(take(stringCard, 2))
57-
58-
59-func getWinner (cardPlayer,cardOracle,callerAddress,oracle) = {
60- let p = getCardValue(cardPlayer)
61- let o = getCardValue(cardOracle)
62- if ((p > o))
63- then callerAddress
64- else oracle
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()
77-
78-
7947 @Callable(i)
80-func bet (round) = {
48+func bet1 (round) = {
8149 let callerAddress = toBase58String(i.caller.bytes)
8250 let meKey = ((round + "_") + callerAddress)
8351 let p = getPayment(i)
9967 then throw(((("Maximum amount of bets for round " + toString(maxBet)) + ". With your bet it's ") + toString(newSumBets)))
10068 else {
10169 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 cardPositionOracle = getRandomNumber((meKey + makeString(avDeck2, separator)), getPreviousRandomNumber(callerAddress), size(avDeck2))
107- let cardOracle = avDeck2[(cardPositionOracle % size(avDeck2))]
108- let avDeck3 = removeByIndex(avDeck2, (cardPositionPlayer % size(avDeck2)))
109- if ((getCardValue(cardPlayer) == getCardValue(cardOracle)))
110- then [IntegerEntry((meKey + "_drawSequence"), (currentDraws + 1))]
111- else {
112- let winner = getWinner(cardPlayer, cardOracle, callerAddress, oracle)
113-[StringEntry((meKey + "_winner"), winner)]
114- }
70+[StringEntry(availableProp, makeString(avDeck, separator))]
11571 }
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- }
14072 }
14173
14274
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 5 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
4-let oracle = "3MtaCL4v1bjTabUqs7oU4ofS8fbai34WM1i"
4+let separator = ","
55
66 let WAVES = 1000000000
77
88 let maxBet = (100 * WAVES)
9-
10-let separator = ","
119
1210 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"]
1311
1412
1513 func getDeck (deck) = if ((0 >= size(deck)))
1614 then getNewDeck()
1715 else deck
1816
1917
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-}
18+func getAvailableDeck (this,availableProp) = if (isDefined(getString(this, availableProp)))
19+ then {
20+ let stringDeck = getStringValue(this, availableProp)
21+ let deck = split(stringDeck, separator)
22+ if ((size(deck) == 0))
23+ then getNewDeck()
24+ else deck
25+ }
26+ else getNewDeck()
3627
3728
3829 func getAmountOrZero (this,key) = match getInteger(this, key) {
3930 case a: Int =>
4031 a
4132 case _ =>
4233 0
4334 }
4435
4536
4637 func getPayment (i) = if ((size(i.payments) == 0))
4738 then throw("Payment must be attached")
4839 else {
4940 let pmt = i.payments[0]
5041 if (isDefined(pmt.assetId))
5142 then throw("This function accepts WAVES tokens only")
5243 else pmt.amount
5344 }
5445
5546
56-func getCardValue (stringCard) = parseIntValue(take(stringCard, 2))
57-
58-
59-func getWinner (cardPlayer,cardOracle,callerAddress,oracle) = {
60- let p = getCardValue(cardPlayer)
61- let o = getCardValue(cardOracle)
62- if ((p > o))
63- then callerAddress
64- else oracle
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()
77-
78-
7947 @Callable(i)
80-func bet (round) = {
48+func bet1 (round) = {
8149 let callerAddress = toBase58String(i.caller.bytes)
8250 let meKey = ((round + "_") + callerAddress)
8351 let p = getPayment(i)
8452 let roundBetsKey = (meKey + "_sumBets")
8553 let curSumBets = getAmountOrZero(this, roundBetsKey)
8654 let currentDraws = match getInteger(this, (meKey + "_drawSequence")) {
8755 case a: Int =>
8856 (a + 1)
8957 case _ =>
9058 0
9159 }
9260 let availableProp = (meKey + "_available")
9361 let newSumBets = (curSumBets + p)
9462 if (if (isDefined(getBoolean(this, (round + "_stop"))))
9563 then true
9664 else isDefined(getString(this, round)))
9765 then throw("This round is already played")
9866 else if ((newSumBets > maxBet))
9967 then throw(((("Maximum amount of bets for round " + toString(maxBet)) + ". With your bet it's ") + toString(newSumBets)))
10068 else {
10169 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 cardPositionOracle = getRandomNumber((meKey + makeString(avDeck2, separator)), getPreviousRandomNumber(callerAddress), size(avDeck2))
107- let cardOracle = avDeck2[(cardPositionOracle % size(avDeck2))]
108- let avDeck3 = removeByIndex(avDeck2, (cardPositionPlayer % size(avDeck2)))
109- if ((getCardValue(cardPlayer) == getCardValue(cardOracle)))
110- then [IntegerEntry((meKey + "_drawSequence"), (currentDraws + 1))]
111- else {
112- let winner = getWinner(cardPlayer, cardOracle, callerAddress, oracle)
113-[StringEntry((meKey + "_winner"), winner)]
114- }
70+[StringEntry(availableProp, makeString(avDeck, separator))]
11571 }
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- }
14072 }
14173
14274
14375 @Verifier(tx)
14476 func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
14577

github/deemru/w8io/026f985 
27.52 ms