tx · 6fcajKgAe5ezje9FD4Xp5F2n9aXVs16Q4DE8pMYGWqXP 3Mwuu6do9zBghKKVshUFferCwepiQYcAeVE: -0.01500000 Waves 2019.07.11 16:35 [581100] smart account 3Mwuu6do9zBghKKVshUFferCwepiQYcAeVE > SELF 0.00000000 Waves
{ "type": 13, "id": "6fcajKgAe5ezje9FD4Xp5F2n9aXVs16Q4DE8pMYGWqXP", "fee": 1500000, "feeAssetId": null, "timestamp": 1562852142974, "version": 1, "sender": "3Mwuu6do9zBghKKVshUFferCwepiQYcAeVE", "senderPublicKey": "8fdATo5z3B5EweA3kKoRgbJZhGa4JicyHHMkhBZTvNSf", "proofs": [ "4jTJKsFzE6dfim7UJcGEAwYYMjBEWt8qqHkeVLiMrnJK6T4dfR6w8CJr6kWMrGR4Tuqc9qKmYkGQrKehhChfbJav" ], "script": "base64:AAIDAAAAAAAAAAAAAAANAAAAAAVXYXZlcwAAAAAABfXhAAAAAAAEYmV0MQkAAGgAAAACAAAAAAAAAAABBQAAAAVXYXZlcwAAAAAEYmV0NQkAAGgAAAACAAAAAAAAAAAFBQAAAAVXYXZlcwAAAAAFYmV0MTAJAABoAAAAAgAAAAAAAAAACgUAAAAFV2F2ZXMAAAAABWJldDI1CQAAaAAAAAIAAAAAAAAAABkFAAAABVdhdmVzAAAAAAZiZXQxMDAJAABoAAAAAgAAAAAAAAAAZAUAAAAFV2F2ZXMAAAAACWNvbWlzc2lvbgAAAAAAAExLQAAAAAAPb3JhY2xlUHVibGljS2V5CQACWQAAAAECAAAALEE3N3FwVmt0enQxb0FQeVBmbUtkUHNEWkdSUEp6QnJFM1dUdHVMMUt4TVlMAAAAAA1nYW1lVGltZUZyYW1lAAAAAAAAAAWgAAAAAAhzdGF0ZUFjYwIAAAAIQWNjZXB0ZWQAAAAACHN0YXRlV2luAgAAAANXaW4AAAAADHN0YXRlVGltZW91dAIAAAAMV2luQnlUaW1lb3V0AAAAAAlzdGF0ZUxvc2UCAAAABExvc2UAAAACAAAAAWk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GNoMQUAAAABYQAAAAAAAAAAAAQAAAAQYXZhaWxhYmxlQmFsYW5jZQkAAGUAAAACCQEAAAAMd2F2ZXNCYWxhbmNlAAAAAQUAAAAEdGhpcwUAAAAPcmVzZXJ2ZWRCYWxhbmNlBAAAAA9hdmFpbGlibGVBbW91bnQJAABnAAAAAgUAAAAQYXZhaWxhYmxlQmFsYW5jZQgFAAAAA3R0eAAAAAZhbW91bnQEAAAACXNpZ25hdHVyZQkAAfQAAAADCAUAAAADdHR4AAAACWJvZHlCeXRlcwkAAZEAAAACCAUAAAADdHR4AAAABnByb29mcwAAAAAAAAAAAAgFAAAAA3R0eAAAAA9zZW5kZXJQdWJsaWNLZXkDBQAAAA9hdmFpbGlibGVBbW91bnQFAAAACXNpZ25hdHVyZQcDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAFFNldFNjcmlwdFRyYW5zYWN0aW9uBAAAAARzc3R4BQAAAAckbWF0Y2gwCQAB9AAAAAMIBQAAAARzc3R4AAAACWJvZHlCeXRlcwkAAZEAAAACCAUAAAAEc3N0eAAAAAZwcm9vZnMAAAAAAAAAAAAIBQAAAARzc3R4AAAAD3NlbmRlclB1YmxpY0tleQcTrGHv", "chainId": 84, "height": 581100, "spentComplexity": 0 } View: original | compacted Prev: G4Cqr79JQpGqG9wGvfZK5k8PrDZTpLiDvKkPp7cVF2VM Next: CcXchEfWE3qYvCvYmF4xBxnCPssoKQfX9PSpQQaBQQR8 Full:
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | let string = "10.10" | |
4 | + | let Waves = 100000000 | |
5 | + | ||
6 | + | let bet1 = (1 * Waves) | |
7 | + | ||
8 | + | let bet5 = (5 * Waves) | |
9 | + | ||
10 | + | let bet10 = (10 * Waves) | |
11 | + | ||
12 | + | let bet25 = (25 * Waves) | |
13 | + | ||
14 | + | let bet100 = (100 * Waves) | |
15 | + | ||
16 | + | let comission = 5000000 | |
17 | + | ||
18 | + | let oraclePublicKey = fromBase58String("A77qpVktzt1oAPyPfmKdPsDZGRPJzBrE3WTtuL1KxMYL") | |
19 | + | ||
20 | + | let gameTimeFrame = 1440 | |
21 | + | ||
22 | + | let stateAcc = "Accepted" | |
23 | + | ||
24 | + | let stateWin = "Win" | |
25 | + | ||
26 | + | let stateTimeout = "WinByTimeout" | |
27 | + | ||
28 | + | let stateLose = "Lose" | |
5 | 29 | ||
6 | 30 | @Callable(i) | |
7 | - | func a (testNum) = { | |
8 | - | let newList = split(string, ".") | |
9 | - | let element1 = parseIntValue(newList[0]) | |
10 | - | let element2 = parseIntValue(newList[1]) | |
11 | - | WriteSet([DataEntry((testNum + "_elem1"), element1), DataEntry((testNum + "_elem2"), element2)]) | |
31 | + | func bet (choice) = { | |
32 | + | let pmnt = extract(i.payment) | |
33 | + | let gameId = toBase58String(i.transactionId) | |
34 | + | let gameStart = height | |
35 | + | let gameCounter = { | |
36 | + | let gameNumber = { | |
37 | + | let counterValue = getInteger(this, "GamesCounter") | |
38 | + | match counterValue { | |
39 | + | case p: Int => | |
40 | + | p | |
41 | + | case _ => | |
42 | + | 0 | |
43 | + | } | |
44 | + | } | |
45 | + | (gameNumber + 1) | |
46 | + | } | |
47 | + | let betAssetIdCheck = isDefined(pmnt.assetId) | |
48 | + | let playerPublicKey = toBase58String(i.callerPublicKey) | |
49 | + | let playerChoice = if (if ((choice == "1")) | |
50 | + | then true | |
51 | + | else (choice == "2")) | |
52 | + | then choice | |
53 | + | else throw("Player's choice is incorrect") | |
54 | + | let playerPrize = { | |
55 | + | let bet = (pmnt.amount - comission) | |
56 | + | if (if (if (if (if ((bet == bet1)) | |
57 | + | then true | |
58 | + | else (bet == bet5)) | |
59 | + | then true | |
60 | + | else (bet == bet10)) | |
61 | + | then true | |
62 | + | else (bet == bet25)) | |
63 | + | then true | |
64 | + | else (bet == bet100)) | |
65 | + | then (bet * 2) | |
66 | + | else throw("Payment amount is incorrect") | |
67 | + | } | |
68 | + | let reservedBalance = { | |
69 | + | let currentReservedBalance = { | |
70 | + | let valueReservedBalance = getInteger(this, "Reserved") | |
71 | + | match valueReservedBalance { | |
72 | + | case a: Int => | |
73 | + | a | |
74 | + | case _ => | |
75 | + | 0 | |
76 | + | } | |
77 | + | } | |
78 | + | let newReservedBalance = (currentReservedBalance + playerPrize) | |
79 | + | if ((wavesBalance(this) >= newReservedBalance)) | |
80 | + | then { | |
81 | + | let increaseReservedBalance = newReservedBalance | |
82 | + | increaseReservedBalance | |
83 | + | } | |
84 | + | else throw("Bet was rejected. Insufficient funds on game account.") | |
85 | + | } | |
86 | + | if (betAssetIdCheck) | |
87 | + | then throw("You can make bet in Waves only") | |
88 | + | else { | |
89 | + | let dataString = ((((((((stateAcc + "_") + playerPublicKey) + "_") + playerChoice) + "_") + toString(playerPrize)) + "_") + toString(gameStart)) | |
90 | + | WriteSet([DataEntry("Reserved", reservedBalance), DataEntry(gameId, dataString)]) | |
91 | + | } | |
92 | + | } | |
93 | + | ||
94 | + | ||
95 | + | ||
96 | + | @Callable(i) | |
97 | + | func withdraw (gameId,rsaSign) = { | |
98 | + | let dataList = { | |
99 | + | let getDataString = getString(this, gameId) | |
100 | + | let a = match getDataString { | |
101 | + | case a: String => | |
102 | + | a | |
103 | + | case _ => | |
104 | + | throw("GameId was not found") | |
105 | + | } | |
106 | + | split(a, "_") | |
107 | + | } | |
108 | + | let gameState = dataList[0] | |
109 | + | let playerAddress = { | |
110 | + | let a = dataList[1] | |
111 | + | addressFromPublicKey(fromBase58String(a)) | |
112 | + | } | |
113 | + | let playerChoice = dataList[2] | |
114 | + | let rsaToInt = { | |
115 | + | let rsaCheck = rsaVerify(SHA256, toBytes(gameId), rsaSign, oraclePublicKey) | |
116 | + | if (rsaCheck) | |
117 | + | then { | |
118 | + | let rsaInt = ((toInt(sha256(rsaSign)) % 99) + 1) | |
119 | + | if (if ((rsaInt > 0)) | |
120 | + | then (100 >= rsaInt) | |
121 | + | else false) | |
122 | + | then rsaInt | |
123 | + | else throw("Rsa integer is not in range") | |
124 | + | } | |
125 | + | else throw("Rsa Signature is invalid") | |
126 | + | } | |
127 | + | let gameStart = { | |
128 | + | let a = dataList[4] | |
129 | + | parseIntValue(a) | |
130 | + | } | |
131 | + | let playerPrize = { | |
132 | + | let a = dataList[3] | |
133 | + | parseIntValue(a) | |
134 | + | } | |
135 | + | let newReservedBalance = { | |
136 | + | let valueReservedBalance = getInteger(this, "Reserved") | |
137 | + | let extractReservedBalance = match valueReservedBalance { | |
138 | + | case a: Int => | |
139 | + | a | |
140 | + | case _ => | |
141 | + | 0 | |
142 | + | } | |
143 | + | let decreaseReservedBalance = (extractReservedBalance - playerPrize) | |
144 | + | if ((decreaseReservedBalance > 0)) | |
145 | + | then decreaseReservedBalance | |
146 | + | else throw("Reserved balance couldn't be less than 0") | |
147 | + | } | |
148 | + | let stringForNewData = ((((((dataList[1] + "_") + dataList[2]) + "_") + dataList[3]) + "_") + dataList[4]) | |
149 | + | let gameTime = (gameTimeFrame > (height - gameStart)) | |
150 | + | let stateCheck = (gameState == stateAcc) | |
151 | + | if (stateCheck) | |
152 | + | then if (gameTime) | |
153 | + | then { | |
154 | + | let playerWin = { | |
155 | + | let rsaToState = if ((48 > rsaToInt)) | |
156 | + | then "1" | |
157 | + | else if ((rsaToInt > 52)) | |
158 | + | then "2" | |
159 | + | else "3" | |
160 | + | (rsaToState == playerChoice) | |
161 | + | } | |
162 | + | if (playerWin) | |
163 | + | then ScriptResult(WriteSet([DataEntry(gameId, ((((stateWin + "_") + stringForNewData) + "_") + toString(rsaToInt))), DataEntry("Reserved", newReservedBalance)]), TransferSet([ScriptTransfer(playerAddress, playerPrize, unit)])) | |
164 | + | else WriteSet([DataEntry(gameId, ((((stateLose + "_") + stringForNewData) + "_") + toString(rsaToInt))), DataEntry("Reserved", newReservedBalance)]) | |
165 | + | } | |
166 | + | else throw("Game state is invalid") | |
167 | + | else ScriptResult(WriteSet([DataEntry(gameId, ((((stateTimeout + "_") + stringForNewData) + "_") + "00")), DataEntry("Reserved", newReservedBalance)]), TransferSet([ScriptTransfer(playerAddress, playerPrize, unit)])) | |
12 | 168 | } | |
13 | 169 | ||
14 | 170 | ||
15 | 171 | @Verifier(tx) | |
16 | - | func verify () = true | |
172 | + | func verify () = match tx { | |
173 | + | case ttx: TransferTransaction => | |
174 | + | let valueReservedBalance = getInteger(this, "Reserved") | |
175 | + | let reservedBalance = match valueReservedBalance { | |
176 | + | case a: Int => | |
177 | + | a | |
178 | + | case _ => | |
179 | + | 0 | |
180 | + | } | |
181 | + | let availableBalance = (wavesBalance(this) - reservedBalance) | |
182 | + | let availibleAmount = (availableBalance >= ttx.amount) | |
183 | + | let signature = sigVerify(ttx.bodyBytes, ttx.proofs[0], ttx.senderPublicKey) | |
184 | + | if (availibleAmount) | |
185 | + | then signature | |
186 | + | else false | |
187 | + | case sstx: SetScriptTransaction => | |
188 | + | sigVerify(sstx.bodyBytes, sstx.proofs[0], sstx.senderPublicKey) | |
189 | + | case _ => | |
190 | + | false | |
191 | + | } | |
17 | 192 |
github/deemru/w8io/169f3d6 46.63 ms ◑