tx · 4SoGwsL49AgNYEq25PYejjj2xQnmhtzaFZiLi74r4x8P 3Mp4CwaPCH1nQv7aGthPpkAd1CqGfu2cNCt: -0.01500000 Waves 2020.04.29 19:39 [976312] smart account 3Mp4CwaPCH1nQv7aGthPpkAd1CqGfu2cNCt > SELF 0.00000000 Waves
{ "type": 13, "id": "4SoGwsL49AgNYEq25PYejjj2xQnmhtzaFZiLi74r4x8P", "fee": 1500000, "feeAssetId": null, "timestamp": 1588178479757, "version": 1, "sender": "3Mp4CwaPCH1nQv7aGthPpkAd1CqGfu2cNCt", "senderPublicKey": "GXakSD9KC2Pj1Hs5beSSPFhbKdD2vQo6H71AQXHb2m92", "proofs": [ "XUsPhRSjfYjTLLTfDAyBXN4jQCcGpccEYKL9qbQHwEtUmyvkvYPHuTaosXbpbvnJyJsbjtsjBtKY4UyYWFZ6bBt" ], "script": "base64:AAIDAAAAAAAAAA0IARIDCgEIEgQKAggCAAAALgAAAAAGV0FWRVNEAAAAAAAF9eEAAAAAAAVVU0RORAAAAAAAAA9CQAAAAAAIREVDSU1BTFMJAARMAAAAAgUAAAAGV0FWRVNECQAETAAAAAIFAAAABVVTRE5EBQAAAANuaWwAAAAABkFTU0VUUwkABEwAAAACBQAAAAR1bml0CQAETAAAAAIJAAJZAAAAAQIAAAAsM0tGWEJHR0xDakE1WjJEdVc0RHE5ZkREckhqSkpQMVpFa2FvYWpTenVLc0MFAAAAA25pbAAAAAAKQ09NTUlTU0lPTgkABEwAAAACCQAAaQAAAAIJAABoAAAAAgAAAAAAAAAABQUAAAAGV0FWRVNEAAAAAAAAAAPoCQAETAAAAAIJAABoAAAAAgkAAGkAAAACCQAAaAAAAAIAAAAAAAAAAAUFAAAABVVTRE5EAAAAAAAAAAPoAAAAAAAAAAAKBQAAAANuaWwBAAAADWdldENvbW1pc3Npb24AAAABAAAAB2Fzc2V0SWQJAAGRAAAAAgUAAAAKQ09NTUlTU0lPTgUAAAAHYXNzZXRJZAAAAAAJUlNBUFVCTElDCQAC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1hdGNoMAIAAAATVHJhbnNmZXJUcmFuc2FjdGlvbgQAAAADdHR4BQAAAAckbWF0Y2gwBAAAAAdhc3NldElkCQEAAAAVdmFsaWRhdGVBbmRHZXRBc3NldElkAAAAAQgFAAAAA3R0eAAAAAdhc3NldElkCQAAZwAAAAIJAABlAAAAAgkAA+sAAAACBQAAAAR0aGlzCAUAAAADdHR4AAAAB2Fzc2V0SWQIBQAAAAN0dHgAAAAGYW1vdW50CQEAAAAIZ2V0SW50T3IAAAACCQABkQAAAAIFAAAADlJFU0VSVkFUSU9OS0VZBQAAAAdhc3NldElkAAAAAAAAAAAAAwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAABRTZXRTY3JpcHRUcmFuc2FjdGlvbgQAAAADc3R4BQAAAAckbWF0Y2gwAwkAAAAAAAACCQEAAAAIZ2V0SW50T3IAAAACCQABkQAAAAIFAAAADlJFU0VSVkFUSU9OS0VZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACQAAAAAAAAIJAQAAAAhnZXRJbnRPcgAAAAIJAAGRAAAAAgUAAAAOUkVTRVJWQVRJT05LRVkAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAHBweV6wn9", "chainId": 84, "height": 976312, "spentComplexity": 0 } View: original | compacted Prev: none Next: none Full:
Old | New | Differences | |
---|---|---|---|
1 | - | # no script | |
1 | + | {-# STDLIB_VERSION 3 #-} | |
2 | + | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | + | {-# CONTENT_TYPE DAPP #-} | |
4 | + | let WAVESD = 100000000 | |
5 | + | ||
6 | + | let USDND = 1000000 | |
7 | + | ||
8 | + | let DECIMALS = [WAVESD, USDND] | |
9 | + | ||
10 | + | let ASSETS = [unit, fromBase58String("3KFXBGGLCjA5Z2DuW4Dq9fDDrHjJJP1ZEkaoajSzuKsC")] | |
11 | + | ||
12 | + | let COMMISSION = [((5 * WAVESD) / 1000), (((5 * USDND) / 1000) * 10)] | |
13 | + | ||
14 | + | func getCommission (assetId) = COMMISSION[assetId] | |
15 | + | ||
16 | + | ||
17 | + | let RSAPUBLIC = fromBase64String("base64:MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAmpuXcI/o4pIB5ywv9DOOGapTBUwRVlM/6+H6hFelOXtkrwY/YItmPxEDpz7rAerQPQe9tDPEaAv/GnlEztybOFXgu9DzDe8YoMRD1vakgoAcogmbY58QD6KMj5HkoVj/yTNIc9szj5qhIlrAdmb3KLL6hQU7y8+Jj69BWVPsaQgkspSdeYtb1tHQc7t95n7OZ56r2A7G3+bQf6nSMkPkAhIrEpbCm58oiGBczdTd/LqFSVotZsbL7Yh6SHLfnHeD+QgcfJrnam8OHMGJEJTRXjILeHGjlRCP8oVpioHry1S2xPx5sVzIm2MM+CzYenAGlo0j26atBhiULoTulwD3pQIDAQAB") | |
18 | + | ||
19 | + | let SERVER = addressFromStringValue("3N4Aib5iubWiGMzdTh6wWiVDVbo32oeVUmH") | |
20 | + | ||
21 | + | let RANDORACLETIMEFRAME = 4320 | |
22 | + | ||
23 | + | let BET1 = 1 | |
24 | + | ||
25 | + | let BET2 = 2 | |
26 | + | ||
27 | + | let BET4 = 4 | |
28 | + | ||
29 | + | let BET8 = 8 | |
30 | + | ||
31 | + | let BET14 = 14 | |
32 | + | ||
33 | + | let RATEMULT = 10000 | |
34 | + | ||
35 | + | let RATE1 = 39655 | |
36 | + | ||
37 | + | let RATE2 = 24600 | |
38 | + | ||
39 | + | let RATE3 = 19000 | |
40 | + | ||
41 | + | let RATE4 = 14200 | |
42 | + | ||
43 | + | let RATE5 = 11400 | |
44 | + | ||
45 | + | let RATES = [RATE1, RATE2, RATE3, RATE4, RATE5] | |
46 | + | ||
47 | + | let BETS = [BET1, BET2, BET4, BET8, BET14] | |
48 | + | ||
49 | + | let IdxGameState = 0 | |
50 | + | ||
51 | + | let IdxPlayerChoice = 1 | |
52 | + | ||
53 | + | let IdxPlayerPubKey58 = 2 | |
54 | + | ||
55 | + | let IdxStartedHeight = 3 | |
56 | + | ||
57 | + | let IdxWinAmount = 4 | |
58 | + | ||
59 | + | let IdxAssetId = 5 | |
60 | + | ||
61 | + | let RESERVATIONKEY = ["$RESERVED_AMOUNT_WAVES", "$RESERVED_AMOUNT_USDN"] | |
62 | + | ||
63 | + | let GAMESCOUNTERKEY = "$GAME_NUM" | |
64 | + | ||
65 | + | let STATESUBMITTED = "SUBMITTED" | |
66 | + | ||
67 | + | let STATEWON = "WON" | |
68 | + | ||
69 | + | let STATELOST = "LOST" | |
70 | + | ||
71 | + | func getIntOr (key,default) = if (isDefined(getInteger(this, key))) | |
72 | + | then getIntegerValue(this, key) | |
73 | + | else default | |
74 | + | ||
75 | + | ||
76 | + | func setInt (key,value) = DataEntry(key, value) | |
77 | + | ||
78 | + | ||
79 | + | func incrementInt (key) = setInt(key, (getIntOr(key, -1) + 1)) | |
80 | + | ||
81 | + | ||
82 | + | func changeInt (key,by) = setInt(key, (getIntOr(key, 0) + by)) | |
83 | + | ||
84 | + | ||
85 | + | func increaseReserveAmount (winAmount,assetId) = { | |
86 | + | let newReservedAmount = (getIntOr(RESERVATIONKEY[assetId], 0) + winAmount) | |
87 | + | if ((newReservedAmount > wavesBalance(this))) | |
88 | + | then throw("Insufficient funds on Dice Roller account. Transaction was rejected for your safety.") | |
89 | + | else newReservedAmount | |
90 | + | } | |
91 | + | ||
92 | + | ||
93 | + | func decreaseReservedAmount (gameId,assetId,winAmount) = if ((0 > (getIntOr(RESERVATIONKEY[assetId], 0) - winAmount))) | |
94 | + | then throw("Invalid Dice Roller account state - reserved amount is less than 0") | |
95 | + | else changeInt(RESERVATIONKEY[assetId], -(winAmount)) | |
96 | + | ||
97 | + | ||
98 | + | func validateAndGetAssetId (assetId) = if ((assetId == ASSETS[0])) | |
99 | + | then 0 | |
100 | + | else if ((assetId == ASSETS[1])) | |
101 | + | then 1 | |
102 | + | else throw("Invalid payment asset") | |
103 | + | ||
104 | + | ||
105 | + | func validateBetAndGetWinAmount (betAmount,assetId,playerChoice) = { | |
106 | + | let dicesCount = size(playerChoice) | |
107 | + | let commission = getCommission(assetId) | |
108 | + | func checkAmount (a,x) = if (a) | |
109 | + | then true | |
110 | + | else (betAmount == ((x * DECIMALS[assetId]) + commission)) | |
111 | + | ||
112 | + | if (!({ | |
113 | + | let $list46494682 = BETS | |
114 | + | let $size46494682 = size($list46494682) | |
115 | + | let $acc046494682 = false | |
116 | + | if (($size46494682 == 0)) | |
117 | + | then $acc046494682 | |
118 | + | else { | |
119 | + | let $acc146494682 = checkAmount($acc046494682, $list46494682[0]) | |
120 | + | if (($size46494682 == 1)) | |
121 | + | then $acc146494682 | |
122 | + | else { | |
123 | + | let $acc246494682 = checkAmount($acc146494682, $list46494682[1]) | |
124 | + | if (($size46494682 == 2)) | |
125 | + | then $acc246494682 | |
126 | + | else { | |
127 | + | let $acc346494682 = checkAmount($acc246494682, $list46494682[2]) | |
128 | + | if (($size46494682 == 3)) | |
129 | + | then $acc346494682 | |
130 | + | else { | |
131 | + | let $acc446494682 = checkAmount($acc346494682, $list46494682[3]) | |
132 | + | if (($size46494682 == 4)) | |
133 | + | then $acc446494682 | |
134 | + | else { | |
135 | + | let $acc546494682 = checkAmount($acc446494682, $list46494682[4]) | |
136 | + | if (($size46494682 == 5)) | |
137 | + | then $acc546494682 | |
138 | + | else { | |
139 | + | let $acc646494682 = checkAmount($acc546494682, $list46494682[5]) | |
140 | + | throw("List size exceed 5") | |
141 | + | } | |
142 | + | } | |
143 | + | } | |
144 | + | } | |
145 | + | } | |
146 | + | } | |
147 | + | })) | |
148 | + | then throw("Bet amount is not valid") | |
149 | + | else if ((parseInt(playerChoice) == unit)) | |
150 | + | then throw("Invalid player's choice") | |
151 | + | else if (if ((1 > dicesCount)) | |
152 | + | then true | |
153 | + | else (dicesCount > 5)) | |
154 | + | then throw("Invalid dices count in player's choice") | |
155 | + | else { | |
156 | + | let bet = (betAmount - commission) | |
157 | + | ((bet * RATES[(dicesCount - 1)]) / RATEMULT) | |
158 | + | } | |
159 | + | } | |
160 | + | ||
161 | + | ||
162 | + | func generateRandChoise (gameId,rsaSign) = { | |
163 | + | let rsaSigValid = rsaVerify(SHA256, toBytes(gameId), rsaSign, RSAPUBLIC) | |
164 | + | if (!(rsaSigValid)) | |
165 | + | then throw("Invalid RSA signature") | |
166 | + | else { | |
167 | + | let rand = (toInt(sha256(rsaSign)) % 6) | |
168 | + | let result = if ((0 > rand)) | |
169 | + | then (-1 * rand) | |
170 | + | else rand | |
171 | + | toString((result + 1)) | |
172 | + | } | |
173 | + | } | |
174 | + | ||
175 | + | ||
176 | + | func isPlayerWin (playerChoice,randChoise) = { | |
177 | + | let s = size(playerChoice) | |
178 | + | func check (a,x) = if (a) | |
179 | + | then true | |
180 | + | else if ((s >= x)) | |
181 | + | then (take(drop(playerChoice, (x - 1)), 1) == randChoise) | |
182 | + | else false | |
183 | + | ||
184 | + | let $list55635597 = [1, 2, 3, 4, 5] | |
185 | + | let $size55635597 = size($list55635597) | |
186 | + | let $acc055635597 = false | |
187 | + | if (($size55635597 == 0)) | |
188 | + | then $acc055635597 | |
189 | + | else { | |
190 | + | let $acc155635597 = check($acc055635597, $list55635597[0]) | |
191 | + | if (($size55635597 == 1)) | |
192 | + | then $acc155635597 | |
193 | + | else { | |
194 | + | let $acc255635597 = check($acc155635597, $list55635597[1]) | |
195 | + | if (($size55635597 == 2)) | |
196 | + | then $acc255635597 | |
197 | + | else { | |
198 | + | let $acc355635597 = check($acc255635597, $list55635597[2]) | |
199 | + | if (($size55635597 == 3)) | |
200 | + | then $acc355635597 | |
201 | + | else { | |
202 | + | let $acc455635597 = check($acc355635597, $list55635597[3]) | |
203 | + | if (($size55635597 == 4)) | |
204 | + | then $acc455635597 | |
205 | + | else { | |
206 | + | let $acc555635597 = check($acc455635597, $list55635597[4]) | |
207 | + | if (($size55635597 == 5)) | |
208 | + | then $acc555635597 | |
209 | + | else { | |
210 | + | let $acc655635597 = check($acc555635597, $list55635597[5]) | |
211 | + | throw("List size exceed 5") | |
212 | + | } | |
213 | + | } | |
214 | + | } | |
215 | + | } | |
216 | + | } | |
217 | + | } | |
218 | + | } | |
219 | + | ||
220 | + | ||
221 | + | func formatGameData (gameState,playerChoice,playerPubKey58,startedHeight,winAmount,assetId,randOrEmpty) = (((((((((((gameState + "_") + playerChoice) + "_") + playerPubKey58) + "_") + toString(startedHeight)) + "_") + toString(winAmount)) + "_") + toString(assetId)) + (if ((randOrEmpty == "")) | |
222 | + | then "" | |
223 | + | else ("_" + randOrEmpty))) | |
224 | + | ||
225 | + | ||
226 | + | func extractGameData (gameId) = split(match getString(this, gameId) { | |
227 | + | case str: String => | |
228 | + | str | |
229 | + | case _ => | |
230 | + | throw((("Game: " + gameId) + " not found.")) | |
231 | + | }, "_") | |
232 | + | ||
233 | + | ||
234 | + | func winScriptSet (gameId,playerAddress,winAmount,assetId,newgameData,winByTimeout,decreasedReserves) = { | |
235 | + | let wSetCommonData = [decreasedReserves] | |
236 | + | let tSetCommonData = [ScriptTransfer(playerAddress, winAmount, ASSETS[assetId])] | |
237 | + | if (winByTimeout) | |
238 | + | then { | |
239 | + | let newgameDataAdjusted = (newgameData + "_TIMEOUT") | |
240 | + | let gameData = DataEntry(gameId, newgameDataAdjusted) | |
241 | + | ScriptResult(WriteSet(gameData :: wSetCommonData), TransferSet(tSetCommonData)) | |
242 | + | } | |
243 | + | else { | |
244 | + | let gameData = DataEntry(gameId, newgameData) | |
245 | + | ScriptResult(WriteSet(gameData :: wSetCommonData), TransferSet(tSetCommonData)) | |
246 | + | } | |
247 | + | } | |
248 | + | ||
249 | + | ||
250 | + | @Callable(i) | |
251 | + | func bet (playerChoice) = { | |
252 | + | let gameId = toBase58String(i.transactionId) | |
253 | + | if ((i.payment == unit)) | |
254 | + | then throw("No payment") | |
255 | + | else if (isDefined(getString(this, gameId))) | |
256 | + | then throw((("Bet for: " + gameId) + " was already made.")) | |
257 | + | else { | |
258 | + | let p = extract(i.payment) | |
259 | + | let assetId = validateAndGetAssetId(p.assetId) | |
260 | + | let commission = getCommission(assetId) | |
261 | + | let winAmount = validateBetAndGetWinAmount(p.amount, assetId, playerChoice) | |
262 | + | let playerPubKey58 = toBase58String(i.callerPublicKey) | |
263 | + | let gameData = formatGameData(STATESUBMITTED, playerChoice, playerPubKey58, height, winAmount, assetId, "") | |
264 | + | ScriptResult(WriteSet([DataEntry(RESERVATIONKEY[assetId], increaseReserveAmount(winAmount, assetId)), incrementInt(GAMESCOUNTERKEY), DataEntry(gameId, gameData)]), TransferSet([ScriptTransfer(SERVER, commission, p.assetId)])) | |
265 | + | } | |
266 | + | } | |
267 | + | ||
268 | + | ||
269 | + | ||
270 | + | @Callable(i) | |
271 | + | func withdraw (gameId,rsaSign) = { | |
272 | + | let gameData = extractGameData(gameId) | |
273 | + | let gameState = gameData[IdxGameState] | |
274 | + | let playerChoice = gameData[IdxPlayerChoice] | |
275 | + | let startedHeight = parseIntValue(gameData[IdxStartedHeight]) | |
276 | + | let winAmount = parseIntValue(gameData[IdxWinAmount]) | |
277 | + | let assetId = parseIntValue(gameData[IdxAssetId]) | |
278 | + | let playerPubKey58 = gameData[IdxPlayerPubKey58] | |
279 | + | let playerAddress = addressFromPublicKey(fromBase58String(playerPubKey58)) | |
280 | + | let winByTimeout = ((height - startedHeight) > RANDORACLETIMEFRAME) | |
281 | + | let decreasedReserves = decreaseReservedAmount(gameId, assetId, winAmount) | |
282 | + | if ((gameState != STATESUBMITTED)) | |
283 | + | then throw("Invalid game state for passed gameId") | |
284 | + | else if (winByTimeout) | |
285 | + | then { | |
286 | + | let randChoise = take(playerChoice, 1) | |
287 | + | let newgameData = formatGameData(STATEWON, playerChoice, playerPubKey58, startedHeight, winAmount, assetId, randChoise) | |
288 | + | winScriptSet(gameId, playerAddress, winAmount, assetId, newgameData, winByTimeout, decreasedReserves) | |
289 | + | } | |
290 | + | else { | |
291 | + | let randChoise = generateRandChoise(gameId, rsaSign) | |
292 | + | if ((i.caller != SERVER)) | |
293 | + | then throw("Regular withdraw can be done by server only") | |
294 | + | else if (isPlayerWin(playerChoice, randChoise)) | |
295 | + | then { | |
296 | + | let newgameData = formatGameData(STATEWON, playerChoice, playerPubKey58, startedHeight, winAmount, assetId, randChoise) | |
297 | + | winScriptSet(gameId, playerAddress, winAmount, assetId, newgameData, winByTimeout, decreasedReserves) | |
298 | + | } | |
299 | + | else { | |
300 | + | let newgameData = formatGameData(STATELOST, playerChoice, playerPubKey58, startedHeight, winAmount, assetId, randChoise) | |
301 | + | WriteSet([DataEntry(gameId, newgameData), decreasedReserves]) | |
302 | + | } | |
303 | + | } | |
304 | + | } | |
305 | + | ||
306 | + | ||
307 | + | @Verifier(tx) | |
308 | + | func verify () = if (sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)) | |
309 | + | then match tx { | |
310 | + | case ttx: TransferTransaction => | |
311 | + | let assetId = validateAndGetAssetId(ttx.assetId) | |
312 | + | ((assetBalance(this, ttx.assetId) - ttx.amount) >= getIntOr(RESERVATIONKEY[assetId], 0)) | |
313 | + | case stx: SetScriptTransaction => | |
314 | + | if ((getIntOr(RESERVATIONKEY[0], 0) == 0)) | |
315 | + | then (getIntOr(RESERVATIONKEY[1], 0) == 0) | |
316 | + | else false | |
317 | + | case _ => | |
318 | + | false | |
319 | + | } | |
320 | + | else false | |
321 | + |
github/deemru/w8io/026f985 22.82 ms ◑