tx · FwfpqDPfs3EvW1znFgeaBgWkz9oSo2YyLTkwEc4xbs2w 3N2tusqAtDctK8iSTXS6F9rimmftmSuwLUX: -0.05000000 Waves 2019.10.29 06:19 [740884] smart account 3N2tusqAtDctK8iSTXS6F9rimmftmSuwLUX > SELF 0.00000000 Waves
{ "type": 13, "id": "FwfpqDPfs3EvW1znFgeaBgWkz9oSo2YyLTkwEc4xbs2w", "fee": 5000000, "feeAssetId": null, "timestamp": 1572319171585, "version": 1, "sender": "3N2tusqAtDctK8iSTXS6F9rimmftmSuwLUX", "senderPublicKey": "ACfUG5PwG2GssMuyEwVEhkYAbbbP1geSHR8XoNxLyu6V", "proofs": [ "5yCX93tbQS74Vv7DJXARH8omvKhypSbEXu4V1vtLDwAUhYnpcno6TcQhdYGMGstLo7eiFWm1fgn6PANT5RsbhCQZ" ], "script": "base64:AAIDAAAAAAAAAAcIARIDCgEIAAAAHQAAAAAJUlNBUFVCTElDCQACWwAAAAECAAABj2Jhc2U2NDpNSUlCSWpBTkJna3Foa2lHOXcwQkFRRUZBQU9DQVE4QU1JSUJDZ0tDQVFFQWc0ZEFSNlhiQkRBUzloci9FajNkSnY2RmZjNDY2eC9tT0dNV1UzbHJBQnMzcWE4QkhtdUpHbmtmYnBFZjJ2QXdZVE9XUHZ2emZNMTBPQmJmbG9TeXEzYzlNS3Z5VGUxbHVCTEdxVzR2WlVYSXl2U2d6MWxpeVVWZWZJUXkzZHlGOWpiZVRaYkMwYmJjVC83TzNERUwrMDF6NkErckRDYWNTWjBsR29sU1E2QW5oTHh6SWtWcE9RSmJyQm1DK3grWnVaUENNV3pKeW5kNWFlT243amFqL21rUlZ5eGU2Zy8wT2hXejROaWlaWGV1TVJCKzhtS3kwZldEL1VsSWxaV0hzQVMyWm1ya1hLcWpMcTAvMHdyOElMSmt6bmpTcWRuSTVJYmpnM3VRcmovNEFOK2k5cjI4YVE3My9aa1B0WTVTYncwQU9pQUJCdTdnSG1xOWF5VnhaUUlEQVFBQgAAAAAPR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ZXRBbmREZWZpbmVXaW5BbXQAAAADCAUAAAAHcGF5bWVudAAAAAZhbW91bnQFAAAABnBhQ29pbgUAAAAHcGF5VHlwZQQAAAALZ2FtZURhdGFTdHIJAQAAABFGb3JtYXRHYW1lRGF0YVN0cgAAAAgFAAAADlNUQVRFU1VCTUlUVEVEBQAAAAZwYUNvaW4FAAAAD3BsYXllckFQdWJLZXk1OAUAAAAHcGF5VHlwZQgFAAAAB3BheW1lbnQAAAAGYW1vdW50BQAAAAZ3aW5BbXQCAAAAAAIAAAAACQEAAAAMU2NyaXB0UmVzdWx0AAAAAgkBAAAACFdyaXRlU2V0AAAAAQkABEwAAAACCQEAAAAJRGF0YUVudHJ5AAAAAgUAAAAPR0FNRVNDT1VOVEVSS0VZBQAAAApuZXdHYW1lTnVtCQAETAAAAAIJAQAAAAlEYXRhRW50cnkAAAACBQAAAAZnYW1lSWQFAAAAC2dhbWVEYXRhU3RyBQAAAANuaWwJAQAAAAtUcmFuc2ZlclNldAAAAAEFAAAAA25pbAAAAABNwl2d", "chainId": 84, "height": 740884, "spentComplexity": 0 } View: original | compacted Prev: C7EMUrbJvfo1YZd8n7fR7Lkr2Pw1skyDk2qsFFN93Kwz Next: 7gBhkZkMAsTDKCE6Z8rkRCqo7TFruS5BqVzJmLhcaxde Diff:
Old | New | Differences | |
---|---|---|---|
5 | 5 | ||
6 | 6 | let b = "$GAME_NUM" | |
7 | 7 | ||
8 | - | let c = | |
8 | + | let c = base58'23vgV9p9pD83A7CFbsDEc4zjanep7UeFo4ZRS6oGorhv' | |
9 | 9 | ||
10 | - | let d = | |
10 | + | let d = 4 | |
11 | 11 | ||
12 | - | let e = | |
12 | + | let e = 2 | |
13 | 13 | ||
14 | - | let f = | |
14 | + | let f = 100000000 | |
15 | 15 | ||
16 | - | let g = | |
16 | + | let g = "SUBMITTED" | |
17 | 17 | ||
18 | - | let h = " | |
18 | + | let h = "ACCEPTED" | |
19 | 19 | ||
20 | - | let i = " | |
20 | + | let i = "FINISHED" | |
21 | 21 | ||
22 | - | let j = " | |
22 | + | let j = "CANCELED" | |
23 | 23 | ||
24 | - | let k = " | |
24 | + | let k = "RED" | |
25 | 25 | ||
26 | - | let l = " | |
26 | + | let l = "BLUE" | |
27 | 27 | ||
28 | - | let m = ( | |
28 | + | let m = ((1 * f) / 2) | |
29 | 29 | ||
30 | - | let n = ( | |
30 | + | let n = (100 * f) | |
31 | 31 | ||
32 | - | let o = | |
32 | + | let o = 0 | |
33 | 33 | ||
34 | - | let p = | |
34 | + | let p = 1 | |
35 | 35 | ||
36 | - | let q = | |
36 | + | let q = 2 | |
37 | 37 | ||
38 | - | let r = | |
38 | + | let r = 3 | |
39 | 39 | ||
40 | - | let s = | |
40 | + | let s = 4 | |
41 | 41 | ||
42 | - | let t = | |
42 | + | let t = 5 | |
43 | 43 | ||
44 | - | let u = | |
44 | + | let u = 6 | |
45 | 45 | ||
46 | - | let v = | |
46 | + | let v = 7 | |
47 | 47 | ||
48 | 48 | func w () = { | |
49 | 49 | let x = { | |
59 | 59 | } | |
60 | 60 | ||
61 | 61 | ||
62 | - | func A () = { | |
63 | - | let y = getInteger(this, c) | |
64 | - | if ($isInstanceOf(y, "Int")) | |
65 | - | then { | |
66 | - | let B = y | |
67 | - | B | |
68 | - | } | |
69 | - | else 0 | |
62 | + | func A (B,C,D) = { | |
63 | + | let E = { | |
64 | + | let y = getBinary(this, "lastPlay") | |
65 | + | if ($isInstanceOf(y, "ByteVector")) | |
66 | + | then { | |
67 | + | let F = y | |
68 | + | F | |
69 | + | } | |
70 | + | else if ($isInstanceOf(y, "Unit")) | |
71 | + | then { | |
72 | + | let G = y | |
73 | + | base58'2ee4oFDYriWJ9EMeR' | |
74 | + | } | |
75 | + | else throw() | |
76 | + | } | |
77 | + | let H = (((((E + B.transactionId) + B.callerPublicKey) + lastBlock.generationSignature) + toBytes(lastBlock.timestamp)) + toBytes(lastBlock.height)) | |
78 | + | (((toInt(sha256(H)) % 1000) % ((C - D) + 1)) + 1) | |
70 | 79 | } | |
71 | 80 | ||
72 | 81 | ||
73 | - | func C (D) = { | |
74 | - | let E = (A() + D) | |
75 | - | let F = assetBalance(this, d) | |
76 | - | if ((E > F)) | |
77 | - | then throw("Insufficient funds on Wavesbet Dice account. Transaction was rejected for your safety.") | |
78 | - | else E | |
82 | + | func I (J) = if ((J.assetId == c)) | |
83 | + | then "WBET" | |
84 | + | else "WAVES" | |
85 | + | ||
86 | + | ||
87 | + | func K (L) = if ((L == "WBET")) | |
88 | + | then c | |
89 | + | else unit | |
90 | + | ||
91 | + | ||
92 | + | func M (N) = { | |
93 | + | let F = size(N) | |
94 | + | if ((F == 0)) | |
95 | + | then throw("Parameter size must be greater then 0") | |
96 | + | else if ((F > 99)) | |
97 | + | then throw("Parameter size must be less then 100") | |
98 | + | else if ((10 > F)) | |
99 | + | then (("0" + toString(F)) + N) | |
100 | + | else (toString(F) + N) | |
79 | 101 | } | |
80 | 102 | ||
81 | 103 | ||
82 | - | func G (H) = { | |
83 | - | let I = size(H) | |
84 | - | if ((I == 0)) | |
85 | - | then throw("Parameter size must be greater then 0") | |
86 | - | else if ((I > 99)) | |
87 | - | then throw("Parameter size must be less then 100") | |
88 | - | else if ((10 > I)) | |
89 | - | then (("0" + toString(I)) + H) | |
90 | - | else (toString(I) + H) | |
104 | + | func O (P,Q,R,S,T,U,V,W) = { | |
105 | + | let X = ((((((((((M(P) + "_") + M(Q)) + "_") + M(R)) + "_") + M(S)) + "_") + M(toString(T))) + "_") + M(toString(U))) | |
106 | + | if (if ((V == "")) | |
107 | + | then (W == "") | |
108 | + | else false) | |
109 | + | then X | |
110 | + | else ((((X + "_") + M(V)) + "_") + M(W)) | |
91 | 111 | } | |
92 | 112 | ||
93 | 113 | ||
94 | - | func J (K,L,M,N,D,O) = { | |
95 | - | let P = ((((((((G(K) + "_") + G(toString(L))) + "_") + G(M)) + "_") + G(N)) + "_") + G(toString(D))) | |
96 | - | if ((O == "")) | |
97 | - | then P | |
98 | - | else ((P + "_") + G(O)) | |
114 | + | func Y (Z,aa,I) = if (if ((aa != k)) | |
115 | + | then (aa != l) | |
116 | + | else false) | |
117 | + | then throw("Invalid play, change your bet to RED or BLUE coin. Game aborted.") | |
118 | + | else if (if ((I == "WBET")) | |
119 | + | then (n > Z) | |
120 | + | else false) | |
121 | + | then throw(("The minimum bet on Wbet is " + toString((n / f)))) | |
122 | + | else if (if ((I == "WAVES")) | |
123 | + | then (m > Z) | |
124 | + | else false) | |
125 | + | then throw(("The minimum bet on Waves is " + toString((m / f)))) | |
126 | + | else (((Z * 2) * f) * ((100 - (d + e)) / 100)) | |
127 | + | ||
128 | + | ||
129 | + | @Callable(ab) | |
130 | + | func playCoin (ac) = { | |
131 | + | let ad = toBase58String(ab.transactionId) | |
132 | + | let ae = isDefined(getString(this, ad)) | |
133 | + | let J = extract(ab.payment) | |
134 | + | let af = isDefined(ab.feeAssetId) | |
135 | + | if (if ((J.assetId != assetInfo(base58'WAVES'))) | |
136 | + | then (J.assetId != c) | |
137 | + | else false) | |
138 | + | then throw("Payment should be in Wbet or Waves. Game aborted.") | |
139 | + | else if (af) | |
140 | + | then throw("Transaction's fee must be in Waves. Game aborted.") | |
141 | + | else if (ae) | |
142 | + | then throw("Passed gameId had been used before. Game aborted.") | |
143 | + | else { | |
144 | + | let ag = w() | |
145 | + | let R = toBase58String(ab.callerPublicKey) | |
146 | + | let S = I(J) | |
147 | + | let U = Y(J.amount, ac, S) | |
148 | + | let ah = O(g, ac, R, S, J.amount, U, "", "") | |
149 | + | ScriptResult(WriteSet([DataEntry(b, ag), DataEntry(ad, ah)]), TransferSet(nil)) | |
150 | + | } | |
99 | 151 | } | |
100 | 152 | ||
101 | - | ||
102 | - | func Q (R) = if ((size(R) > 0)) | |
103 | - | then drop(R, 1) | |
104 | - | else R | |
105 | - | ||
106 | - | ||
107 | - | func S (R) = { | |
108 | - | let I = size(R) | |
109 | - | if ((I > 0)) | |
110 | - | then { | |
111 | - | let T = parseIntValue(take(R, 2)) | |
112 | - | let U = take(drop(R, 2), T) | |
113 | - | let V = drop(R, (T + 2)) | |
114 | - | let W = Q(V) | |
115 | - | [U, W] | |
116 | - | } | |
117 | - | else throw("Empty string was passed into parseNextAttribute func") | |
118 | - | } | |
119 | - | ||
120 | - | ||
121 | - | func X (Y) = { | |
122 | - | let K = S(Y) | |
123 | - | let L = S(K[1]) | |
124 | - | let Z = S(L[1]) | |
125 | - | let N = S(Z[1]) | |
126 | - | let D = S(N[1]) | |
127 | - | [K[0], L[0], Z[0], N[0], D[0]] | |
128 | - | } | |
129 | - | ||
130 | - | ||
131 | - | func aa (ab) = { | |
132 | - | let ac = { | |
133 | - | let y = getString(this, ab) | |
134 | - | if ($isInstanceOf(y, "String")) | |
135 | - | then { | |
136 | - | let ad = y | |
137 | - | ad | |
138 | - | } | |
139 | - | else throw(("Couldn't find game by " + ab)) | |
140 | - | } | |
141 | - | X(ac) | |
142 | - | } | |
143 | - | ||
144 | - | ||
145 | - | func ae (ab,D) = { | |
146 | - | let E = (A() - D) | |
147 | - | if ((0 > E)) | |
148 | - | then throw("Invalid Dice Roller account state - reserved amount is less than 0") | |
149 | - | else DataEntry(c, E) | |
150 | - | } | |
151 | - | ||
152 | - | ||
153 | - | func af (ab,ag) = { | |
154 | - | let ah = rsaVerify(SHA256, toBytes(ab), ag, a) | |
155 | - | if (ah) | |
156 | - | then { | |
157 | - | let ai = (toInt(sha256(ag)) % 100) | |
158 | - | if ((0 > ai)) | |
159 | - | then ((-1 * ai) + 1) | |
160 | - | else (ai + 1) | |
161 | - | } | |
162 | - | else throw("Invalid RSA signature") | |
163 | - | } | |
164 | - | ||
165 | - | ||
166 | - | func aj (ak) = if (if ((ak >= 1)) | |
167 | - | then (100 >= ak) | |
168 | - | else false) | |
169 | - | then toString(ak) | |
170 | - | else throw(("Unsupported r parameter passed: expected=[1,...,100] actual=" + toString(ak))) | |
171 | - | ||
172 | - | ||
173 | - | func al (ab,am,D,an,ao) = { | |
174 | - | let ap = [ao] | |
175 | - | let aq = [ScriptTransfer(am, D, d)] | |
176 | - | let ar = DataEntry(ab, an) | |
177 | - | ScriptResult(WriteSet(ar :: ap), TransferSet(aq)) | |
178 | - | } | |
179 | - | ||
180 | - | ||
181 | - | func as (L,Z) = if ((Z == k)) | |
182 | - | then if ((L == 1)) | |
183 | - | then 9850000 | |
184 | - | else if ((L == 2)) | |
185 | - | then 4925000 | |
186 | - | else if ((L == 3)) | |
187 | - | then 3283330 | |
188 | - | else if ((L == 4)) | |
189 | - | then 2462500 | |
190 | - | else if ((L == 5)) | |
191 | - | then 1970000 | |
192 | - | else if ((L == 6)) | |
193 | - | then 1641660 | |
194 | - | else if ((L == 7)) | |
195 | - | then 1407140 | |
196 | - | else if ((L == 8)) | |
197 | - | then 1231250 | |
198 | - | else if ((L == 9)) | |
199 | - | then 1094440 | |
200 | - | else if ((L == 10)) | |
201 | - | then 985000 | |
202 | - | else if ((L == 11)) | |
203 | - | then 895450 | |
204 | - | else if ((L == 12)) | |
205 | - | then 820830 | |
206 | - | else if ((L == 13)) | |
207 | - | then 757690 | |
208 | - | else if ((L == 14)) | |
209 | - | then 703570 | |
210 | - | else if ((L == 15)) | |
211 | - | then 656660 | |
212 | - | else if ((L == 16)) | |
213 | - | then 615620 | |
214 | - | else if ((L == 17)) | |
215 | - | then 579410 | |
216 | - | else if ((L == 18)) | |
217 | - | then 547220 | |
218 | - | else if ((L == 19)) | |
219 | - | then 518420 | |
220 | - | else if ((L == 20)) | |
221 | - | then 492500 | |
222 | - | else if ((L == 21)) | |
223 | - | then 469040 | |
224 | - | else if ((L == 22)) | |
225 | - | then 447720 | |
226 | - | else if ((L == 23)) | |
227 | - | then 428260 | |
228 | - | else if ((L == 24)) | |
229 | - | then 410410 | |
230 | - | else if ((L == 25)) | |
231 | - | then 394000 | |
232 | - | else if ((L == 26)) | |
233 | - | then 378840 | |
234 | - | else if ((L == 27)) | |
235 | - | then 364810 | |
236 | - | else if ((L == 28)) | |
237 | - | then 351780 | |
238 | - | else if ((L == 29)) | |
239 | - | then 339650 | |
240 | - | else if ((L == 30)) | |
241 | - | then 328330 | |
242 | - | else if ((L == 31)) | |
243 | - | then 317740 | |
244 | - | else if ((L == 32)) | |
245 | - | then 307810 | |
246 | - | else if ((L == 33)) | |
247 | - | then 298480 | |
248 | - | else if ((L == 34)) | |
249 | - | then 289700 | |
250 | - | else if ((L == 35)) | |
251 | - | then 281420 | |
252 | - | else if ((L == 36)) | |
253 | - | then 273610 | |
254 | - | else if ((L == 37)) | |
255 | - | then 259210 | |
256 | - | else if ((L == 38)) | |
257 | - | then 259210 | |
258 | - | else if ((L == 39)) | |
259 | - | then 252560 | |
260 | - | else if ((L == 40)) | |
261 | - | then 246250 | |
262 | - | else if ((L == 41)) | |
263 | - | then 240240 | |
264 | - | else if ((L == 42)) | |
265 | - | then 234520 | |
266 | - | else if ((L == 43)) | |
267 | - | then 229060 | |
268 | - | else if ((L == 44)) | |
269 | - | then 223860 | |
270 | - | else if ((L == 45)) | |
271 | - | then 218880 | |
272 | - | else if ((L == 46)) | |
273 | - | then 214130 | |
274 | - | else if ((L == 47)) | |
275 | - | then 209570 | |
276 | - | else if ((L == 48)) | |
277 | - | then 205200 | |
278 | - | else if ((L == 49)) | |
279 | - | then 201020 | |
280 | - | else if ((L == 50)) | |
281 | - | then 197000 | |
282 | - | else if ((L == 51)) | |
283 | - | then 193130 | |
284 | - | else if ((L == 52)) | |
285 | - | then 189420 | |
286 | - | else if ((L == 53)) | |
287 | - | then 185840 | |
288 | - | else if ((L == 54)) | |
289 | - | then 182400 | |
290 | - | else if ((L == 55)) | |
291 | - | then 179090 | |
292 | - | else if ((L == 56)) | |
293 | - | then 175890 | |
294 | - | else if ((L == 57)) | |
295 | - | then 172800 | |
296 | - | else if ((L == 58)) | |
297 | - | then 169820 | |
298 | - | else if ((L == 59)) | |
299 | - | then 166940 | |
300 | - | else if ((L == 60)) | |
301 | - | then 164160 | |
302 | - | else if ((L == 61)) | |
303 | - | then 161470 | |
304 | - | else if ((L == 62)) | |
305 | - | then 158870 | |
306 | - | else if ((L == 63)) | |
307 | - | then 156340 | |
308 | - | else if ((L == 64)) | |
309 | - | then 153900 | |
310 | - | else if ((L == 65)) | |
311 | - | then 151530 | |
312 | - | else if ((L == 66)) | |
313 | - | then 149240 | |
314 | - | else if ((L == 67)) | |
315 | - | then 147010 | |
316 | - | else if ((L == 68)) | |
317 | - | then 144850 | |
318 | - | else if ((L == 69)) | |
319 | - | then 142750 | |
320 | - | else if ((L == 70)) | |
321 | - | then 140710 | |
322 | - | else if ((L == 71)) | |
323 | - | then 138730 | |
324 | - | else if ((L == 72)) | |
325 | - | then 136800 | |
326 | - | else if ((L == 73)) | |
327 | - | then 134930 | |
328 | - | else if ((L == 74)) | |
329 | - | then 133100 | |
330 | - | else if ((L == 75)) | |
331 | - | then 131330 | |
332 | - | else if ((L == 76)) | |
333 | - | then 129600 | |
334 | - | else if ((L == 77)) | |
335 | - | then 127920 | |
336 | - | else if ((L == 78)) | |
337 | - | then 126280 | |
338 | - | else if ((L == 79)) | |
339 | - | then 124680 | |
340 | - | else if ((L == 80)) | |
341 | - | then 123120 | |
342 | - | else if ((L == 81)) | |
343 | - | then 121600 | |
344 | - | else if ((L == 82)) | |
345 | - | then 120120 | |
346 | - | else if ((L == 83)) | |
347 | - | then 118670 | |
348 | - | else if ((L == 84)) | |
349 | - | then 117260 | |
350 | - | else if ((L == 85)) | |
351 | - | then 115880 | |
352 | - | else if ((L == 86)) | |
353 | - | then 114530 | |
354 | - | else if ((L == 87)) | |
355 | - | then 113210 | |
356 | - | else if ((L == 88)) | |
357 | - | then 111930 | |
358 | - | else if ((L == 89)) | |
359 | - | then 110670 | |
360 | - | else if ((L == 90)) | |
361 | - | then 109440 | |
362 | - | else if ((L == 91)) | |
363 | - | then 108240 | |
364 | - | else if ((L == 92)) | |
365 | - | then 107060 | |
366 | - | else if ((L == 93)) | |
367 | - | then 105910 | |
368 | - | else if ((L == 94)) | |
369 | - | then 104780 | |
370 | - | else if ((L == 95)) | |
371 | - | then 103680 | |
372 | - | else if ((L == 96)) | |
373 | - | then 103680 | |
374 | - | else 100000 | |
375 | - | else if ((Z == l)) | |
376 | - | then if ((L == 4)) | |
377 | - | then 103680 | |
378 | - | else if ((L == 5)) | |
379 | - | then 103680 | |
380 | - | else if ((L == 6)) | |
381 | - | then 104780 | |
382 | - | else if ((L == 7)) | |
383 | - | then 105910 | |
384 | - | else if ((L == 8)) | |
385 | - | then 107060 | |
386 | - | else if ((L == 9)) | |
387 | - | then 108240 | |
388 | - | else if ((L == 10)) | |
389 | - | then 109440 | |
390 | - | else if ((L == 11)) | |
391 | - | then 110670 | |
392 | - | else if ((L == 12)) | |
393 | - | then 111930 | |
394 | - | else if ((L == 13)) | |
395 | - | then 113210 | |
396 | - | else if ((L == 14)) | |
397 | - | then 114530 | |
398 | - | else if ((L == 15)) | |
399 | - | then 115880 | |
400 | - | else if ((L == 16)) | |
401 | - | then 117260 | |
402 | - | else if ((L == 17)) | |
403 | - | then 118670 | |
404 | - | else if ((L == 18)) | |
405 | - | then 120120 | |
406 | - | else if ((L == 19)) | |
407 | - | then 121600 | |
408 | - | else if ((L == 20)) | |
409 | - | then 123120 | |
410 | - | else if ((L == 21)) | |
411 | - | then 124680 | |
412 | - | else if ((L == 22)) | |
413 | - | then 126280 | |
414 | - | else if ((L == 23)) | |
415 | - | then 127920 | |
416 | - | else if ((L == 24)) | |
417 | - | then 129600 | |
418 | - | else if ((L == 25)) | |
419 | - | then 131330 | |
420 | - | else if ((L == 26)) | |
421 | - | then 133100 | |
422 | - | else if ((L == 27)) | |
423 | - | then 134930 | |
424 | - | else if ((L == 28)) | |
425 | - | then 136800 | |
426 | - | else if ((L == 29)) | |
427 | - | then 138730 | |
428 | - | else if ((L == 30)) | |
429 | - | then 140710 | |
430 | - | else if ((L == 31)) | |
431 | - | then 142750 | |
432 | - | else if ((L == 32)) | |
433 | - | then 144850 | |
434 | - | else if ((L == 33)) | |
435 | - | then 147010 | |
436 | - | else if ((L == 34)) | |
437 | - | then 149240 | |
438 | - | else if ((L == 35)) | |
439 | - | then 151530 | |
440 | - | else if ((L == 36)) | |
441 | - | then 153900 | |
442 | - | else if ((L == 37)) | |
443 | - | then 156340 | |
444 | - | else if ((L == 38)) | |
445 | - | then 158870 | |
446 | - | else if ((L == 39)) | |
447 | - | then 161470 | |
448 | - | else if ((L == 40)) | |
449 | - | then 164160 | |
450 | - | else if ((L == 41)) | |
451 | - | then 166940 | |
452 | - | else if ((L == 42)) | |
453 | - | then 169820 | |
454 | - | else if ((L == 43)) | |
455 | - | then 172800 | |
456 | - | else if ((L == 44)) | |
457 | - | then 175890 | |
458 | - | else if ((L == 45)) | |
459 | - | then 179090 | |
460 | - | else if ((L == 46)) | |
461 | - | then 185840 | |
462 | - | else if ((L == 47)) | |
463 | - | then 185840 | |
464 | - | else if ((L == 48)) | |
465 | - | then 189420 | |
466 | - | else if ((L == 49)) | |
467 | - | then 193130 | |
468 | - | else if ((L == 50)) | |
469 | - | then 197000 | |
470 | - | else if ((L == 51)) | |
471 | - | then 201020 | |
472 | - | else if ((L == 52)) | |
473 | - | then 205200 | |
474 | - | else if ((L == 53)) | |
475 | - | then 209570 | |
476 | - | else if ((L == 54)) | |
477 | - | then 214130 | |
478 | - | else if ((L == 55)) | |
479 | - | then 218880 | |
480 | - | else if ((L == 56)) | |
481 | - | then 223860 | |
482 | - | else if ((L == 57)) | |
483 | - | then 229060 | |
484 | - | else if ((L == 58)) | |
485 | - | then 234520 | |
486 | - | else if ((L == 59)) | |
487 | - | then 240240 | |
488 | - | else if ((L == 60)) | |
489 | - | then 246250 | |
490 | - | else if ((L == 61)) | |
491 | - | then 252560 | |
492 | - | else if ((L == 62)) | |
493 | - | then 259210 | |
494 | - | else if ((L == 63)) | |
495 | - | then 259210 | |
496 | - | else if ((L == 64)) | |
497 | - | then 273610 | |
498 | - | else if ((L == 65)) | |
499 | - | then 281420 | |
500 | - | else if ((L == 66)) | |
501 | - | then 289700 | |
502 | - | else if ((L == 67)) | |
503 | - | then 298480 | |
504 | - | else if ((L == 68)) | |
505 | - | then 307810 | |
506 | - | else if ((L == 69)) | |
507 | - | then 317740 | |
508 | - | else if ((L == 70)) | |
509 | - | then 328330 | |
510 | - | else if ((L == 71)) | |
511 | - | then 339650 | |
512 | - | else if ((L == 72)) | |
513 | - | then 351780 | |
514 | - | else if ((L == 73)) | |
515 | - | then 364810 | |
516 | - | else if ((L == 74)) | |
517 | - | then 378840 | |
518 | - | else if ((L == 75)) | |
519 | - | then 394000 | |
520 | - | else if ((L == 76)) | |
521 | - | then 410410 | |
522 | - | else if ((L == 77)) | |
523 | - | then 428260 | |
524 | - | else if ((L == 78)) | |
525 | - | then 447720 | |
526 | - | else if ((L == 79)) | |
527 | - | then 469040 | |
528 | - | else if ((L == 80)) | |
529 | - | then 492500 | |
530 | - | else if ((L == 81)) | |
531 | - | then 518420 | |
532 | - | else if ((L == 82)) | |
533 | - | then 547220 | |
534 | - | else if ((L == 83)) | |
535 | - | then 579410 | |
536 | - | else if ((L == 84)) | |
537 | - | then 615620 | |
538 | - | else if ((L == 85)) | |
539 | - | then 656660 | |
540 | - | else if ((L == 86)) | |
541 | - | then 703570 | |
542 | - | else if ((L == 87)) | |
543 | - | then 757690 | |
544 | - | else if ((L == 88)) | |
545 | - | then 820830 | |
546 | - | else if ((L == 89)) | |
547 | - | then 895450 | |
548 | - | else if ((L == 90)) | |
549 | - | then 985000 | |
550 | - | else if ((L == 91)) | |
551 | - | then 1094440 | |
552 | - | else if ((L == 92)) | |
553 | - | then 1231250 | |
554 | - | else if ((L == 93)) | |
555 | - | then 1407140 | |
556 | - | else if ((L == 94)) | |
557 | - | then 1641660 | |
558 | - | else if ((L == 95)) | |
559 | - | then 1970000 | |
560 | - | else if ((L == 96)) | |
561 | - | then 2462500 | |
562 | - | else if ((L == 97)) | |
563 | - | then 3283330 | |
564 | - | else if ((L == 98)) | |
565 | - | then 4925000 | |
566 | - | else if ((L == 99)) | |
567 | - | then 9850000 | |
568 | - | else 100000 | |
569 | - | else 100000 | |
570 | - | ||
571 | - | ||
572 | - | func at (au,L,av) = if ((au == k)) | |
573 | - | then if ((L >= av)) | |
574 | - | then true | |
575 | - | else false | |
576 | - | else if ((au == l)) | |
577 | - | then if ((av >= L)) | |
578 | - | then true | |
579 | - | else false | |
580 | - | else false | |
581 | - | ||
582 | - | ||
583 | - | func aw (ax,L,Z) = if (if ((m > ax)) | |
584 | - | then true | |
585 | - | else (ax > n)) | |
586 | - | then throw(((("Bet amount is not in range: minBet=" + toString((m / e))) + " maxBet=") + toString((n / e)))) | |
587 | - | else if (if ((Z != k)) | |
588 | - | then (Z != l) | |
589 | - | else false) | |
590 | - | then throw("Invalid Roll type, try with OVER or UNDER") | |
591 | - | else if (if ((o > L)) | |
592 | - | then true | |
593 | - | else (L > p)) | |
594 | - | then throw(((("Prediction is out of the range: " + toString(o)) + " <= prediction <= ") + toString(p))) | |
595 | - | else { | |
596 | - | let ay = as(L, Z) | |
597 | - | ((((ax * ay) / 100000) * (100 - (f + g))) / 100) | |
598 | - | } | |
599 | - | ||
600 | - | ||
601 | - | @Callable(az) | |
602 | - | func playDice (Z,L) = { | |
603 | - | let ab = toBase58String(az.transactionId) | |
604 | - | let aA = extract(az.payment) | |
605 | - | let aB = isDefined(az.feeAssetId) | |
606 | - | let ay = as(L, Z) | |
607 | - | let D = aw(aA.amount, L, Z) | |
608 | - | let aC = wavesBalance(az.caller) | |
609 | - | let aD = isDefined(getString(this, ab)) | |
610 | - | if ((aA.assetId != d)) | |
611 | - | then throw("Payment should be in Wavesbet") | |
612 | - | else if ((1000000 > aC)) | |
613 | - | then throw("There are not enough waves, it takes 0.01 Waves to bet. Game aborted.") | |
614 | - | else if (aB) | |
615 | - | then throw("Transaction's fee must be in Waves. Game aborted.") | |
616 | - | else if (aD) | |
617 | - | then throw("Passed gameId had been used before. Game aborted.") | |
618 | - | else { | |
619 | - | let aE = w() | |
620 | - | let N = toBase58String(az.callerPublicKey) | |
621 | - | let aF = J(h, L, Z, N, D, "") | |
622 | - | ScriptResult(WriteSet([DataEntry(c, C(D)), DataEntry(b, aE), DataEntry(ab, aF)]), TransferSet(nil)) | |
623 | - | } | |
624 | - | } | |
625 | - | ||
626 | - | ||
627 | - | ||
628 | - | @Callable(az) | |
629 | - | func withdraw (ab,aG) = { | |
630 | - | let aH = aa(ab) | |
631 | - | let K = aH[q] | |
632 | - | let L = parseIntValue(aH[r]) | |
633 | - | let Z = aH[s] | |
634 | - | let D = parseIntValue(aH[u]) | |
635 | - | let N = aH[t] | |
636 | - | let am = addressFromPublicKey(fromBase58String(N)) | |
637 | - | let ao = ae(ab, D) | |
638 | - | if ((K != h)) | |
639 | - | then throw("Invalid game state for passed gameId. Game aborted.") | |
640 | - | else { | |
641 | - | let ai = af(ab, aG) | |
642 | - | let aI = aj(ai) | |
643 | - | if (at(Z, L, ai)) | |
644 | - | then { | |
645 | - | let an = J(i, L, Z, N, D, aI) | |
646 | - | al(ab, am, D, an, ao) | |
647 | - | } | |
648 | - | else { | |
649 | - | let an = J(j, L, Z, N, D, aI) | |
650 | - | WriteSet([DataEntry(ab, an), ao]) | |
651 | - | } | |
652 | - | } | |
653 | - | } | |
654 | - | ||
655 | - | ||
656 | - | @Verifier(aJ) | |
657 | - | func aK () = if (sigVerify(aJ.bodyBytes, aJ.proofs[0], aJ.senderPublicKey)) | |
658 | - | then { | |
659 | - | let y = aJ | |
660 | - | if ($isInstanceOf(y, "TransferTransaction")) | |
661 | - | then { | |
662 | - | let aL = y | |
663 | - | ((assetBalance(this, d) - aL.amount) >= A()) | |
664 | - | } | |
665 | - | else if ($isInstanceOf(y, "SetScriptTransaction")) | |
666 | - | then { | |
667 | - | let aM = y | |
668 | - | true | |
669 | - | } | |
670 | - | else false | |
671 | - | } | |
672 | - | else false | |
673 | 153 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let a = fromBase64String("base64:MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAg4dAR6XbBDAS9hr/Ej3dJv6Ffc466x/mOGMWU3lrABs3qa8BHmuJGnkfbpEf2vAwYTOWPvvzfM10OBbfloSyq3c9MKvyTe1luBLGqW4vZUXIyvSgz1liyUVefIQy3dyF9jbeTZbC0bbcT/7O3DEL+01z6A+rDCacSZ0lGolSQ6AnhLxzIkVpOQJbrBmC+x+ZuZPCMWzJynd5aeOn7jaj/mkRVyxe6g/0OhWz4NiiZXeuMRB+8mKy0fWD/UlIlZWHsAS2ZmrkXKqjLq0/0wr8ILJkznjSqdnI5Ibjg3uQrj/4AN+i9r28aQ73/ZkPtY5Sbw0AOiABBu7gHmq9ayVxZQIDAQAB") | |
5 | 5 | ||
6 | 6 | let b = "$GAME_NUM" | |
7 | 7 | ||
8 | - | let c = | |
8 | + | let c = base58'23vgV9p9pD83A7CFbsDEc4zjanep7UeFo4ZRS6oGorhv' | |
9 | 9 | ||
10 | - | let d = | |
10 | + | let d = 4 | |
11 | 11 | ||
12 | - | let e = | |
12 | + | let e = 2 | |
13 | 13 | ||
14 | - | let f = | |
14 | + | let f = 100000000 | |
15 | 15 | ||
16 | - | let g = | |
16 | + | let g = "SUBMITTED" | |
17 | 17 | ||
18 | - | let h = " | |
18 | + | let h = "ACCEPTED" | |
19 | 19 | ||
20 | - | let i = " | |
20 | + | let i = "FINISHED" | |
21 | 21 | ||
22 | - | let j = " | |
22 | + | let j = "CANCELED" | |
23 | 23 | ||
24 | - | let k = " | |
24 | + | let k = "RED" | |
25 | 25 | ||
26 | - | let l = " | |
26 | + | let l = "BLUE" | |
27 | 27 | ||
28 | - | let m = ( | |
28 | + | let m = ((1 * f) / 2) | |
29 | 29 | ||
30 | - | let n = ( | |
30 | + | let n = (100 * f) | |
31 | 31 | ||
32 | - | let o = | |
32 | + | let o = 0 | |
33 | 33 | ||
34 | - | let p = | |
34 | + | let p = 1 | |
35 | 35 | ||
36 | - | let q = | |
36 | + | let q = 2 | |
37 | 37 | ||
38 | - | let r = | |
38 | + | let r = 3 | |
39 | 39 | ||
40 | - | let s = | |
40 | + | let s = 4 | |
41 | 41 | ||
42 | - | let t = | |
42 | + | let t = 5 | |
43 | 43 | ||
44 | - | let u = | |
44 | + | let u = 6 | |
45 | 45 | ||
46 | - | let v = | |
46 | + | let v = 7 | |
47 | 47 | ||
48 | 48 | func w () = { | |
49 | 49 | let x = { | |
50 | 50 | let y = getInteger(this, b) | |
51 | 51 | if ($isInstanceOf(y, "Int")) | |
52 | 52 | then { | |
53 | 53 | let z = y | |
54 | 54 | z | |
55 | 55 | } | |
56 | 56 | else 0 | |
57 | 57 | } | |
58 | 58 | (x + 1) | |
59 | 59 | } | |
60 | 60 | ||
61 | 61 | ||
62 | - | func A () = { | |
63 | - | let y = getInteger(this, c) | |
64 | - | if ($isInstanceOf(y, "Int")) | |
65 | - | then { | |
66 | - | let B = y | |
67 | - | B | |
68 | - | } | |
69 | - | else 0 | |
62 | + | func A (B,C,D) = { | |
63 | + | let E = { | |
64 | + | let y = getBinary(this, "lastPlay") | |
65 | + | if ($isInstanceOf(y, "ByteVector")) | |
66 | + | then { | |
67 | + | let F = y | |
68 | + | F | |
69 | + | } | |
70 | + | else if ($isInstanceOf(y, "Unit")) | |
71 | + | then { | |
72 | + | let G = y | |
73 | + | base58'2ee4oFDYriWJ9EMeR' | |
74 | + | } | |
75 | + | else throw() | |
76 | + | } | |
77 | + | let H = (((((E + B.transactionId) + B.callerPublicKey) + lastBlock.generationSignature) + toBytes(lastBlock.timestamp)) + toBytes(lastBlock.height)) | |
78 | + | (((toInt(sha256(H)) % 1000) % ((C - D) + 1)) + 1) | |
70 | 79 | } | |
71 | 80 | ||
72 | 81 | ||
73 | - | func C (D) = { | |
74 | - | let E = (A() + D) | |
75 | - | let F = assetBalance(this, d) | |
76 | - | if ((E > F)) | |
77 | - | then throw("Insufficient funds on Wavesbet Dice account. Transaction was rejected for your safety.") | |
78 | - | else E | |
82 | + | func I (J) = if ((J.assetId == c)) | |
83 | + | then "WBET" | |
84 | + | else "WAVES" | |
85 | + | ||
86 | + | ||
87 | + | func K (L) = if ((L == "WBET")) | |
88 | + | then c | |
89 | + | else unit | |
90 | + | ||
91 | + | ||
92 | + | func M (N) = { | |
93 | + | let F = size(N) | |
94 | + | if ((F == 0)) | |
95 | + | then throw("Parameter size must be greater then 0") | |
96 | + | else if ((F > 99)) | |
97 | + | then throw("Parameter size must be less then 100") | |
98 | + | else if ((10 > F)) | |
99 | + | then (("0" + toString(F)) + N) | |
100 | + | else (toString(F) + N) | |
79 | 101 | } | |
80 | 102 | ||
81 | 103 | ||
82 | - | func G (H) = { | |
83 | - | let I = size(H) | |
84 | - | if ((I == 0)) | |
85 | - | then throw("Parameter size must be greater then 0") | |
86 | - | else if ((I > 99)) | |
87 | - | then throw("Parameter size must be less then 100") | |
88 | - | else if ((10 > I)) | |
89 | - | then (("0" + toString(I)) + H) | |
90 | - | else (toString(I) + H) | |
104 | + | func O (P,Q,R,S,T,U,V,W) = { | |
105 | + | let X = ((((((((((M(P) + "_") + M(Q)) + "_") + M(R)) + "_") + M(S)) + "_") + M(toString(T))) + "_") + M(toString(U))) | |
106 | + | if (if ((V == "")) | |
107 | + | then (W == "") | |
108 | + | else false) | |
109 | + | then X | |
110 | + | else ((((X + "_") + M(V)) + "_") + M(W)) | |
91 | 111 | } | |
92 | 112 | ||
93 | 113 | ||
94 | - | func J (K,L,M,N,D,O) = { | |
95 | - | let P = ((((((((G(K) + "_") + G(toString(L))) + "_") + G(M)) + "_") + G(N)) + "_") + G(toString(D))) | |
96 | - | if ((O == "")) | |
97 | - | then P | |
98 | - | else ((P + "_") + G(O)) | |
114 | + | func Y (Z,aa,I) = if (if ((aa != k)) | |
115 | + | then (aa != l) | |
116 | + | else false) | |
117 | + | then throw("Invalid play, change your bet to RED or BLUE coin. Game aborted.") | |
118 | + | else if (if ((I == "WBET")) | |
119 | + | then (n > Z) | |
120 | + | else false) | |
121 | + | then throw(("The minimum bet on Wbet is " + toString((n / f)))) | |
122 | + | else if (if ((I == "WAVES")) | |
123 | + | then (m > Z) | |
124 | + | else false) | |
125 | + | then throw(("The minimum bet on Waves is " + toString((m / f)))) | |
126 | + | else (((Z * 2) * f) * ((100 - (d + e)) / 100)) | |
127 | + | ||
128 | + | ||
129 | + | @Callable(ab) | |
130 | + | func playCoin (ac) = { | |
131 | + | let ad = toBase58String(ab.transactionId) | |
132 | + | let ae = isDefined(getString(this, ad)) | |
133 | + | let J = extract(ab.payment) | |
134 | + | let af = isDefined(ab.feeAssetId) | |
135 | + | if (if ((J.assetId != assetInfo(base58'WAVES'))) | |
136 | + | then (J.assetId != c) | |
137 | + | else false) | |
138 | + | then throw("Payment should be in Wbet or Waves. Game aborted.") | |
139 | + | else if (af) | |
140 | + | then throw("Transaction's fee must be in Waves. Game aborted.") | |
141 | + | else if (ae) | |
142 | + | then throw("Passed gameId had been used before. Game aborted.") | |
143 | + | else { | |
144 | + | let ag = w() | |
145 | + | let R = toBase58String(ab.callerPublicKey) | |
146 | + | let S = I(J) | |
147 | + | let U = Y(J.amount, ac, S) | |
148 | + | let ah = O(g, ac, R, S, J.amount, U, "", "") | |
149 | + | ScriptResult(WriteSet([DataEntry(b, ag), DataEntry(ad, ah)]), TransferSet(nil)) | |
150 | + | } | |
99 | 151 | } | |
100 | 152 | ||
101 | - | ||
102 | - | func Q (R) = if ((size(R) > 0)) | |
103 | - | then drop(R, 1) | |
104 | - | else R | |
105 | - | ||
106 | - | ||
107 | - | func S (R) = { | |
108 | - | let I = size(R) | |
109 | - | if ((I > 0)) | |
110 | - | then { | |
111 | - | let T = parseIntValue(take(R, 2)) | |
112 | - | let U = take(drop(R, 2), T) | |
113 | - | let V = drop(R, (T + 2)) | |
114 | - | let W = Q(V) | |
115 | - | [U, W] | |
116 | - | } | |
117 | - | else throw("Empty string was passed into parseNextAttribute func") | |
118 | - | } | |
119 | - | ||
120 | - | ||
121 | - | func X (Y) = { | |
122 | - | let K = S(Y) | |
123 | - | let L = S(K[1]) | |
124 | - | let Z = S(L[1]) | |
125 | - | let N = S(Z[1]) | |
126 | - | let D = S(N[1]) | |
127 | - | [K[0], L[0], Z[0], N[0], D[0]] | |
128 | - | } | |
129 | - | ||
130 | - | ||
131 | - | func aa (ab) = { | |
132 | - | let ac = { | |
133 | - | let y = getString(this, ab) | |
134 | - | if ($isInstanceOf(y, "String")) | |
135 | - | then { | |
136 | - | let ad = y | |
137 | - | ad | |
138 | - | } | |
139 | - | else throw(("Couldn't find game by " + ab)) | |
140 | - | } | |
141 | - | X(ac) | |
142 | - | } | |
143 | - | ||
144 | - | ||
145 | - | func ae (ab,D) = { | |
146 | - | let E = (A() - D) | |
147 | - | if ((0 > E)) | |
148 | - | then throw("Invalid Dice Roller account state - reserved amount is less than 0") | |
149 | - | else DataEntry(c, E) | |
150 | - | } | |
151 | - | ||
152 | - | ||
153 | - | func af (ab,ag) = { | |
154 | - | let ah = rsaVerify(SHA256, toBytes(ab), ag, a) | |
155 | - | if (ah) | |
156 | - | then { | |
157 | - | let ai = (toInt(sha256(ag)) % 100) | |
158 | - | if ((0 > ai)) | |
159 | - | then ((-1 * ai) + 1) | |
160 | - | else (ai + 1) | |
161 | - | } | |
162 | - | else throw("Invalid RSA signature") | |
163 | - | } | |
164 | - | ||
165 | - | ||
166 | - | func aj (ak) = if (if ((ak >= 1)) | |
167 | - | then (100 >= ak) | |
168 | - | else false) | |
169 | - | then toString(ak) | |
170 | - | else throw(("Unsupported r parameter passed: expected=[1,...,100] actual=" + toString(ak))) | |
171 | - | ||
172 | - | ||
173 | - | func al (ab,am,D,an,ao) = { | |
174 | - | let ap = [ao] | |
175 | - | let aq = [ScriptTransfer(am, D, d)] | |
176 | - | let ar = DataEntry(ab, an) | |
177 | - | ScriptResult(WriteSet(ar :: ap), TransferSet(aq)) | |
178 | - | } | |
179 | - | ||
180 | - | ||
181 | - | func as (L,Z) = if ((Z == k)) | |
182 | - | then if ((L == 1)) | |
183 | - | then 9850000 | |
184 | - | else if ((L == 2)) | |
185 | - | then 4925000 | |
186 | - | else if ((L == 3)) | |
187 | - | then 3283330 | |
188 | - | else if ((L == 4)) | |
189 | - | then 2462500 | |
190 | - | else if ((L == 5)) | |
191 | - | then 1970000 | |
192 | - | else if ((L == 6)) | |
193 | - | then 1641660 | |
194 | - | else if ((L == 7)) | |
195 | - | then 1407140 | |
196 | - | else if ((L == 8)) | |
197 | - | then 1231250 | |
198 | - | else if ((L == 9)) | |
199 | - | then 1094440 | |
200 | - | else if ((L == 10)) | |
201 | - | then 985000 | |
202 | - | else if ((L == 11)) | |
203 | - | then 895450 | |
204 | - | else if ((L == 12)) | |
205 | - | then 820830 | |
206 | - | else if ((L == 13)) | |
207 | - | then 757690 | |
208 | - | else if ((L == 14)) | |
209 | - | then 703570 | |
210 | - | else if ((L == 15)) | |
211 | - | then 656660 | |
212 | - | else if ((L == 16)) | |
213 | - | then 615620 | |
214 | - | else if ((L == 17)) | |
215 | - | then 579410 | |
216 | - | else if ((L == 18)) | |
217 | - | then 547220 | |
218 | - | else if ((L == 19)) | |
219 | - | then 518420 | |
220 | - | else if ((L == 20)) | |
221 | - | then 492500 | |
222 | - | else if ((L == 21)) | |
223 | - | then 469040 | |
224 | - | else if ((L == 22)) | |
225 | - | then 447720 | |
226 | - | else if ((L == 23)) | |
227 | - | then 428260 | |
228 | - | else if ((L == 24)) | |
229 | - | then 410410 | |
230 | - | else if ((L == 25)) | |
231 | - | then 394000 | |
232 | - | else if ((L == 26)) | |
233 | - | then 378840 | |
234 | - | else if ((L == 27)) | |
235 | - | then 364810 | |
236 | - | else if ((L == 28)) | |
237 | - | then 351780 | |
238 | - | else if ((L == 29)) | |
239 | - | then 339650 | |
240 | - | else if ((L == 30)) | |
241 | - | then 328330 | |
242 | - | else if ((L == 31)) | |
243 | - | then 317740 | |
244 | - | else if ((L == 32)) | |
245 | - | then 307810 | |
246 | - | else if ((L == 33)) | |
247 | - | then 298480 | |
248 | - | else if ((L == 34)) | |
249 | - | then 289700 | |
250 | - | else if ((L == 35)) | |
251 | - | then 281420 | |
252 | - | else if ((L == 36)) | |
253 | - | then 273610 | |
254 | - | else if ((L == 37)) | |
255 | - | then 259210 | |
256 | - | else if ((L == 38)) | |
257 | - | then 259210 | |
258 | - | else if ((L == 39)) | |
259 | - | then 252560 | |
260 | - | else if ((L == 40)) | |
261 | - | then 246250 | |
262 | - | else if ((L == 41)) | |
263 | - | then 240240 | |
264 | - | else if ((L == 42)) | |
265 | - | then 234520 | |
266 | - | else if ((L == 43)) | |
267 | - | then 229060 | |
268 | - | else if ((L == 44)) | |
269 | - | then 223860 | |
270 | - | else if ((L == 45)) | |
271 | - | then 218880 | |
272 | - | else if ((L == 46)) | |
273 | - | then 214130 | |
274 | - | else if ((L == 47)) | |
275 | - | then 209570 | |
276 | - | else if ((L == 48)) | |
277 | - | then 205200 | |
278 | - | else if ((L == 49)) | |
279 | - | then 201020 | |
280 | - | else if ((L == 50)) | |
281 | - | then 197000 | |
282 | - | else if ((L == 51)) | |
283 | - | then 193130 | |
284 | - | else if ((L == 52)) | |
285 | - | then 189420 | |
286 | - | else if ((L == 53)) | |
287 | - | then 185840 | |
288 | - | else if ((L == 54)) | |
289 | - | then 182400 | |
290 | - | else if ((L == 55)) | |
291 | - | then 179090 | |
292 | - | else if ((L == 56)) | |
293 | - | then 175890 | |
294 | - | else if ((L == 57)) | |
295 | - | then 172800 | |
296 | - | else if ((L == 58)) | |
297 | - | then 169820 | |
298 | - | else if ((L == 59)) | |
299 | - | then 166940 | |
300 | - | else if ((L == 60)) | |
301 | - | then 164160 | |
302 | - | else if ((L == 61)) | |
303 | - | then 161470 | |
304 | - | else if ((L == 62)) | |
305 | - | then 158870 | |
306 | - | else if ((L == 63)) | |
307 | - | then 156340 | |
308 | - | else if ((L == 64)) | |
309 | - | then 153900 | |
310 | - | else if ((L == 65)) | |
311 | - | then 151530 | |
312 | - | else if ((L == 66)) | |
313 | - | then 149240 | |
314 | - | else if ((L == 67)) | |
315 | - | then 147010 | |
316 | - | else if ((L == 68)) | |
317 | - | then 144850 | |
318 | - | else if ((L == 69)) | |
319 | - | then 142750 | |
320 | - | else if ((L == 70)) | |
321 | - | then 140710 | |
322 | - | else if ((L == 71)) | |
323 | - | then 138730 | |
324 | - | else if ((L == 72)) | |
325 | - | then 136800 | |
326 | - | else if ((L == 73)) | |
327 | - | then 134930 | |
328 | - | else if ((L == 74)) | |
329 | - | then 133100 | |
330 | - | else if ((L == 75)) | |
331 | - | then 131330 | |
332 | - | else if ((L == 76)) | |
333 | - | then 129600 | |
334 | - | else if ((L == 77)) | |
335 | - | then 127920 | |
336 | - | else if ((L == 78)) | |
337 | - | then 126280 | |
338 | - | else if ((L == 79)) | |
339 | - | then 124680 | |
340 | - | else if ((L == 80)) | |
341 | - | then 123120 | |
342 | - | else if ((L == 81)) | |
343 | - | then 121600 | |
344 | - | else if ((L == 82)) | |
345 | - | then 120120 | |
346 | - | else if ((L == 83)) | |
347 | - | then 118670 | |
348 | - | else if ((L == 84)) | |
349 | - | then 117260 | |
350 | - | else if ((L == 85)) | |
351 | - | then 115880 | |
352 | - | else if ((L == 86)) | |
353 | - | then 114530 | |
354 | - | else if ((L == 87)) | |
355 | - | then 113210 | |
356 | - | else if ((L == 88)) | |
357 | - | then 111930 | |
358 | - | else if ((L == 89)) | |
359 | - | then 110670 | |
360 | - | else if ((L == 90)) | |
361 | - | then 109440 | |
362 | - | else if ((L == 91)) | |
363 | - | then 108240 | |
364 | - | else if ((L == 92)) | |
365 | - | then 107060 | |
366 | - | else if ((L == 93)) | |
367 | - | then 105910 | |
368 | - | else if ((L == 94)) | |
369 | - | then 104780 | |
370 | - | else if ((L == 95)) | |
371 | - | then 103680 | |
372 | - | else if ((L == 96)) | |
373 | - | then 103680 | |
374 | - | else 100000 | |
375 | - | else if ((Z == l)) | |
376 | - | then if ((L == 4)) | |
377 | - | then 103680 | |
378 | - | else if ((L == 5)) | |
379 | - | then 103680 | |
380 | - | else if ((L == 6)) | |
381 | - | then 104780 | |
382 | - | else if ((L == 7)) | |
383 | - | then 105910 | |
384 | - | else if ((L == 8)) | |
385 | - | then 107060 | |
386 | - | else if ((L == 9)) | |
387 | - | then 108240 | |
388 | - | else if ((L == 10)) | |
389 | - | then 109440 | |
390 | - | else if ((L == 11)) | |
391 | - | then 110670 | |
392 | - | else if ((L == 12)) | |
393 | - | then 111930 | |
394 | - | else if ((L == 13)) | |
395 | - | then 113210 | |
396 | - | else if ((L == 14)) | |
397 | - | then 114530 | |
398 | - | else if ((L == 15)) | |
399 | - | then 115880 | |
400 | - | else if ((L == 16)) | |
401 | - | then 117260 | |
402 | - | else if ((L == 17)) | |
403 | - | then 118670 | |
404 | - | else if ((L == 18)) | |
405 | - | then 120120 | |
406 | - | else if ((L == 19)) | |
407 | - | then 121600 | |
408 | - | else if ((L == 20)) | |
409 | - | then 123120 | |
410 | - | else if ((L == 21)) | |
411 | - | then 124680 | |
412 | - | else if ((L == 22)) | |
413 | - | then 126280 | |
414 | - | else if ((L == 23)) | |
415 | - | then 127920 | |
416 | - | else if ((L == 24)) | |
417 | - | then 129600 | |
418 | - | else if ((L == 25)) | |
419 | - | then 131330 | |
420 | - | else if ((L == 26)) | |
421 | - | then 133100 | |
422 | - | else if ((L == 27)) | |
423 | - | then 134930 | |
424 | - | else if ((L == 28)) | |
425 | - | then 136800 | |
426 | - | else if ((L == 29)) | |
427 | - | then 138730 | |
428 | - | else if ((L == 30)) | |
429 | - | then 140710 | |
430 | - | else if ((L == 31)) | |
431 | - | then 142750 | |
432 | - | else if ((L == 32)) | |
433 | - | then 144850 | |
434 | - | else if ((L == 33)) | |
435 | - | then 147010 | |
436 | - | else if ((L == 34)) | |
437 | - | then 149240 | |
438 | - | else if ((L == 35)) | |
439 | - | then 151530 | |
440 | - | else if ((L == 36)) | |
441 | - | then 153900 | |
442 | - | else if ((L == 37)) | |
443 | - | then 156340 | |
444 | - | else if ((L == 38)) | |
445 | - | then 158870 | |
446 | - | else if ((L == 39)) | |
447 | - | then 161470 | |
448 | - | else if ((L == 40)) | |
449 | - | then 164160 | |
450 | - | else if ((L == 41)) | |
451 | - | then 166940 | |
452 | - | else if ((L == 42)) | |
453 | - | then 169820 | |
454 | - | else if ((L == 43)) | |
455 | - | then 172800 | |
456 | - | else if ((L == 44)) | |
457 | - | then 175890 | |
458 | - | else if ((L == 45)) | |
459 | - | then 179090 | |
460 | - | else if ((L == 46)) | |
461 | - | then 185840 | |
462 | - | else if ((L == 47)) | |
463 | - | then 185840 | |
464 | - | else if ((L == 48)) | |
465 | - | then 189420 | |
466 | - | else if ((L == 49)) | |
467 | - | then 193130 | |
468 | - | else if ((L == 50)) | |
469 | - | then 197000 | |
470 | - | else if ((L == 51)) | |
471 | - | then 201020 | |
472 | - | else if ((L == 52)) | |
473 | - | then 205200 | |
474 | - | else if ((L == 53)) | |
475 | - | then 209570 | |
476 | - | else if ((L == 54)) | |
477 | - | then 214130 | |
478 | - | else if ((L == 55)) | |
479 | - | then 218880 | |
480 | - | else if ((L == 56)) | |
481 | - | then 223860 | |
482 | - | else if ((L == 57)) | |
483 | - | then 229060 | |
484 | - | else if ((L == 58)) | |
485 | - | then 234520 | |
486 | - | else if ((L == 59)) | |
487 | - | then 240240 | |
488 | - | else if ((L == 60)) | |
489 | - | then 246250 | |
490 | - | else if ((L == 61)) | |
491 | - | then 252560 | |
492 | - | else if ((L == 62)) | |
493 | - | then 259210 | |
494 | - | else if ((L == 63)) | |
495 | - | then 259210 | |
496 | - | else if ((L == 64)) | |
497 | - | then 273610 | |
498 | - | else if ((L == 65)) | |
499 | - | then 281420 | |
500 | - | else if ((L == 66)) | |
501 | - | then 289700 | |
502 | - | else if ((L == 67)) | |
503 | - | then 298480 | |
504 | - | else if ((L == 68)) | |
505 | - | then 307810 | |
506 | - | else if ((L == 69)) | |
507 | - | then 317740 | |
508 | - | else if ((L == 70)) | |
509 | - | then 328330 | |
510 | - | else if ((L == 71)) | |
511 | - | then 339650 | |
512 | - | else if ((L == 72)) | |
513 | - | then 351780 | |
514 | - | else if ((L == 73)) | |
515 | - | then 364810 | |
516 | - | else if ((L == 74)) | |
517 | - | then 378840 | |
518 | - | else if ((L == 75)) | |
519 | - | then 394000 | |
520 | - | else if ((L == 76)) | |
521 | - | then 410410 | |
522 | - | else if ((L == 77)) | |
523 | - | then 428260 | |
524 | - | else if ((L == 78)) | |
525 | - | then 447720 | |
526 | - | else if ((L == 79)) | |
527 | - | then 469040 | |
528 | - | else if ((L == 80)) | |
529 | - | then 492500 | |
530 | - | else if ((L == 81)) | |
531 | - | then 518420 | |
532 | - | else if ((L == 82)) | |
533 | - | then 547220 | |
534 | - | else if ((L == 83)) | |
535 | - | then 579410 | |
536 | - | else if ((L == 84)) | |
537 | - | then 615620 | |
538 | - | else if ((L == 85)) | |
539 | - | then 656660 | |
540 | - | else if ((L == 86)) | |
541 | - | then 703570 | |
542 | - | else if ((L == 87)) | |
543 | - | then 757690 | |
544 | - | else if ((L == 88)) | |
545 | - | then 820830 | |
546 | - | else if ((L == 89)) | |
547 | - | then 895450 | |
548 | - | else if ((L == 90)) | |
549 | - | then 985000 | |
550 | - | else if ((L == 91)) | |
551 | - | then 1094440 | |
552 | - | else if ((L == 92)) | |
553 | - | then 1231250 | |
554 | - | else if ((L == 93)) | |
555 | - | then 1407140 | |
556 | - | else if ((L == 94)) | |
557 | - | then 1641660 | |
558 | - | else if ((L == 95)) | |
559 | - | then 1970000 | |
560 | - | else if ((L == 96)) | |
561 | - | then 2462500 | |
562 | - | else if ((L == 97)) | |
563 | - | then 3283330 | |
564 | - | else if ((L == 98)) | |
565 | - | then 4925000 | |
566 | - | else if ((L == 99)) | |
567 | - | then 9850000 | |
568 | - | else 100000 | |
569 | - | else 100000 | |
570 | - | ||
571 | - | ||
572 | - | func at (au,L,av) = if ((au == k)) | |
573 | - | then if ((L >= av)) | |
574 | - | then true | |
575 | - | else false | |
576 | - | else if ((au == l)) | |
577 | - | then if ((av >= L)) | |
578 | - | then true | |
579 | - | else false | |
580 | - | else false | |
581 | - | ||
582 | - | ||
583 | - | func aw (ax,L,Z) = if (if ((m > ax)) | |
584 | - | then true | |
585 | - | else (ax > n)) | |
586 | - | then throw(((("Bet amount is not in range: minBet=" + toString((m / e))) + " maxBet=") + toString((n / e)))) | |
587 | - | else if (if ((Z != k)) | |
588 | - | then (Z != l) | |
589 | - | else false) | |
590 | - | then throw("Invalid Roll type, try with OVER or UNDER") | |
591 | - | else if (if ((o > L)) | |
592 | - | then true | |
593 | - | else (L > p)) | |
594 | - | then throw(((("Prediction is out of the range: " + toString(o)) + " <= prediction <= ") + toString(p))) | |
595 | - | else { | |
596 | - | let ay = as(L, Z) | |
597 | - | ((((ax * ay) / 100000) * (100 - (f + g))) / 100) | |
598 | - | } | |
599 | - | ||
600 | - | ||
601 | - | @Callable(az) | |
602 | - | func playDice (Z,L) = { | |
603 | - | let ab = toBase58String(az.transactionId) | |
604 | - | let aA = extract(az.payment) | |
605 | - | let aB = isDefined(az.feeAssetId) | |
606 | - | let ay = as(L, Z) | |
607 | - | let D = aw(aA.amount, L, Z) | |
608 | - | let aC = wavesBalance(az.caller) | |
609 | - | let aD = isDefined(getString(this, ab)) | |
610 | - | if ((aA.assetId != d)) | |
611 | - | then throw("Payment should be in Wavesbet") | |
612 | - | else if ((1000000 > aC)) | |
613 | - | then throw("There are not enough waves, it takes 0.01 Waves to bet. Game aborted.") | |
614 | - | else if (aB) | |
615 | - | then throw("Transaction's fee must be in Waves. Game aborted.") | |
616 | - | else if (aD) | |
617 | - | then throw("Passed gameId had been used before. Game aborted.") | |
618 | - | else { | |
619 | - | let aE = w() | |
620 | - | let N = toBase58String(az.callerPublicKey) | |
621 | - | let aF = J(h, L, Z, N, D, "") | |
622 | - | ScriptResult(WriteSet([DataEntry(c, C(D)), DataEntry(b, aE), DataEntry(ab, aF)]), TransferSet(nil)) | |
623 | - | } | |
624 | - | } | |
625 | - | ||
626 | - | ||
627 | - | ||
628 | - | @Callable(az) | |
629 | - | func withdraw (ab,aG) = { | |
630 | - | let aH = aa(ab) | |
631 | - | let K = aH[q] | |
632 | - | let L = parseIntValue(aH[r]) | |
633 | - | let Z = aH[s] | |
634 | - | let D = parseIntValue(aH[u]) | |
635 | - | let N = aH[t] | |
636 | - | let am = addressFromPublicKey(fromBase58String(N)) | |
637 | - | let ao = ae(ab, D) | |
638 | - | if ((K != h)) | |
639 | - | then throw("Invalid game state for passed gameId. Game aborted.") | |
640 | - | else { | |
641 | - | let ai = af(ab, aG) | |
642 | - | let aI = aj(ai) | |
643 | - | if (at(Z, L, ai)) | |
644 | - | then { | |
645 | - | let an = J(i, L, Z, N, D, aI) | |
646 | - | al(ab, am, D, an, ao) | |
647 | - | } | |
648 | - | else { | |
649 | - | let an = J(j, L, Z, N, D, aI) | |
650 | - | WriteSet([DataEntry(ab, an), ao]) | |
651 | - | } | |
652 | - | } | |
653 | - | } | |
654 | - | ||
655 | - | ||
656 | - | @Verifier(aJ) | |
657 | - | func aK () = if (sigVerify(aJ.bodyBytes, aJ.proofs[0], aJ.senderPublicKey)) | |
658 | - | then { | |
659 | - | let y = aJ | |
660 | - | if ($isInstanceOf(y, "TransferTransaction")) | |
661 | - | then { | |
662 | - | let aL = y | |
663 | - | ((assetBalance(this, d) - aL.amount) >= A()) | |
664 | - | } | |
665 | - | else if ($isInstanceOf(y, "SetScriptTransaction")) | |
666 | - | then { | |
667 | - | let aM = y | |
668 | - | true | |
669 | - | } | |
670 | - | else false | |
671 | - | } | |
672 | - | else false | |
673 | 153 |
github/deemru/w8io/169f3d6 85.15 ms ◑![]()