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