tx · J6b6hntFFT6GYqdB6mfyLhYmopVcL9sbeSozUvS9YQzf

3MrdV3AP4zfU77ifesNStoDZmL1Cfx13eDc:  -0.05000000 Waves

2020.01.01 19:38 [834986] smart account 3MrdV3AP4zfU77ifesNStoDZmL1Cfx13eDc > SELF 0.00000000 Waves

{ "type": 13, "id": "J6b6hntFFT6GYqdB6mfyLhYmopVcL9sbeSozUvS9YQzf", "fee": 5000000, "feeAssetId": null, "timestamp": 1577896747994, "version": 1, "sender": "3MrdV3AP4zfU77ifesNStoDZmL1Cfx13eDc", "senderPublicKey": "5M79Anear5ntQk2bbDdFA2goiPXkv7Xy2UpV4n5RKRv", "proofs": [ "3Eq3Jp6Ly29jTM6GTfUSCpFjLTkxuAx9k2aeqvR6ZEAFUhkPA8GTQpghRmnvnha3FwvKhRNGCMak1gLYZNqoYLXU" ], "script": "base64:AAIDAAAAAAAAABoIARIAEgMKAQgSAwoBCBIDCgEIEgASAwoBAQAAABQAAAAADUxPQ0tFRFdCRVRLRVkCAAAAEyRXQkVUX0xPQ0tFRF9BTU9VTlQAAAAADkxPQ0tFRFJPWUFMS0VZAgAAABQkUk9ZQUxfTE9DS0VSX0FNT1VOVAAAAAAQV0FMTEVUQ09VTlRFUktFWQIAAAALJFdBTExFVF9OVU0AAAAAD0NPTU1VTklUWUZFRUtFWQIAAAAUJENPTU1VTklUWUZFRV9BTU9VTlQAAAAABFdCRVQBAAAAIIa0Nqh40w7M2PAXrUsuLAQfB5+6yrkWqUrXbyWtm9B2AAAAAAVST1lBTAEAAAAgQ+mKgsIl2XSclXwgUknGo5qQsraVX2JiXso4iYkMaRwAAAAAD0NPTU1VTklUWVdBTExFVAkBAAAAB0FkZHJlc3MAAAABAQAAABoBVC8R8HhOr9aTn6luIitmtR+yU9d4zzto+wAAAAAKV0JFVExPQ0tFRAAAAAAAAAAAAAAAAAALUk9ZQUxMT0NLRUQAAAAAAAAAAAEAAAAADFdCRVRXSVRIRFJBVwAAAAAAAAAAAgAAAAANUk9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AAECAAAANFlvdSBkbyBub3QgaGF2ZSBwZXJtaXNzaW9uIHRvIHBlcmZvcm0gdGhpcyBmdW5jdGlvbi4AAAAALvCsbA==", "chainId": 84, "height": 834986, "spentComplexity": 0 } View: original | compacted Prev: JDv8NTaAuouY7c9iJ5x9qTPydF3tiBkyKuPAszhFUXzW Next: AcQwYeqECaLRMMRkLKh2aJwGwodkbBYE1BryfkEgPcjm Diff:
OldNewDifferences
11 {-# STDLIB_VERSION 3 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
4-let RSAPUBLIC = fromBase64String("base64:MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAndGGi3mK3eNaz3UZwJ6DAzrMZJ2owHWOY0nGVmB2/OZLtLItmz29OHLL1iCWJU9zJBVtAX4xc/wMWzSyaqNUeAP7ggniG8Q3C7Ck7rAL/9rADgAGn5UFjnTP5ApYcQ+RHzlX82/qCVL/7USri4rnK/fmp/eTUs9kbN+LE6Stn1iDijJCAfrS/9zT+RQDH3T6ysYCHL0I6wkHHGx2w3qN3beoY4+loS+XnAg//0gHtkL93AUPEPeALj508XpvUH7fDnaUbrPcUy5a0t5VRIDF6fYCEaikcflWM9Wg3hdn8Yy5OSd8xKo2ArLeooVYdJcMVnmsdxmfgIGg1dDc4Vl7xwIDAQAB")
4+let LOCKEDWBETKEY = "$WBET_LOCKED_AMOUNT"
55
6-let GAMESCOUNTERKEY = "$GAME_NUM"
6+let LOCKEDROYALKEY = "$ROYAL_LOCKER_AMOUNT"
77
8-let RESERVATIONKEY = "$RESERVED_AMOUNT"
8+let WALLETCOUNTERKEY = "$WALLET_NUM"
9+
10+let COMMUNITYFEEKEY = "$COMMUNITYFEE_AMOUNT"
911
1012 let WBET = base58'A4q1mYKo11yuH9gmvDodeJoksagcyQzeFE9JtphMWddw'
1113
12-let WALLETCOMMUNITY = Address(base58'3MtCy2PCFPyu8A9SRNL4qUo1V17SGLHftD8')
14+let ROYAL = base58'5a6rvDEiVwvhTvTH6ce2qFwqdCt3VKaHKXEpwLXXVvyy'
1315
14-let WALLETWAVESBET = Address(base58'3MxK12u62zsu9xh3hU7p5iJncCLANd3zhTZ')
16+let COMMUNITYWALLET = Address(base58'3MtCy2PCFPyu8A9SRNL4qUo1V17SGLHftD8')
1517
16-let WALLETMCAFEE = Address(base58'3MxK12u62zsu9xh3hU7p5iJncCLANd3zhTZ')
18+let WBETLOCKED = 0
1719
18-let WAVELET = 100000000
20+let ROYALLOCKED = 1
1921
20-let FEECOMMUNITY = 1
22+let WBETWITHDRAW = 2
2123
22-let FEEWAVESBET = 3
24+let ROYALWITHDRAW = 3
2325
24-let FEEMCAFEE = 2
26+let WAVESWITHDRAW = 4
2527
26-let STATESUBMITTED = "SUBMITTED"
27-
28-let STATEWON = "WON"
29-
30-let STATELOST = "LOST"
31-
32-let ROLLUNDER = "UNDER"
33-
34-let ROLLOVER = "OVER"
35-
36-let BETMIN = (1000 * WAVELET)
37-
38-let BETMAX = (20000000 * WAVELET)
39-
40-let PREDICTIONMIN = 1
41-
42-let PREDICTIONMAX = 99
43-
44-let IdxGameState = 0
45-
46-let IdxPrediction = 1
47-
48-let IdxType = 2
49-
50-let IdxPlayerPubKey58 = 3
51-
52-let IdxWinAmt = 4
53-
54-let IdxRandOrEmpty = 5
55-
56-func IncrementGameNum () = {
57- let gameNum = match getInteger(this, GAMESCOUNTERKEY) {
28+func IncrementWalletNum () = {
29+ let walletNum = match getInteger(this, WALLETCOUNTERKEY) {
5830 case num: Int =>
5931 num
6032 case _ =>
6133 0
6234 }
63- (gameNum + 1)
35+ (walletNum + 1)
6436 }
6537
6638
67-func ExtractReservedAmt () = match getInteger(this, RESERVATIONKEY) {
39+func ExtractWBETReservedAmt () = match getInteger(this, LOCKEDWBETKEY) {
6840 case a: Int =>
6941 a
7042 case _ =>
7244 }
7345
7446
75-func ValidateAndIncreaseReservedAmt (winAmt) = {
76- let newReservedAmount = (ExtractReservedAmt() + winAmt)
77- let balance = assetBalance(this, WBET)
78- if ((newReservedAmount > balance))
79- then throw("Insufficient funds on Wavesbet Dice account. Transaction was rejected for your safety.")
80- else newReservedAmount
47+func ExtractROYALReservedAmt () = match getInteger(this, LOCKEDROYALKEY) {
48+ case a: Int =>
49+ a
50+ case _ =>
51+ 0
52+}
53+
54+
55+func ExtractFEEReservedAmt () = match getInteger(this, COMMUNITYFEEKEY) {
56+ case a: Int =>
57+ a
58+ case _ =>
59+ 0
60+}
61+
62+
63+func ExtractPlayerAmt (wallet) = match getString(this, wallet) {
64+ case str: String =>
65+ str
66+ case _ =>
67+ "0_0_0_0_0"
68+}
69+
70+
71+func WalletExist (wallet) = match getString(this, wallet) {
72+ case str: String =>
73+ true
74+ case _ =>
75+ false
76+}
77+
78+
79+func FormatPlayerBalance (wbet,royal,wbetWithdraw,royalWithdraw,wavesWithdraw) = ((((((((toString(wbet) + "_") + toString(royal)) + "_") + toString(wbetWithdraw)) + "_") + toString(royalWithdraw)) + "_") + toString(wavesWithdraw))
80+
81+
82+func ParsePlayerBalance (wallet) = {
83+ let amounts = split(ExtractPlayerAmt(wallet), "_")
84+ let wbetAmount = parseIntValue(amounts[WBETLOCKED])
85+ let royalAmount = parseIntValue(amounts[ROYALLOCKED])
86+ let wbetWithdraw = parseIntValue(amounts[WBETWITHDRAW])
87+ let royalWithdraw = parseIntValue(amounts[ROYALWITHDRAW])
88+ let wavesWithdraw = parseIntValue(amounts[WAVESWITHDRAW])
89+[wbetAmount, royalAmount, wbetWithdraw, royalWithdraw, wavesWithdraw]
8190 }
8291
8392
84-func FormatGameDataParam (p) = {
85- let s = size(p)
86- if ((s == 0))
87- then throw("Parameter size must be greater then 0")
88- else if ((s > 99))
89- then throw("Parameter size must be less then 100")
90- else if ((10 > s))
91- then (("0" + toString(s)) + p)
92- else (toString(s) + p)
93- }
94-
95-
96-func FormatGameDataStr (gameState,prediction,typeRoll,playerPubKey58,winAmt,randOrEmpty) = {
97- let fullStateStr = ((((((((FormatGameDataParam(gameState) + "_") + FormatGameDataParam(toString(prediction))) + "_") + FormatGameDataParam(typeRoll)) + "_") + FormatGameDataParam(playerPubKey58)) + "_") + FormatGameDataParam(toString(winAmt)))
98- if ((randOrEmpty == ""))
99- then fullStateStr
100- else ((fullStateStr + "_") + FormatGameDataParam(randOrEmpty))
101- }
102-
103-
104-func RemoveUnderscoreIfPresent (remaining) = if ((size(remaining) > 0))
105- then drop(remaining, 1)
106- else remaining
107-
108-
109-func ParseNextAttribute (remaining) = {
110- let s = size(remaining)
111- if ((s > 0))
112- then {
113- let nn = parseIntValue(take(remaining, 2))
114- let v = take(drop(remaining, 2), nn)
115- let tmpRemaining = drop(remaining, (nn + 2))
116- let remainingState = RemoveUnderscoreIfPresent(tmpRemaining)
117-[v, remainingState]
93+@Callable(i)
94+func lock () = {
95+ let payment = extract(i.payment)
96+ if (if ((payment.assetId != WBET))
97+ then (payment.assetId != ROYAL)
98+ else false)
99+ then throw("The token should be in WBET or ROYAL.")
100+ else {
101+ let wallet = toString(i.caller)
102+ let balance = ParsePlayerBalance(wallet)
103+ if ((payment.assetId == WBET))
104+ then {
105+ let newWBETReservedAmount = (ExtractWBETReservedAmt() + payment.amount)
106+ let newPlayerWBETAmount = (balance[WBETLOCKED] + payment.amount)
107+ if (WalletExist(wallet))
108+ then ScriptResult(WriteSet([DataEntry(LOCKEDWBETKEY, newWBETReservedAmount), DataEntry(wallet, FormatPlayerBalance(newPlayerWBETAmount, balance[ROYALLOCKED], balance[WBETWITHDRAW], balance[ROYALWITHDRAW], balance[WAVESWITHDRAW]))]), TransferSet(nil))
109+ else {
110+ let newWalletNum = IncrementWalletNum()
111+ ScriptResult(WriteSet([DataEntry(WALLETCOUNTERKEY, newWalletNum), DataEntry(LOCKEDWBETKEY, newWBETReservedAmount), DataEntry(wallet, FormatPlayerBalance(newPlayerWBETAmount, balance[ROYALLOCKED], balance[WBETWITHDRAW], balance[ROYALWITHDRAW], balance[WAVESWITHDRAW]))]), TransferSet(nil))
112+ }
113+ }
114+ else if ((payment.assetId == ROYAL))
115+ then {
116+ let newROYALReservedAmount = (ExtractROYALReservedAmt() + payment.amount)
117+ let newPlayerRoyalAmount = (balance[ROYALLOCKED] + payment.amount)
118+ if (WalletExist(wallet))
119+ then ScriptResult(WriteSet([DataEntry(LOCKEDROYALKEY, newROYALReservedAmount), DataEntry(wallet, FormatPlayerBalance(balance[WBETLOCKED], newPlayerRoyalAmount, balance[WBETWITHDRAW], balance[ROYALWITHDRAW], balance[WAVESWITHDRAW]))]), TransferSet(nil))
120+ else {
121+ let newWalletNum = IncrementWalletNum()
122+ ScriptResult(WriteSet([DataEntry(WALLETCOUNTERKEY, newWalletNum), DataEntry(LOCKEDROYALKEY, newROYALReservedAmount), DataEntry(wallet, FormatPlayerBalance(balance[WBETLOCKED], newPlayerRoyalAmount, balance[WBETWITHDRAW], balance[ROYALWITHDRAW], balance[WAVESWITHDRAW]))]), TransferSet(nil))
123+ }
124+ }
125+ else throw("error")
118126 }
119- else throw("Empty string was passed into parseNextAttribute func")
120- }
121-
122-
123-func ParseGameRawDataStr (rawStateStr) = {
124- let gameState = ParseNextAttribute(rawStateStr)
125- let prediction = ParseNextAttribute(gameState[1])
126- let rollType = ParseNextAttribute(prediction[1])
127- let playerPubKey58 = ParseNextAttribute(rollType[1])
128- let winAmt = ParseNextAttribute(playerPubKey58[1])
129-[gameState[0], prediction[0], rollType[0], playerPubKey58[0], winAmt[0]]
130- }
131-
132-
133-func ExtractGameDataList (gameId) = {
134- let rawDataStr = match getString(this, gameId) {
135- case str: String =>
136- str
137- case _ =>
138- throw(("Couldn't find game by " + gameId))
139- }
140- ParseGameRawDataStr(rawDataStr)
141- }
142-
143-
144-func DecreaseReservedAmt (gameId,winAmt) = {
145- let newReservedAmount = (ExtractReservedAmt() - winAmt)
146- if ((0 > newReservedAmount))
147- then throw("Invalid Dice Roller account state - reserved amount is less than 0")
148- else DataEntry(RESERVATIONKEY, newReservedAmount)
149- }
150-
151-
152-func GenerateRandInt (gameId,rsaSign) = {
153- let rsaSigValid = rsaVerify(SHA256, toBytes(gameId), rsaSign, RSAPUBLIC)
154- if (rsaSigValid)
155- then {
156- let rand = (toInt(sha256(rsaSign)) % 100)
157- if ((0 > rand))
158- then ((-1 * rand) + 1)
159- else (rand + 1)
160- }
161- else throw("Invalid RSA signature")
162- }
163-
164-
165-func RandToStr (r) = if (if ((r >= 1))
166- then (100 >= r)
167- else false)
168- then toString(r)
169- else throw(("Unsupported r parameter passed: expected=[1,...,100] actual=" + toString(r)))
170-
171-
172-func WinScriptSet (gameId,playerAddress,winAmt,newGameDataStr,decreasedReserves) = {
173- let wSetCommonData = [decreasedReserves]
174- let tSetCommonData = [ScriptTransfer(playerAddress, winAmt, WBET)]
175- let gameData = DataEntry(gameId, newGameDataStr)
176- ScriptResult(WriteSet(gameData :: wSetCommonData), TransferSet(tSetCommonData))
177- }
178-
179-
180-func Multiplier (prediction,rollType) = if ((rollType == ROLLUNDER))
181- then if ((prediction == 1))
182- then 9850000
183- else if ((prediction == 2))
184- then 4925000
185- else if ((prediction == 3))
186- then 3283330
187- else if ((prediction == 4))
188- then 2462500
189- else if ((prediction == 5))
190- then 1970000
191- else if ((prediction == 6))
192- then 1641660
193- else if ((prediction == 7))
194- then 1407140
195- else if ((prediction == 8))
196- then 1231250
197- else if ((prediction == 9))
198- then 1094440
199- else if ((prediction == 10))
200- then 985000
201- else if ((prediction == 11))
202- then 895450
203- else if ((prediction == 12))
204- then 820830
205- else if ((prediction == 13))
206- then 757690
207- else if ((prediction == 14))
208- then 703570
209- else if ((prediction == 15))
210- then 656660
211- else if ((prediction == 16))
212- then 615620
213- else if ((prediction == 17))
214- then 579410
215- else if ((prediction == 18))
216- then 547220
217- else if ((prediction == 19))
218- then 518420
219- else if ((prediction == 20))
220- then 492500
221- else if ((prediction == 21))
222- then 469040
223- else if ((prediction == 22))
224- then 447720
225- else if ((prediction == 23))
226- then 428260
227- else if ((prediction == 24))
228- then 410410
229- else if ((prediction == 25))
230- then 394000
231- else if ((prediction == 26))
232- then 378840
233- else if ((prediction == 27))
234- then 364810
235- else if ((prediction == 28))
236- then 351780
237- else if ((prediction == 29))
238- then 339650
239- else if ((prediction == 30))
240- then 328330
241- else if ((prediction == 31))
242- then 317740
243- else if ((prediction == 32))
244- then 307810
245- else if ((prediction == 33))
246- then 298480
247- else if ((prediction == 34))
248- then 289700
249- else if ((prediction == 35))
250- then 281420
251- else if ((prediction == 36))
252- then 273610
253- else if ((prediction == 37))
254- then 259210
255- else if ((prediction == 38))
256- then 259210
257- else if ((prediction == 39))
258- then 252560
259- else if ((prediction == 40))
260- then 246250
261- else if ((prediction == 41))
262- then 240240
263- else if ((prediction == 42))
264- then 234520
265- else if ((prediction == 43))
266- then 229060
267- else if ((prediction == 44))
268- then 223860
269- else if ((prediction == 45))
270- then 218880
271- else if ((prediction == 46))
272- then 214130
273- else if ((prediction == 47))
274- then 209570
275- else if ((prediction == 48))
276- then 205200
277- else if ((prediction == 49))
278- then 201020
279- else if ((prediction == 50))
280- then 197000
281- else if ((prediction == 51))
282- then 193130
283- else if ((prediction == 52))
284- then 189420
285- else if ((prediction == 53))
286- then 185840
287- else if ((prediction == 54))
288- then 182400
289- else if ((prediction == 55))
290- then 179090
291- else if ((prediction == 56))
292- then 175890
293- else if ((prediction == 57))
294- then 172800
295- else if ((prediction == 58))
296- then 169820
297- else if ((prediction == 59))
298- then 166940
299- else if ((prediction == 60))
300- then 164160
301- else if ((prediction == 61))
302- then 161470
303- else if ((prediction == 62))
304- then 158870
305- else if ((prediction == 63))
306- then 156340
307- else if ((prediction == 64))
308- then 153900
309- else if ((prediction == 65))
310- then 151530
311- else if ((prediction == 66))
312- then 149240
313- else if ((prediction == 67))
314- then 147010
315- else if ((prediction == 68))
316- then 144850
317- else if ((prediction == 69))
318- then 142750
319- else if ((prediction == 70))
320- then 140710
321- else if ((prediction == 71))
322- then 138730
323- else if ((prediction == 72))
324- then 136800
325- else if ((prediction == 73))
326- then 134930
327- else if ((prediction == 74))
328- then 133100
329- else if ((prediction == 75))
330- then 131330
331- else if ((prediction == 76))
332- then 129600
333- else if ((prediction == 77))
334- then 127920
335- else if ((prediction == 78))
336- then 126280
337- else if ((prediction == 79))
338- then 124680
339- else if ((prediction == 80))
340- then 123120
341- else if ((prediction == 81))
342- then 121600
343- else if ((prediction == 82))
344- then 120120
345- else if ((prediction == 83))
346- then 118670
347- else if ((prediction == 84))
348- then 117260
349- else if ((prediction == 85))
350- then 115880
351- else if ((prediction == 86))
352- then 114530
353- else if ((prediction == 87))
354- then 113210
355- else if ((prediction == 88))
356- then 111930
357- else if ((prediction == 89))
358- then 110670
359- else if ((prediction == 90))
360- then 109440
361- else if ((prediction == 91))
362- then 108240
363- else if ((prediction == 92))
364- then 107060
365- else if ((prediction == 93))
366- then 105910
367- else if ((prediction == 94))
368- then 104780
369- else if ((prediction == 95))
370- then 103680
371- else if ((prediction == 96))
372- then 103680
373- else 100000
374- else if ((rollType == ROLLOVER))
375- then if ((prediction == 4))
376- then 103680
377- else if ((prediction == 5))
378- then 103680
379- else if ((prediction == 6))
380- then 104780
381- else if ((prediction == 7))
382- then 105910
383- else if ((prediction == 8))
384- then 107060
385- else if ((prediction == 9))
386- then 108240
387- else if ((prediction == 10))
388- then 109440
389- else if ((prediction == 11))
390- then 110670
391- else if ((prediction == 12))
392- then 111930
393- else if ((prediction == 13))
394- then 113210
395- else if ((prediction == 14))
396- then 114530
397- else if ((prediction == 15))
398- then 115880
399- else if ((prediction == 16))
400- then 117260
401- else if ((prediction == 17))
402- then 118670
403- else if ((prediction == 18))
404- then 120120
405- else if ((prediction == 19))
406- then 121600
407- else if ((prediction == 20))
408- then 123120
409- else if ((prediction == 21))
410- then 124680
411- else if ((prediction == 22))
412- then 126280
413- else if ((prediction == 23))
414- then 127920
415- else if ((prediction == 24))
416- then 129600
417- else if ((prediction == 25))
418- then 131330
419- else if ((prediction == 26))
420- then 133100
421- else if ((prediction == 27))
422- then 134930
423- else if ((prediction == 28))
424- then 136800
425- else if ((prediction == 29))
426- then 138730
427- else if ((prediction == 30))
428- then 140710
429- else if ((prediction == 31))
430- then 142750
431- else if ((prediction == 32))
432- then 144850
433- else if ((prediction == 33))
434- then 147010
435- else if ((prediction == 34))
436- then 149240
437- else if ((prediction == 35))
438- then 151530
439- else if ((prediction == 36))
440- then 153900
441- else if ((prediction == 37))
442- then 156340
443- else if ((prediction == 38))
444- then 158870
445- else if ((prediction == 39))
446- then 161470
447- else if ((prediction == 40))
448- then 164160
449- else if ((prediction == 41))
450- then 166940
451- else if ((prediction == 42))
452- then 169820
453- else if ((prediction == 43))
454- then 172800
455- else if ((prediction == 44))
456- then 175890
457- else if ((prediction == 45))
458- then 179090
459- else if ((prediction == 46))
460- then 185840
461- else if ((prediction == 47))
462- then 185840
463- else if ((prediction == 48))
464- then 189420
465- else if ((prediction == 49))
466- then 193130
467- else if ((prediction == 50))
468- then 197000
469- else if ((prediction == 51))
470- then 201020
471- else if ((prediction == 52))
472- then 205200
473- else if ((prediction == 53))
474- then 209570
475- else if ((prediction == 54))
476- then 214130
477- else if ((prediction == 55))
478- then 218880
479- else if ((prediction == 56))
480- then 223860
481- else if ((prediction == 57))
482- then 229060
483- else if ((prediction == 58))
484- then 234520
485- else if ((prediction == 59))
486- then 240240
487- else if ((prediction == 60))
488- then 246250
489- else if ((prediction == 61))
490- then 252560
491- else if ((prediction == 62))
492- then 259210
493- else if ((prediction == 63))
494- then 259210
495- else if ((prediction == 64))
496- then 273610
497- else if ((prediction == 65))
498- then 281420
499- else if ((prediction == 66))
500- then 289700
501- else if ((prediction == 67))
502- then 298480
503- else if ((prediction == 68))
504- then 307810
505- else if ((prediction == 69))
506- then 317740
507- else if ((prediction == 70))
508- then 328330
509- else if ((prediction == 71))
510- then 339650
511- else if ((prediction == 72))
512- then 351780
513- else if ((prediction == 73))
514- then 364810
515- else if ((prediction == 74))
516- then 378840
517- else if ((prediction == 75))
518- then 394000
519- else if ((prediction == 76))
520- then 410410
521- else if ((prediction == 77))
522- then 428260
523- else if ((prediction == 78))
524- then 447720
525- else if ((prediction == 79))
526- then 469040
527- else if ((prediction == 80))
528- then 492500
529- else if ((prediction == 81))
530- then 518420
531- else if ((prediction == 82))
532- then 547220
533- else if ((prediction == 83))
534- then 579410
535- else if ((prediction == 84))
536- then 615620
537- else if ((prediction == 85))
538- then 656660
539- else if ((prediction == 86))
540- then 703570
541- else if ((prediction == 87))
542- then 757690
543- else if ((prediction == 88))
544- then 820830
545- else if ((prediction == 89))
546- then 895450
547- else if ((prediction == 90))
548- then 985000
549- else if ((prediction == 91))
550- then 1094440
551- else if ((prediction == 92))
552- then 1231250
553- else if ((prediction == 93))
554- then 1407140
555- else if ((prediction == 94))
556- then 1641660
557- else if ((prediction == 95))
558- then 1970000
559- else if ((prediction == 96))
560- then 2462500
561- else if ((prediction == 97))
562- then 3283330
563- else if ((prediction == 98))
564- then 4925000
565- else if ((prediction == 99))
566- then 9850000
567- else 100000
568- else 100000
569-
570-
571-func diceWin (type,prediction,number) = if ((type == ROLLUNDER))
572- then if ((prediction >= number))
573- then true
574- else false
575- else if ((type == ROLLOVER))
576- then if ((number >= prediction))
577- then true
578- else false
579- else false
580-
581-
582-func ValidateBetAndDefineWinAmt (amount,prediction,rollType) = if (if ((BETMIN > amount))
583- then true
584- else (amount > BETMAX))
585- then throw(((("Bet amount is not in range: minBet=" + toString((BETMIN / WAVELET))) + " maxBet=") + toString((BETMAX / WAVELET))))
586- else if (if ((rollType != ROLLUNDER))
587- then (rollType != ROLLOVER)
588- else false)
589- then throw("Invalid Roll type, try with OVER or UNDER")
590- else if (if (if ((rollType == ROLLUNDER))
591- then (1 > prediction)
592- else false)
593- then true
594- else if ((rollType == ROLLUNDER))
595- then (prediction > 96)
596- else false)
597- then throw("Prediction is out of the range for ROLL UNDER: 1 <= PREDICTION <= 96")
598- else if (if (if ((rollType == ROLLOVER))
599- then (4 > prediction)
600- else false)
601- then true
602- else if ((rollType == ROLLOVER))
603- then (prediction > 99)
604- else false)
605- then throw("Prediction is out of the range for ROLL OVER: 4 <= PREDICTION <= 99")
606- else {
607- let multi = Multiplier(prediction, rollType)
608- fraction(((amount / 100000) * multi), (((100 - FEEWAVESBET) - FEEMCAFEE) - FEECOMMUNITY), 100)
609- }
610-
611-
612-@Callable(i)
613-func playDice (rollType,prediction) = {
614- let gameId = toBase58String(i.transactionId)
615- let payment = extract(i.payment)
616- let feeAssetId = isDefined(i.feeAssetId)
617- let winAmt = ValidateBetAndDefineWinAmt(payment.amount, prediction, rollType)
618- let playerBalance = wavesBalance(i.caller)
619- let gameIdUsed = isDefined(getString(this, gameId))
620- if ((payment.assetId != WBET))
621- then throw("Payment should be in Wavesbet")
622- else if ((1000000 > playerBalance))
623- then throw("There are not enough waves, it takes 0.01 Waves to bet. Game aborted.")
624- else if (feeAssetId)
625- then throw("Transaction's fee must be in Waves. Game aborted.")
626- else if (gameIdUsed)
627- then throw("Passed gameId had been used before. Game aborted.")
628- else {
629- let newGameNum = IncrementGameNum()
630- let playerPubKey58 = toBase58String(i.callerPublicKey)
631- let gameDataStr = FormatGameDataStr(STATESUBMITTED, prediction, rollType, playerPubKey58, winAmt, "")
632- ScriptResult(WriteSet([DataEntry(RESERVATIONKEY, ValidateAndIncreaseReservedAmt(winAmt)), DataEntry(GAMESCOUNTERKEY, newGameNum), DataEntry(gameId, gameDataStr)]), TransferSet([ScriptTransfer(WALLETCOMMUNITY, fraction(payment.amount, FEECOMMUNITY, 100), WBET), ScriptTransfer(WALLETWAVESBET, fraction(payment.amount, FEEWAVESBET, 100), WBET), ScriptTransfer(WALLETMCAFEE, fraction(payment.amount, FEEMCAFEE, 100), WBET)]))
633- }
634127 }
635128
636129
637130
638131 @Callable(i)
639-func withdraw (gameId,rsaSig) = {
640- let gameDataList = ExtractGameDataList(gameId)
641- let gameState = gameDataList[IdxGameState]
642- let prediction = parseIntValue(gameDataList[IdxPrediction])
643- let rollType = gameDataList[IdxType]
644- let winAmt = parseIntValue(gameDataList[IdxWinAmt])
645- let playerPubKey58 = gameDataList[IdxPlayerPubKey58]
646- let playerAddress = addressFromPublicKey(fromBase58String(playerPubKey58))
647- let decreasedReserves = DecreaseReservedAmt(gameId, winAmt)
648- if ((gameState != STATESUBMITTED))
649- then throw("Invalid game state for passed gameId. Game aborted.")
132+func unlock (asset) = {
133+ let wallet = toString(i.caller)
134+ let balance = ParsePlayerBalance(wallet)
135+ if ((asset == "WBET"))
136+ then if ((0 >= balance[WBETLOCKED]))
137+ then throw("You dont have enough balance to withdraw the amount requested.")
138+ else {
139+ let newWBETReservedAmount = (ExtractWBETReservedAmt() - balance[WBETLOCKED])
140+ ScriptResult(WriteSet([DataEntry(LOCKEDWBETKEY, newWBETReservedAmount), DataEntry(wallet, FormatPlayerBalance(0, balance[ROYALLOCKED], balance[WBETWITHDRAW], balance[ROYALWITHDRAW], balance[WAVESWITHDRAW]))]), TransferSet([ScriptTransfer(i.caller, balance[WBETLOCKED], WBET)]))
141+ }
142+ else if ((asset == "ROYAL"))
143+ then if ((0 >= balance[ROYALLOCKED]))
144+ then throw("You dont have enough balance to withdraw the amount requested.")
145+ else {
146+ let newROYALReservedAmount = (ExtractROYALReservedAmt() - balance[ROYALLOCKED])
147+ ScriptResult(WriteSet([DataEntry(LOCKEDROYALKEY, newROYALReservedAmount), DataEntry(wallet, FormatPlayerBalance(balance[WBETLOCKED], 0, balance[WBETWITHDRAW], balance[ROYALWITHDRAW], balance[WAVESWITHDRAW]))]), TransferSet([ScriptTransfer(i.caller, balance[ROYALLOCKED], ROYAL)]))
148+ }
149+ else throw("Invalid asset")
150+ }
151+
152+
153+
154+@Callable(i)
155+func withdraw (asset) = {
156+ let wallet = toString(i.caller)
157+ let balance = ParsePlayerBalance(wallet)
158+ if ((asset == "WBET"))
159+ then if ((0 >= balance[WBETWITHDRAW]))
160+ then throw("You dont have enough balance to withdraw the amount requested.")
161+ else ScriptResult(WriteSet([DataEntry(wallet, FormatPlayerBalance(balance[WBETLOCKED], balance[ROYALLOCKED], 0, balance[ROYALWITHDRAW], balance[WAVESWITHDRAW]))]), TransferSet([ScriptTransfer(i.caller, balance[WBETWITHDRAW], WBET)]))
162+ else if ((asset == "ROYAL"))
163+ then if ((0 >= balance[ROYALWITHDRAW]))
164+ then throw("You dont have enough balance to withdraw the amount requested.")
165+ else ScriptResult(WriteSet([DataEntry(wallet, FormatPlayerBalance(balance[WBETLOCKED], balance[ROYALLOCKED], balance[WBETWITHDRAW], 0, balance[WAVESWITHDRAW]))]), TransferSet([ScriptTransfer(i.caller, balance[ROYALWITHDRAW], ROYAL)]))
166+ else if ((asset == "WAVES"))
167+ then if ((0 >= balance[WAVESWITHDRAW]))
168+ then throw("You dont have enough balance to withdraw the amount requested.")
169+ else ScriptResult(WriteSet([DataEntry(wallet, FormatPlayerBalance(balance[WBETLOCKED], balance[ROYALLOCKED], balance[WBETWITHDRAW], balance[WBETWITHDRAW], 0))]), TransferSet([ScriptTransfer(i.caller, balance[WAVESWITHDRAW], unit)]))
170+ else throw("Invalid asset")
171+ }
172+
173+
174+
175+@Callable(i)
176+func addWithdraw (wallet) = if ((i.caller == COMMUNITYWALLET))
177+ then {
178+ let payment = extract(i.payment)
179+ let balance = ParsePlayerBalance(wallet)
180+ if ((payment.assetId == WBET))
181+ then {
182+ let newWbetAmount = (balance[WBETWITHDRAW] + payment.amount)
183+ ScriptResult(WriteSet([DataEntry(wallet, FormatPlayerBalance(balance[WBETLOCKED], balance[ROYALLOCKED], newWbetAmount, balance[ROYALWITHDRAW], balance[WAVESWITHDRAW]))]), TransferSet(nil))
184+ }
185+ else if ((payment.assetId == ROYAL))
186+ then {
187+ let newRoyalAmount = (balance[ROYALWITHDRAW] + payment.amount)
188+ ScriptResult(WriteSet([DataEntry(wallet, FormatPlayerBalance(balance[WBETLOCKED], balance[ROYALLOCKED], balance[WBETWITHDRAW], newRoyalAmount, balance[WAVESWITHDRAW]))]), TransferSet(nil))
189+ }
190+ else if ((payment.assetId == unit))
191+ then {
192+ let newWavesAmount = (balance[WAVESWITHDRAW] + payment.amount)
193+ ScriptResult(WriteSet([DataEntry(wallet, FormatPlayerBalance(balance[WBETLOCKED], balance[ROYALLOCKED], balance[WBETWITHDRAW], balance[ROYALWITHDRAW], newWavesAmount))]), TransferSet(nil))
194+ }
195+ else throw("Invalid asset")
196+ }
197+ else throw("You do not have permission to perform this function.")
198+
199+
200+
201+@Callable(i)
202+func addCommunityFee () = {
203+ let payment = extract(i.payment)
204+ if ((payment.assetId != assetInfo(base58'WAVES')))
205+ then throw("Payment should be in WAVES.")
650206 else {
651- let rand = GenerateRandInt(gameId, rsaSig)
652- let randStr = RandToStr(rand)
653- if (diceWin(rollType, prediction, rand))
654- then {
655- let newGameDataStr = FormatGameDataStr(STATEWON, prediction, rollType, playerPubKey58, winAmt, randStr)
656- WinScriptSet(gameId, playerAddress, winAmt, newGameDataStr, decreasedReserves)
657- }
658- else {
659- let newGameDataStr = FormatGameDataStr(STATELOST, prediction, rollType, playerPubKey58, winAmt, randStr)
660- WriteSet([DataEntry(gameId, newGameDataStr), decreasedReserves])
661- }
207+ let newFEEReservedAmount = (ExtractFEEReservedAmt() + payment.amount)
208+ ScriptResult(WriteSet([DataEntry(COMMUNITYFEEKEY, newFEEReservedAmount)]), TransferSet(nil))
662209 }
663210 }
664211
665212
666-@Verifier(tx)
667-func verify () = if (sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey))
668- then match tx {
669- case ttx: TransferTransaction =>
670- ((assetBalance(this, WBET) - ttx.amount) >= ExtractReservedAmt())
671- case stx: SetScriptTransaction =>
672- true
673- case _ =>
674- false
675- }
676- else false
213+
214+@Callable(i)
215+func getCommunityFee (amount) = if ((i.caller == COMMUNITYWALLET))
216+ then {
217+ let payment = extract(i.payment)
218+ let FEEReservedAmount = ExtractFEEReservedAmt()
219+ if ((amount > FEEReservedAmount))
220+ then throw("You dont have enough balance to transfer the amount requested.")
221+ else {
222+ let newFEEReservedAmount = (FEEReservedAmount - amount)
223+ ScriptResult(WriteSet([DataEntry(COMMUNITYFEEKEY, newFEEReservedAmount)]), TransferSet([ScriptTransfer(COMMUNITYWALLET, amount, unit)]))
224+ }
225+ }
226+ else throw("You do not have permission to perform this function.")
227+
677228
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 3 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
4-let RSAPUBLIC = fromBase64String("base64:MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAndGGi3mK3eNaz3UZwJ6DAzrMZJ2owHWOY0nGVmB2/OZLtLItmz29OHLL1iCWJU9zJBVtAX4xc/wMWzSyaqNUeAP7ggniG8Q3C7Ck7rAL/9rADgAGn5UFjnTP5ApYcQ+RHzlX82/qCVL/7USri4rnK/fmp/eTUs9kbN+LE6Stn1iDijJCAfrS/9zT+RQDH3T6ysYCHL0I6wkHHGx2w3qN3beoY4+loS+XnAg//0gHtkL93AUPEPeALj508XpvUH7fDnaUbrPcUy5a0t5VRIDF6fYCEaikcflWM9Wg3hdn8Yy5OSd8xKo2ArLeooVYdJcMVnmsdxmfgIGg1dDc4Vl7xwIDAQAB")
4+let LOCKEDWBETKEY = "$WBET_LOCKED_AMOUNT"
55
6-let GAMESCOUNTERKEY = "$GAME_NUM"
6+let LOCKEDROYALKEY = "$ROYAL_LOCKER_AMOUNT"
77
8-let RESERVATIONKEY = "$RESERVED_AMOUNT"
8+let WALLETCOUNTERKEY = "$WALLET_NUM"
9+
10+let COMMUNITYFEEKEY = "$COMMUNITYFEE_AMOUNT"
911
1012 let WBET = base58'A4q1mYKo11yuH9gmvDodeJoksagcyQzeFE9JtphMWddw'
1113
12-let WALLETCOMMUNITY = Address(base58'3MtCy2PCFPyu8A9SRNL4qUo1V17SGLHftD8')
14+let ROYAL = base58'5a6rvDEiVwvhTvTH6ce2qFwqdCt3VKaHKXEpwLXXVvyy'
1315
14-let WALLETWAVESBET = Address(base58'3MxK12u62zsu9xh3hU7p5iJncCLANd3zhTZ')
16+let COMMUNITYWALLET = Address(base58'3MtCy2PCFPyu8A9SRNL4qUo1V17SGLHftD8')
1517
16-let WALLETMCAFEE = Address(base58'3MxK12u62zsu9xh3hU7p5iJncCLANd3zhTZ')
18+let WBETLOCKED = 0
1719
18-let WAVELET = 100000000
20+let ROYALLOCKED = 1
1921
20-let FEECOMMUNITY = 1
22+let WBETWITHDRAW = 2
2123
22-let FEEWAVESBET = 3
24+let ROYALWITHDRAW = 3
2325
24-let FEEMCAFEE = 2
26+let WAVESWITHDRAW = 4
2527
26-let STATESUBMITTED = "SUBMITTED"
27-
28-let STATEWON = "WON"
29-
30-let STATELOST = "LOST"
31-
32-let ROLLUNDER = "UNDER"
33-
34-let ROLLOVER = "OVER"
35-
36-let BETMIN = (1000 * WAVELET)
37-
38-let BETMAX = (20000000 * WAVELET)
39-
40-let PREDICTIONMIN = 1
41-
42-let PREDICTIONMAX = 99
43-
44-let IdxGameState = 0
45-
46-let IdxPrediction = 1
47-
48-let IdxType = 2
49-
50-let IdxPlayerPubKey58 = 3
51-
52-let IdxWinAmt = 4
53-
54-let IdxRandOrEmpty = 5
55-
56-func IncrementGameNum () = {
57- let gameNum = match getInteger(this, GAMESCOUNTERKEY) {
28+func IncrementWalletNum () = {
29+ let walletNum = match getInteger(this, WALLETCOUNTERKEY) {
5830 case num: Int =>
5931 num
6032 case _ =>
6133 0
6234 }
63- (gameNum + 1)
35+ (walletNum + 1)
6436 }
6537
6638
67-func ExtractReservedAmt () = match getInteger(this, RESERVATIONKEY) {
39+func ExtractWBETReservedAmt () = match getInteger(this, LOCKEDWBETKEY) {
6840 case a: Int =>
6941 a
7042 case _ =>
7143 0
7244 }
7345
7446
75-func ValidateAndIncreaseReservedAmt (winAmt) = {
76- let newReservedAmount = (ExtractReservedAmt() + winAmt)
77- let balance = assetBalance(this, WBET)
78- if ((newReservedAmount > balance))
79- then throw("Insufficient funds on Wavesbet Dice account. Transaction was rejected for your safety.")
80- else newReservedAmount
47+func ExtractROYALReservedAmt () = match getInteger(this, LOCKEDROYALKEY) {
48+ case a: Int =>
49+ a
50+ case _ =>
51+ 0
52+}
53+
54+
55+func ExtractFEEReservedAmt () = match getInteger(this, COMMUNITYFEEKEY) {
56+ case a: Int =>
57+ a
58+ case _ =>
59+ 0
60+}
61+
62+
63+func ExtractPlayerAmt (wallet) = match getString(this, wallet) {
64+ case str: String =>
65+ str
66+ case _ =>
67+ "0_0_0_0_0"
68+}
69+
70+
71+func WalletExist (wallet) = match getString(this, wallet) {
72+ case str: String =>
73+ true
74+ case _ =>
75+ false
76+}
77+
78+
79+func FormatPlayerBalance (wbet,royal,wbetWithdraw,royalWithdraw,wavesWithdraw) = ((((((((toString(wbet) + "_") + toString(royal)) + "_") + toString(wbetWithdraw)) + "_") + toString(royalWithdraw)) + "_") + toString(wavesWithdraw))
80+
81+
82+func ParsePlayerBalance (wallet) = {
83+ let amounts = split(ExtractPlayerAmt(wallet), "_")
84+ let wbetAmount = parseIntValue(amounts[WBETLOCKED])
85+ let royalAmount = parseIntValue(amounts[ROYALLOCKED])
86+ let wbetWithdraw = parseIntValue(amounts[WBETWITHDRAW])
87+ let royalWithdraw = parseIntValue(amounts[ROYALWITHDRAW])
88+ let wavesWithdraw = parseIntValue(amounts[WAVESWITHDRAW])
89+[wbetAmount, royalAmount, wbetWithdraw, royalWithdraw, wavesWithdraw]
8190 }
8291
8392
84-func FormatGameDataParam (p) = {
85- let s = size(p)
86- if ((s == 0))
87- then throw("Parameter size must be greater then 0")
88- else if ((s > 99))
89- then throw("Parameter size must be less then 100")
90- else if ((10 > s))
91- then (("0" + toString(s)) + p)
92- else (toString(s) + p)
93- }
94-
95-
96-func FormatGameDataStr (gameState,prediction,typeRoll,playerPubKey58,winAmt,randOrEmpty) = {
97- let fullStateStr = ((((((((FormatGameDataParam(gameState) + "_") + FormatGameDataParam(toString(prediction))) + "_") + FormatGameDataParam(typeRoll)) + "_") + FormatGameDataParam(playerPubKey58)) + "_") + FormatGameDataParam(toString(winAmt)))
98- if ((randOrEmpty == ""))
99- then fullStateStr
100- else ((fullStateStr + "_") + FormatGameDataParam(randOrEmpty))
101- }
102-
103-
104-func RemoveUnderscoreIfPresent (remaining) = if ((size(remaining) > 0))
105- then drop(remaining, 1)
106- else remaining
107-
108-
109-func ParseNextAttribute (remaining) = {
110- let s = size(remaining)
111- if ((s > 0))
112- then {
113- let nn = parseIntValue(take(remaining, 2))
114- let v = take(drop(remaining, 2), nn)
115- let tmpRemaining = drop(remaining, (nn + 2))
116- let remainingState = RemoveUnderscoreIfPresent(tmpRemaining)
117-[v, remainingState]
93+@Callable(i)
94+func lock () = {
95+ let payment = extract(i.payment)
96+ if (if ((payment.assetId != WBET))
97+ then (payment.assetId != ROYAL)
98+ else false)
99+ then throw("The token should be in WBET or ROYAL.")
100+ else {
101+ let wallet = toString(i.caller)
102+ let balance = ParsePlayerBalance(wallet)
103+ if ((payment.assetId == WBET))
104+ then {
105+ let newWBETReservedAmount = (ExtractWBETReservedAmt() + payment.amount)
106+ let newPlayerWBETAmount = (balance[WBETLOCKED] + payment.amount)
107+ if (WalletExist(wallet))
108+ then ScriptResult(WriteSet([DataEntry(LOCKEDWBETKEY, newWBETReservedAmount), DataEntry(wallet, FormatPlayerBalance(newPlayerWBETAmount, balance[ROYALLOCKED], balance[WBETWITHDRAW], balance[ROYALWITHDRAW], balance[WAVESWITHDRAW]))]), TransferSet(nil))
109+ else {
110+ let newWalletNum = IncrementWalletNum()
111+ ScriptResult(WriteSet([DataEntry(WALLETCOUNTERKEY, newWalletNum), DataEntry(LOCKEDWBETKEY, newWBETReservedAmount), DataEntry(wallet, FormatPlayerBalance(newPlayerWBETAmount, balance[ROYALLOCKED], balance[WBETWITHDRAW], balance[ROYALWITHDRAW], balance[WAVESWITHDRAW]))]), TransferSet(nil))
112+ }
113+ }
114+ else if ((payment.assetId == ROYAL))
115+ then {
116+ let newROYALReservedAmount = (ExtractROYALReservedAmt() + payment.amount)
117+ let newPlayerRoyalAmount = (balance[ROYALLOCKED] + payment.amount)
118+ if (WalletExist(wallet))
119+ then ScriptResult(WriteSet([DataEntry(LOCKEDROYALKEY, newROYALReservedAmount), DataEntry(wallet, FormatPlayerBalance(balance[WBETLOCKED], newPlayerRoyalAmount, balance[WBETWITHDRAW], balance[ROYALWITHDRAW], balance[WAVESWITHDRAW]))]), TransferSet(nil))
120+ else {
121+ let newWalletNum = IncrementWalletNum()
122+ ScriptResult(WriteSet([DataEntry(WALLETCOUNTERKEY, newWalletNum), DataEntry(LOCKEDROYALKEY, newROYALReservedAmount), DataEntry(wallet, FormatPlayerBalance(balance[WBETLOCKED], newPlayerRoyalAmount, balance[WBETWITHDRAW], balance[ROYALWITHDRAW], balance[WAVESWITHDRAW]))]), TransferSet(nil))
123+ }
124+ }
125+ else throw("error")
118126 }
119- else throw("Empty string was passed into parseNextAttribute func")
120- }
121-
122-
123-func ParseGameRawDataStr (rawStateStr) = {
124- let gameState = ParseNextAttribute(rawStateStr)
125- let prediction = ParseNextAttribute(gameState[1])
126- let rollType = ParseNextAttribute(prediction[1])
127- let playerPubKey58 = ParseNextAttribute(rollType[1])
128- let winAmt = ParseNextAttribute(playerPubKey58[1])
129-[gameState[0], prediction[0], rollType[0], playerPubKey58[0], winAmt[0]]
130- }
131-
132-
133-func ExtractGameDataList (gameId) = {
134- let rawDataStr = match getString(this, gameId) {
135- case str: String =>
136- str
137- case _ =>
138- throw(("Couldn't find game by " + gameId))
139- }
140- ParseGameRawDataStr(rawDataStr)
141- }
142-
143-
144-func DecreaseReservedAmt (gameId,winAmt) = {
145- let newReservedAmount = (ExtractReservedAmt() - winAmt)
146- if ((0 > newReservedAmount))
147- then throw("Invalid Dice Roller account state - reserved amount is less than 0")
148- else DataEntry(RESERVATIONKEY, newReservedAmount)
149- }
150-
151-
152-func GenerateRandInt (gameId,rsaSign) = {
153- let rsaSigValid = rsaVerify(SHA256, toBytes(gameId), rsaSign, RSAPUBLIC)
154- if (rsaSigValid)
155- then {
156- let rand = (toInt(sha256(rsaSign)) % 100)
157- if ((0 > rand))
158- then ((-1 * rand) + 1)
159- else (rand + 1)
160- }
161- else throw("Invalid RSA signature")
162- }
163-
164-
165-func RandToStr (r) = if (if ((r >= 1))
166- then (100 >= r)
167- else false)
168- then toString(r)
169- else throw(("Unsupported r parameter passed: expected=[1,...,100] actual=" + toString(r)))
170-
171-
172-func WinScriptSet (gameId,playerAddress,winAmt,newGameDataStr,decreasedReserves) = {
173- let wSetCommonData = [decreasedReserves]
174- let tSetCommonData = [ScriptTransfer(playerAddress, winAmt, WBET)]
175- let gameData = DataEntry(gameId, newGameDataStr)
176- ScriptResult(WriteSet(gameData :: wSetCommonData), TransferSet(tSetCommonData))
177- }
178-
179-
180-func Multiplier (prediction,rollType) = if ((rollType == ROLLUNDER))
181- then if ((prediction == 1))
182- then 9850000
183- else if ((prediction == 2))
184- then 4925000
185- else if ((prediction == 3))
186- then 3283330
187- else if ((prediction == 4))
188- then 2462500
189- else if ((prediction == 5))
190- then 1970000
191- else if ((prediction == 6))
192- then 1641660
193- else if ((prediction == 7))
194- then 1407140
195- else if ((prediction == 8))
196- then 1231250
197- else if ((prediction == 9))
198- then 1094440
199- else if ((prediction == 10))
200- then 985000
201- else if ((prediction == 11))
202- then 895450
203- else if ((prediction == 12))
204- then 820830
205- else if ((prediction == 13))
206- then 757690
207- else if ((prediction == 14))
208- then 703570
209- else if ((prediction == 15))
210- then 656660
211- else if ((prediction == 16))
212- then 615620
213- else if ((prediction == 17))
214- then 579410
215- else if ((prediction == 18))
216- then 547220
217- else if ((prediction == 19))
218- then 518420
219- else if ((prediction == 20))
220- then 492500
221- else if ((prediction == 21))
222- then 469040
223- else if ((prediction == 22))
224- then 447720
225- else if ((prediction == 23))
226- then 428260
227- else if ((prediction == 24))
228- then 410410
229- else if ((prediction == 25))
230- then 394000
231- else if ((prediction == 26))
232- then 378840
233- else if ((prediction == 27))
234- then 364810
235- else if ((prediction == 28))
236- then 351780
237- else if ((prediction == 29))
238- then 339650
239- else if ((prediction == 30))
240- then 328330
241- else if ((prediction == 31))
242- then 317740
243- else if ((prediction == 32))
244- then 307810
245- else if ((prediction == 33))
246- then 298480
247- else if ((prediction == 34))
248- then 289700
249- else if ((prediction == 35))
250- then 281420
251- else if ((prediction == 36))
252- then 273610
253- else if ((prediction == 37))
254- then 259210
255- else if ((prediction == 38))
256- then 259210
257- else if ((prediction == 39))
258- then 252560
259- else if ((prediction == 40))
260- then 246250
261- else if ((prediction == 41))
262- then 240240
263- else if ((prediction == 42))
264- then 234520
265- else if ((prediction == 43))
266- then 229060
267- else if ((prediction == 44))
268- then 223860
269- else if ((prediction == 45))
270- then 218880
271- else if ((prediction == 46))
272- then 214130
273- else if ((prediction == 47))
274- then 209570
275- else if ((prediction == 48))
276- then 205200
277- else if ((prediction == 49))
278- then 201020
279- else if ((prediction == 50))
280- then 197000
281- else if ((prediction == 51))
282- then 193130
283- else if ((prediction == 52))
284- then 189420
285- else if ((prediction == 53))
286- then 185840
287- else if ((prediction == 54))
288- then 182400
289- else if ((prediction == 55))
290- then 179090
291- else if ((prediction == 56))
292- then 175890
293- else if ((prediction == 57))
294- then 172800
295- else if ((prediction == 58))
296- then 169820
297- else if ((prediction == 59))
298- then 166940
299- else if ((prediction == 60))
300- then 164160
301- else if ((prediction == 61))
302- then 161470
303- else if ((prediction == 62))
304- then 158870
305- else if ((prediction == 63))
306- then 156340
307- else if ((prediction == 64))
308- then 153900
309- else if ((prediction == 65))
310- then 151530
311- else if ((prediction == 66))
312- then 149240
313- else if ((prediction == 67))
314- then 147010
315- else if ((prediction == 68))
316- then 144850
317- else if ((prediction == 69))
318- then 142750
319- else if ((prediction == 70))
320- then 140710
321- else if ((prediction == 71))
322- then 138730
323- else if ((prediction == 72))
324- then 136800
325- else if ((prediction == 73))
326- then 134930
327- else if ((prediction == 74))
328- then 133100
329- else if ((prediction == 75))
330- then 131330
331- else if ((prediction == 76))
332- then 129600
333- else if ((prediction == 77))
334- then 127920
335- else if ((prediction == 78))
336- then 126280
337- else if ((prediction == 79))
338- then 124680
339- else if ((prediction == 80))
340- then 123120
341- else if ((prediction == 81))
342- then 121600
343- else if ((prediction == 82))
344- then 120120
345- else if ((prediction == 83))
346- then 118670
347- else if ((prediction == 84))
348- then 117260
349- else if ((prediction == 85))
350- then 115880
351- else if ((prediction == 86))
352- then 114530
353- else if ((prediction == 87))
354- then 113210
355- else if ((prediction == 88))
356- then 111930
357- else if ((prediction == 89))
358- then 110670
359- else if ((prediction == 90))
360- then 109440
361- else if ((prediction == 91))
362- then 108240
363- else if ((prediction == 92))
364- then 107060
365- else if ((prediction == 93))
366- then 105910
367- else if ((prediction == 94))
368- then 104780
369- else if ((prediction == 95))
370- then 103680
371- else if ((prediction == 96))
372- then 103680
373- else 100000
374- else if ((rollType == ROLLOVER))
375- then if ((prediction == 4))
376- then 103680
377- else if ((prediction == 5))
378- then 103680
379- else if ((prediction == 6))
380- then 104780
381- else if ((prediction == 7))
382- then 105910
383- else if ((prediction == 8))
384- then 107060
385- else if ((prediction == 9))
386- then 108240
387- else if ((prediction == 10))
388- then 109440
389- else if ((prediction == 11))
390- then 110670
391- else if ((prediction == 12))
392- then 111930
393- else if ((prediction == 13))
394- then 113210
395- else if ((prediction == 14))
396- then 114530
397- else if ((prediction == 15))
398- then 115880
399- else if ((prediction == 16))
400- then 117260
401- else if ((prediction == 17))
402- then 118670
403- else if ((prediction == 18))
404- then 120120
405- else if ((prediction == 19))
406- then 121600
407- else if ((prediction == 20))
408- then 123120
409- else if ((prediction == 21))
410- then 124680
411- else if ((prediction == 22))
412- then 126280
413- else if ((prediction == 23))
414- then 127920
415- else if ((prediction == 24))
416- then 129600
417- else if ((prediction == 25))
418- then 131330
419- else if ((prediction == 26))
420- then 133100
421- else if ((prediction == 27))
422- then 134930
423- else if ((prediction == 28))
424- then 136800
425- else if ((prediction == 29))
426- then 138730
427- else if ((prediction == 30))
428- then 140710
429- else if ((prediction == 31))
430- then 142750
431- else if ((prediction == 32))
432- then 144850
433- else if ((prediction == 33))
434- then 147010
435- else if ((prediction == 34))
436- then 149240
437- else if ((prediction == 35))
438- then 151530
439- else if ((prediction == 36))
440- then 153900
441- else if ((prediction == 37))
442- then 156340
443- else if ((prediction == 38))
444- then 158870
445- else if ((prediction == 39))
446- then 161470
447- else if ((prediction == 40))
448- then 164160
449- else if ((prediction == 41))
450- then 166940
451- else if ((prediction == 42))
452- then 169820
453- else if ((prediction == 43))
454- then 172800
455- else if ((prediction == 44))
456- then 175890
457- else if ((prediction == 45))
458- then 179090
459- else if ((prediction == 46))
460- then 185840
461- else if ((prediction == 47))
462- then 185840
463- else if ((prediction == 48))
464- then 189420
465- else if ((prediction == 49))
466- then 193130
467- else if ((prediction == 50))
468- then 197000
469- else if ((prediction == 51))
470- then 201020
471- else if ((prediction == 52))
472- then 205200
473- else if ((prediction == 53))
474- then 209570
475- else if ((prediction == 54))
476- then 214130
477- else if ((prediction == 55))
478- then 218880
479- else if ((prediction == 56))
480- then 223860
481- else if ((prediction == 57))
482- then 229060
483- else if ((prediction == 58))
484- then 234520
485- else if ((prediction == 59))
486- then 240240
487- else if ((prediction == 60))
488- then 246250
489- else if ((prediction == 61))
490- then 252560
491- else if ((prediction == 62))
492- then 259210
493- else if ((prediction == 63))
494- then 259210
495- else if ((prediction == 64))
496- then 273610
497- else if ((prediction == 65))
498- then 281420
499- else if ((prediction == 66))
500- then 289700
501- else if ((prediction == 67))
502- then 298480
503- else if ((prediction == 68))
504- then 307810
505- else if ((prediction == 69))
506- then 317740
507- else if ((prediction == 70))
508- then 328330
509- else if ((prediction == 71))
510- then 339650
511- else if ((prediction == 72))
512- then 351780
513- else if ((prediction == 73))
514- then 364810
515- else if ((prediction == 74))
516- then 378840
517- else if ((prediction == 75))
518- then 394000
519- else if ((prediction == 76))
520- then 410410
521- else if ((prediction == 77))
522- then 428260
523- else if ((prediction == 78))
524- then 447720
525- else if ((prediction == 79))
526- then 469040
527- else if ((prediction == 80))
528- then 492500
529- else if ((prediction == 81))
530- then 518420
531- else if ((prediction == 82))
532- then 547220
533- else if ((prediction == 83))
534- then 579410
535- else if ((prediction == 84))
536- then 615620
537- else if ((prediction == 85))
538- then 656660
539- else if ((prediction == 86))
540- then 703570
541- else if ((prediction == 87))
542- then 757690
543- else if ((prediction == 88))
544- then 820830
545- else if ((prediction == 89))
546- then 895450
547- else if ((prediction == 90))
548- then 985000
549- else if ((prediction == 91))
550- then 1094440
551- else if ((prediction == 92))
552- then 1231250
553- else if ((prediction == 93))
554- then 1407140
555- else if ((prediction == 94))
556- then 1641660
557- else if ((prediction == 95))
558- then 1970000
559- else if ((prediction == 96))
560- then 2462500
561- else if ((prediction == 97))
562- then 3283330
563- else if ((prediction == 98))
564- then 4925000
565- else if ((prediction == 99))
566- then 9850000
567- else 100000
568- else 100000
569-
570-
571-func diceWin (type,prediction,number) = if ((type == ROLLUNDER))
572- then if ((prediction >= number))
573- then true
574- else false
575- else if ((type == ROLLOVER))
576- then if ((number >= prediction))
577- then true
578- else false
579- else false
580-
581-
582-func ValidateBetAndDefineWinAmt (amount,prediction,rollType) = if (if ((BETMIN > amount))
583- then true
584- else (amount > BETMAX))
585- then throw(((("Bet amount is not in range: minBet=" + toString((BETMIN / WAVELET))) + " maxBet=") + toString((BETMAX / WAVELET))))
586- else if (if ((rollType != ROLLUNDER))
587- then (rollType != ROLLOVER)
588- else false)
589- then throw("Invalid Roll type, try with OVER or UNDER")
590- else if (if (if ((rollType == ROLLUNDER))
591- then (1 > prediction)
592- else false)
593- then true
594- else if ((rollType == ROLLUNDER))
595- then (prediction > 96)
596- else false)
597- then throw("Prediction is out of the range for ROLL UNDER: 1 <= PREDICTION <= 96")
598- else if (if (if ((rollType == ROLLOVER))
599- then (4 > prediction)
600- else false)
601- then true
602- else if ((rollType == ROLLOVER))
603- then (prediction > 99)
604- else false)
605- then throw("Prediction is out of the range for ROLL OVER: 4 <= PREDICTION <= 99")
606- else {
607- let multi = Multiplier(prediction, rollType)
608- fraction(((amount / 100000) * multi), (((100 - FEEWAVESBET) - FEEMCAFEE) - FEECOMMUNITY), 100)
609- }
610-
611-
612-@Callable(i)
613-func playDice (rollType,prediction) = {
614- let gameId = toBase58String(i.transactionId)
615- let payment = extract(i.payment)
616- let feeAssetId = isDefined(i.feeAssetId)
617- let winAmt = ValidateBetAndDefineWinAmt(payment.amount, prediction, rollType)
618- let playerBalance = wavesBalance(i.caller)
619- let gameIdUsed = isDefined(getString(this, gameId))
620- if ((payment.assetId != WBET))
621- then throw("Payment should be in Wavesbet")
622- else if ((1000000 > playerBalance))
623- then throw("There are not enough waves, it takes 0.01 Waves to bet. Game aborted.")
624- else if (feeAssetId)
625- then throw("Transaction's fee must be in Waves. Game aborted.")
626- else if (gameIdUsed)
627- then throw("Passed gameId had been used before. Game aborted.")
628- else {
629- let newGameNum = IncrementGameNum()
630- let playerPubKey58 = toBase58String(i.callerPublicKey)
631- let gameDataStr = FormatGameDataStr(STATESUBMITTED, prediction, rollType, playerPubKey58, winAmt, "")
632- ScriptResult(WriteSet([DataEntry(RESERVATIONKEY, ValidateAndIncreaseReservedAmt(winAmt)), DataEntry(GAMESCOUNTERKEY, newGameNum), DataEntry(gameId, gameDataStr)]), TransferSet([ScriptTransfer(WALLETCOMMUNITY, fraction(payment.amount, FEECOMMUNITY, 100), WBET), ScriptTransfer(WALLETWAVESBET, fraction(payment.amount, FEEWAVESBET, 100), WBET), ScriptTransfer(WALLETMCAFEE, fraction(payment.amount, FEEMCAFEE, 100), WBET)]))
633- }
634127 }
635128
636129
637130
638131 @Callable(i)
639-func withdraw (gameId,rsaSig) = {
640- let gameDataList = ExtractGameDataList(gameId)
641- let gameState = gameDataList[IdxGameState]
642- let prediction = parseIntValue(gameDataList[IdxPrediction])
643- let rollType = gameDataList[IdxType]
644- let winAmt = parseIntValue(gameDataList[IdxWinAmt])
645- let playerPubKey58 = gameDataList[IdxPlayerPubKey58]
646- let playerAddress = addressFromPublicKey(fromBase58String(playerPubKey58))
647- let decreasedReserves = DecreaseReservedAmt(gameId, winAmt)
648- if ((gameState != STATESUBMITTED))
649- then throw("Invalid game state for passed gameId. Game aborted.")
132+func unlock (asset) = {
133+ let wallet = toString(i.caller)
134+ let balance = ParsePlayerBalance(wallet)
135+ if ((asset == "WBET"))
136+ then if ((0 >= balance[WBETLOCKED]))
137+ then throw("You dont have enough balance to withdraw the amount requested.")
138+ else {
139+ let newWBETReservedAmount = (ExtractWBETReservedAmt() - balance[WBETLOCKED])
140+ ScriptResult(WriteSet([DataEntry(LOCKEDWBETKEY, newWBETReservedAmount), DataEntry(wallet, FormatPlayerBalance(0, balance[ROYALLOCKED], balance[WBETWITHDRAW], balance[ROYALWITHDRAW], balance[WAVESWITHDRAW]))]), TransferSet([ScriptTransfer(i.caller, balance[WBETLOCKED], WBET)]))
141+ }
142+ else if ((asset == "ROYAL"))
143+ then if ((0 >= balance[ROYALLOCKED]))
144+ then throw("You dont have enough balance to withdraw the amount requested.")
145+ else {
146+ let newROYALReservedAmount = (ExtractROYALReservedAmt() - balance[ROYALLOCKED])
147+ ScriptResult(WriteSet([DataEntry(LOCKEDROYALKEY, newROYALReservedAmount), DataEntry(wallet, FormatPlayerBalance(balance[WBETLOCKED], 0, balance[WBETWITHDRAW], balance[ROYALWITHDRAW], balance[WAVESWITHDRAW]))]), TransferSet([ScriptTransfer(i.caller, balance[ROYALLOCKED], ROYAL)]))
148+ }
149+ else throw("Invalid asset")
150+ }
151+
152+
153+
154+@Callable(i)
155+func withdraw (asset) = {
156+ let wallet = toString(i.caller)
157+ let balance = ParsePlayerBalance(wallet)
158+ if ((asset == "WBET"))
159+ then if ((0 >= balance[WBETWITHDRAW]))
160+ then throw("You dont have enough balance to withdraw the amount requested.")
161+ else ScriptResult(WriteSet([DataEntry(wallet, FormatPlayerBalance(balance[WBETLOCKED], balance[ROYALLOCKED], 0, balance[ROYALWITHDRAW], balance[WAVESWITHDRAW]))]), TransferSet([ScriptTransfer(i.caller, balance[WBETWITHDRAW], WBET)]))
162+ else if ((asset == "ROYAL"))
163+ then if ((0 >= balance[ROYALWITHDRAW]))
164+ then throw("You dont have enough balance to withdraw the amount requested.")
165+ else ScriptResult(WriteSet([DataEntry(wallet, FormatPlayerBalance(balance[WBETLOCKED], balance[ROYALLOCKED], balance[WBETWITHDRAW], 0, balance[WAVESWITHDRAW]))]), TransferSet([ScriptTransfer(i.caller, balance[ROYALWITHDRAW], ROYAL)]))
166+ else if ((asset == "WAVES"))
167+ then if ((0 >= balance[WAVESWITHDRAW]))
168+ then throw("You dont have enough balance to withdraw the amount requested.")
169+ else ScriptResult(WriteSet([DataEntry(wallet, FormatPlayerBalance(balance[WBETLOCKED], balance[ROYALLOCKED], balance[WBETWITHDRAW], balance[WBETWITHDRAW], 0))]), TransferSet([ScriptTransfer(i.caller, balance[WAVESWITHDRAW], unit)]))
170+ else throw("Invalid asset")
171+ }
172+
173+
174+
175+@Callable(i)
176+func addWithdraw (wallet) = if ((i.caller == COMMUNITYWALLET))
177+ then {
178+ let payment = extract(i.payment)
179+ let balance = ParsePlayerBalance(wallet)
180+ if ((payment.assetId == WBET))
181+ then {
182+ let newWbetAmount = (balance[WBETWITHDRAW] + payment.amount)
183+ ScriptResult(WriteSet([DataEntry(wallet, FormatPlayerBalance(balance[WBETLOCKED], balance[ROYALLOCKED], newWbetAmount, balance[ROYALWITHDRAW], balance[WAVESWITHDRAW]))]), TransferSet(nil))
184+ }
185+ else if ((payment.assetId == ROYAL))
186+ then {
187+ let newRoyalAmount = (balance[ROYALWITHDRAW] + payment.amount)
188+ ScriptResult(WriteSet([DataEntry(wallet, FormatPlayerBalance(balance[WBETLOCKED], balance[ROYALLOCKED], balance[WBETWITHDRAW], newRoyalAmount, balance[WAVESWITHDRAW]))]), TransferSet(nil))
189+ }
190+ else if ((payment.assetId == unit))
191+ then {
192+ let newWavesAmount = (balance[WAVESWITHDRAW] + payment.amount)
193+ ScriptResult(WriteSet([DataEntry(wallet, FormatPlayerBalance(balance[WBETLOCKED], balance[ROYALLOCKED], balance[WBETWITHDRAW], balance[ROYALWITHDRAW], newWavesAmount))]), TransferSet(nil))
194+ }
195+ else throw("Invalid asset")
196+ }
197+ else throw("You do not have permission to perform this function.")
198+
199+
200+
201+@Callable(i)
202+func addCommunityFee () = {
203+ let payment = extract(i.payment)
204+ if ((payment.assetId != assetInfo(base58'WAVES')))
205+ then throw("Payment should be in WAVES.")
650206 else {
651- let rand = GenerateRandInt(gameId, rsaSig)
652- let randStr = RandToStr(rand)
653- if (diceWin(rollType, prediction, rand))
654- then {
655- let newGameDataStr = FormatGameDataStr(STATEWON, prediction, rollType, playerPubKey58, winAmt, randStr)
656- WinScriptSet(gameId, playerAddress, winAmt, newGameDataStr, decreasedReserves)
657- }
658- else {
659- let newGameDataStr = FormatGameDataStr(STATELOST, prediction, rollType, playerPubKey58, winAmt, randStr)
660- WriteSet([DataEntry(gameId, newGameDataStr), decreasedReserves])
661- }
207+ let newFEEReservedAmount = (ExtractFEEReservedAmt() + payment.amount)
208+ ScriptResult(WriteSet([DataEntry(COMMUNITYFEEKEY, newFEEReservedAmount)]), TransferSet(nil))
662209 }
663210 }
664211
665212
666-@Verifier(tx)
667-func verify () = if (sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey))
668- then match tx {
669- case ttx: TransferTransaction =>
670- ((assetBalance(this, WBET) - ttx.amount) >= ExtractReservedAmt())
671- case stx: SetScriptTransaction =>
672- true
673- case _ =>
674- false
675- }
676- else false
213+
214+@Callable(i)
215+func getCommunityFee (amount) = if ((i.caller == COMMUNITYWALLET))
216+ then {
217+ let payment = extract(i.payment)
218+ let FEEReservedAmount = ExtractFEEReservedAmt()
219+ if ((amount > FEEReservedAmount))
220+ then throw("You dont have enough balance to transfer the amount requested.")
221+ else {
222+ let newFEEReservedAmount = (FEEReservedAmount - amount)
223+ ScriptResult(WriteSet([DataEntry(COMMUNITYFEEKEY, newFEEReservedAmount)]), TransferSet([ScriptTransfer(COMMUNITYWALLET, amount, unit)]))
224+ }
225+ }
226+ else throw("You do not have permission to perform this function.")
227+
677228

github/deemru/w8io/026f985 
88.32 ms