tx · 5SL6sDSaHkwyy4XR2U9bqF38LhCmZeVLTdyJivHc5UDc

3N3UmzKXACreLX3MxuUSf1zKdxC6GjE8wHD:  -0.01400000 Waves

2021.05.11 16:43 [1521090] smart account 3N3UmzKXACreLX3MxuUSf1zKdxC6GjE8wHD > SELF 0.00000000 Waves

{ "type": 13, "id": "5SL6sDSaHkwyy4XR2U9bqF38LhCmZeVLTdyJivHc5UDc", "fee": 1400000, "feeAssetId": null, "timestamp": 1620740641655, "version": 1, "sender": "3N3UmzKXACreLX3MxuUSf1zKdxC6GjE8wHD", "senderPublicKey": "Co7gTLr7ZJvVKwToLpuZJqmkVecy5uwupYH6qCkKuhc8", "proofs": [ "5frWK2ReAhNJU5xrGsejNgwksrJeo9LXBPEwVSTsaycwSARwR6K1LsiTBAYLScv6iQzYApgxAWHgVBfMsh5eZxqN" ], "script": "base64:AwQAAAAHJG1hdGNoMAUAAAACdHgGB2nb5Q==", "chainId": 84, "height": 1521090, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: J2ika7oekDoT5BiA9iZf2hhs7oeSgt8X9hxGDNacJvgR Next: 68JisrpZAas3C2JfFDF1QcVKS6TktEGG6TCaZYZtwqaZ Full:
OldNewDifferences
11 {-# STDLIB_VERSION 3 #-}
2-{-# SCRIPT_TYPE ACCOUNT #-}
3-{-# CONTENT_TYPE DAPP #-}
4-let lotteryamount = "_amount"
5-
6-let lotteryprobability = "_probability"
7-
8-let lotteryprobabilitydecimal = "_probability_decimal"
9-
10-let lotteryPrice = "_price"
11-
12-let lotteryPrices = "_lottery_prices"
13-
14-let lotteryAssetId = "_lottery_asset_id"
15-
16-let countOfPrices = "_count_prices"
17-
18-let lastHashRandomNumber = "last_spin_random_hash"
19-
20-let lastTokenRandomHash = "last_token_random_hash"
21-
22-let dAppAddres = "3BKFQLeo5ExZ5Y1pt9Ftzsno7aRwzD96zoYVHP3tcLgV"
23-
24-let allowSizeLottery = 14
25-
26-func randomizer (inv) = {
27- let lastPlay = match getBinary(this, lastHashRandomNumber) {
28- case s: ByteVector =>
29- s
30- case _: Unit =>
31- base58'2ee4oFDYriWJ9EMeR'
32- case _ =>
33- throw("Match error")
34- }
35- let rand = (((((lastPlay + inv.transactionId) + inv.callerPublicKey) + lastBlock.generationSignature) + toBytes(lastBlock.timestamp)) + toBytes(lastBlock.height))
36- sha256(rand)
37- }
38-
39-
40-func generatorRandomHash (inv) = {
41- let lastHashForToken = match getBinary(this, lastTokenRandomHash) {
42- case s: ByteVector =>
43- s
44- case _: Unit =>
45- base58'4dD7osCQzvuXJdTiGfKvTwnKT'
46- case _ =>
47- throw("Match error")
48- }
49- let rand = (((((lastHashForToken + inv.transactionId) + inv.callerPublicKey) + lastBlock.generationSignature) + toBytes(lastBlock.timestamp)) + toBytes(lastBlock.height))
50- sha256(rand)
51- }
52-
53-
54-func getPriceArray () = {
55- let tempPrices = getStringValue(this, lotteryPrices)
56- let trimPrices = take(tempPrices, (size(tempPrices) - 1))
57- let newArray = split(trimPrices, ",")
58- newArray
59- }
60-
61-
62-func generateNewListOfPrices (token,val) = {
63- let indexOfComma = indexOf(token, ",")
64- if ((indexOfComma == unit))
65- then (val + ",")
66- else ((token + val) + ",")
67- }
68-
69-
70-func procedLottery (win,token) = {
71- let tokenProbability = getIntegerValue(this, (token + lotteryprobability))
72- let tokenProbabilityDecimal = getIntegerValue(this, (token + lotteryprobabilitydecimal))
73- let probabilityValue = (tokenProbabilityDecimal * 1000)
74- let hash = (tokenProbabilityDecimal % probabilityValue)
75- let sizeOfWin = size(win)
76- if ((sizeOfWin == 1))
77- then {
78- let randomNumber = win[0]
79- if ((probabilityValue > hash))
80- then {
81- let newList = token :: win
82- newList
83- }
84- else win
85- }
86- else win
87- }
88-
89-
90-@Callable(i)
91-func updateprobability (probability,amount,poolprice,probDecimal,assetId) = {
92- let token = toBase64String(generatorRandomHash(i))
93- let paymentIsDefined = if (!(isDefined(i.payment)))
94- then false
95- else true
96- let lotteryAssetTN = if ((assetId == ""))
97- then true
98- else false
99- let totalRequiredAmount = (amount * poolprice)
100- if ((paymentIsDefined == true))
101- then {
102- let payment = extract(i.payment)
103- let paymentAssetId = match payment.assetId {
104- case a: ByteVector =>
105- toBase64String(a)
106- case _: Unit =>
107- ""
108- case _ =>
109- throw("Match error")
110- }
111- let paymentAmount = payment.amount
112- if ((paymentAssetId != assetId))
113- then throw("Asset Id not matching with Payment Asset Id")
114- else if ((totalRequiredAmount > paymentAmount))
115- then throw("Not enough Asset Amount")
116- else {
117- let tempValue = match getString(this, lotteryPrices) {
118- case a: String =>
119- a
120- case _: Unit =>
121- ""
122- case _ =>
123- throw("Match error")
124- }
125- let containKey = indexOf(tempValue, token)
126- let storedTokensValues = match containKey {
127- case _: Unit =>
128- ((tempValue + token) + ",")
129- case x: Int =>
130- throw("Token is duplicated")
131- case _ =>
132- throw("Match error")
133- }
134- let countTokens = match getInteger(this, countOfPrices) {
135- case a: Int =>
136- a
137- case _: Unit =>
138- 0
139- case _ =>
140- throw("Match error")
141- }
142- if ((allowSizeLottery >= countTokens))
143- then {
144- let updateLotteryPool = WriteSet([DataEntry((token + lotteryamount), amount), DataEntry((token + lotteryprobability), probability), DataEntry((token + lotteryPrice), poolprice), DataEntry(lotteryPrices, storedTokensValues), DataEntry(countOfPrices, (countTokens + 1)), DataEntry((token + lotteryprobabilitydecimal), probDecimal), DataEntry((token + lotteryAssetId), assetId), DataEntry(lastTokenRandomHash, token)])
145- ScriptResult(updateLotteryPool, TransferSet(nil))
146- }
147- else throw(("Lottery prices has reached maximum " + toString(allowSizeLottery)))
148- }
149- }
150- else {
151- let tnBalance = if (lotteryAssetTN)
152- then wavesBalance(this)
153- else assetBalance(this, fromBase64String(assetId))
154- if ((totalRequiredAmount > tnBalance))
155- then throw("Not enough Asset Amount")
156- else {
157- let tempValue = match getString(this, lotteryPrices) {
158- case a: String =>
159- a
160- case _: Unit =>
161- ""
162- case _ =>
163- throw("Match error")
164- }
165- let containKey = indexOf(tempValue, token)
166- let storedTokensValues = match containKey {
167- case _: Unit =>
168- ((tempValue + token) + ",")
169- case x: Int =>
170- throw("Token is duplicated")
171- case _ =>
172- throw("Match error")
173- }
174- let countTokens = match getInteger(this, countOfPrices) {
175- case a: Int =>
176- a
177- case _: Unit =>
178- 0
179- case _ =>
180- throw("Match error")
181- }
182- if ((allowSizeLottery >= countTokens))
183- then {
184- let updateLotteryPool = WriteSet([DataEntry((token + lotteryamount), amount), DataEntry((token + lotteryprobability), probability), DataEntry((token + lotteryPrice), poolprice), DataEntry(lotteryPrices, storedTokensValues), DataEntry(countOfPrices, (countTokens + 1)), DataEntry((token + lotteryprobabilitydecimal), probDecimal), DataEntry((token + lotteryAssetId), assetId), DataEntry(lastTokenRandomHash, token)])
185- ScriptResult(updateLotteryPool, TransferSet(nil))
186- }
187- else throw("Lottery prices has reached maximum 15")
188- }
189- }
190- }
191-
192-
193-
194-@Callable(i)
195-func startlotto () = {
196- let currentKey = toBase58String(i.caller.bytes)
197- let randhash = randomizer(i)
198- let countTokens = match getInteger(this, countOfPrices) {
199- case a: Int =>
200- a
201- case _: Unit =>
202- 0
203- case _ =>
204- throw("Match error")
205- }
206- let priceList = getPriceArray()
207- let randNumber = toInt(randhash)
208- let winningToken = {
209- let $list72517289 = priceList
210- let $size72517289 = size($list72517289)
211- let $acc072517289 = nil
212- if (($size72517289 == 0))
213- then $acc072517289
214- else {
215- let $acc172517289 = procedLottery($acc072517289, $list72517289[0])
216- if (($size72517289 == 1))
217- then $acc172517289
218- else {
219- let $acc272517289 = procedLottery($acc172517289, $list72517289[1])
220- if (($size72517289 == 2))
221- then $acc272517289
222- else {
223- let $acc372517289 = procedLottery($acc272517289, $list72517289[2])
224- if (($size72517289 == 3))
225- then $acc372517289
226- else {
227- let $acc472517289 = procedLottery($acc372517289, $list72517289[3])
228- if (($size72517289 == 4))
229- then $acc472517289
230- else {
231- let $acc572517289 = procedLottery($acc472517289, $list72517289[4])
232- if (($size72517289 == 5))
233- then $acc572517289
234- else {
235- let $acc672517289 = procedLottery($acc572517289, $list72517289[5])
236- if (($size72517289 == 6))
237- then $acc672517289
238- else {
239- let $acc772517289 = procedLottery($acc672517289, $list72517289[6])
240- if (($size72517289 == 7))
241- then $acc772517289
242- else {
243- let $acc872517289 = procedLottery($acc772517289, $list72517289[7])
244- if (($size72517289 == 8))
245- then $acc872517289
246- else {
247- let $acc972517289 = procedLottery($acc872517289, $list72517289[8])
248- if (($size72517289 == 9))
249- then $acc972517289
250- else {
251- let $acc1072517289 = procedLottery($acc972517289, $list72517289[9])
252- if (($size72517289 == 10))
253- then $acc1072517289
254- else {
255- let $acc1172517289 = procedLottery($acc1072517289, $list72517289[10])
256- if (($size72517289 == 11))
257- then $acc1172517289
258- else {
259- let $acc1272517289 = procedLottery($acc1172517289, $list72517289[11])
260- if (($size72517289 == 12))
261- then $acc1272517289
262- else {
263- let $acc1372517289 = procedLottery($acc1272517289, $list72517289[12])
264- if (($size72517289 == 13))
265- then $acc1372517289
266- else {
267- let $acc1472517289 = procedLottery($acc1372517289, $list72517289[13])
268- if (($size72517289 == 14))
269- then $acc1472517289
270- else {
271- let $acc1572517289 = procedLottery($acc1472517289, $list72517289[14])
272- throw("List size exceed 14")
273- }
274- }
275- }
276- }
277- }
278- }
279- }
280- }
281- }
282- }
283- }
284- }
285- }
286- }
287- }
288- }
289- let sizeOfWinPrices = size(winningToken)
290- if ((sizeOfWinPrices == 0))
291- then {
292- let writeSets = WriteSet(nil)
293- ScriptResult(writeSets, TransferSet(nil))
294- }
295- else {
296- let token = winningToken[1]
297- let currentAmount = getIntegerValue(this, (token + lotteryamount))
298- if ((currentAmount == 0))
299- then throw("Amount exceeded")
300- else {
301- let actualAmount = (currentAmount - 1)
302- let tokenPrice = getIntegerValue(this, (token + lotteryPrice))
303- let tokenAssetId = getStringValue(this, (token + lotteryAssetId))
304- if ((actualAmount == 0))
305- then {
306- let storedTokensValues = {
307- let $list81248175 = priceList
308- let $size81248175 = size($list81248175)
309- let $acc081248175 = token
310- if (($size81248175 == 0))
311- then $acc081248175
312- else {
313- let $acc181248175 = generateNewListOfPrices($acc081248175, $list81248175[0])
314- if (($size81248175 == 1))
315- then $acc181248175
316- else {
317- let $acc281248175 = generateNewListOfPrices($acc181248175, $list81248175[1])
318- if (($size81248175 == 2))
319- then $acc281248175
320- else {
321- let $acc381248175 = generateNewListOfPrices($acc281248175, $list81248175[2])
322- if (($size81248175 == 3))
323- then $acc381248175
324- else {
325- let $acc481248175 = generateNewListOfPrices($acc381248175, $list81248175[3])
326- if (($size81248175 == 4))
327- then $acc481248175
328- else {
329- let $acc581248175 = generateNewListOfPrices($acc481248175, $list81248175[4])
330- if (($size81248175 == 5))
331- then $acc581248175
332- else {
333- let $acc681248175 = generateNewListOfPrices($acc581248175, $list81248175[5])
334- if (($size81248175 == 6))
335- then $acc681248175
336- else {
337- let $acc781248175 = generateNewListOfPrices($acc681248175, $list81248175[6])
338- if (($size81248175 == 7))
339- then $acc781248175
340- else {
341- let $acc881248175 = generateNewListOfPrices($acc781248175, $list81248175[7])
342- if (($size81248175 == 8))
343- then $acc881248175
344- else {
345- let $acc981248175 = generateNewListOfPrices($acc881248175, $list81248175[8])
346- if (($size81248175 == 9))
347- then $acc981248175
348- else {
349- let $acc1081248175 = generateNewListOfPrices($acc981248175, $list81248175[9])
350- if (($size81248175 == 10))
351- then $acc1081248175
352- else {
353- let $acc1181248175 = generateNewListOfPrices($acc1081248175, $list81248175[10])
354- if (($size81248175 == 11))
355- then $acc1181248175
356- else {
357- let $acc1281248175 = generateNewListOfPrices($acc1181248175, $list81248175[11])
358- if (($size81248175 == 12))
359- then $acc1281248175
360- else {
361- let $acc1381248175 = generateNewListOfPrices($acc1281248175, $list81248175[12])
362- if (($size81248175 == 13))
363- then $acc1381248175
364- else {
365- let $acc1481248175 = generateNewListOfPrices($acc1381248175, $list81248175[13])
366- if (($size81248175 == 14))
367- then $acc1481248175
368- else {
369- let $acc1581248175 = generateNewListOfPrices($acc1481248175, $list81248175[14])
370- throw("List size exceed 14")
371- }
372- }
373- }
374- }
375- }
376- }
377- }
378- }
379- }
380- }
381- }
382- }
383- }
384- }
385- }
386- }
387- let writeSets = WriteSet([DataEntry(("winning_token_" + token), token), DataEntry((currentKey + "_wininning_address_"), currentKey), DataEntry(countOfPrices, (countTokens - 1)), DataEntry(lotteryPrices, storedTokensValues), DataEntry(lastHashRandomNumber, randNumber)])
388- if ((tokenAssetId == ""))
389- then {
390- let winTransfer = TransferSet([ScriptTransfer(i.caller, tokenPrice, unit)])
391- ScriptResult(writeSets, winTransfer)
392- }
393- else {
394- let winTransfer = TransferSet([ScriptTransfer(i.caller, tokenPrice, unit)])
395- ScriptResult(writeSets, winTransfer)
396- }
397- }
398- else {
399- let writeSets = WriteSet([DataEntry((currentKey + "_winning_token_"), token), DataEntry((currentKey + "_wininning_address_"), currentKey), DataEntry((token + lotteryamount), actualAmount), DataEntry(lastHashRandomNumber, randNumber)])
400- if ((tokenAssetId == ""))
401- then {
402- let winTransfer = TransferSet([ScriptTransfer(i.caller, tokenPrice, unit)])
403- ScriptResult(writeSets, winTransfer)
404- }
405- else {
406- let winTransfer = TransferSet([ScriptTransfer(i.caller, tokenPrice, unit)])
407- ScriptResult(writeSets, winTransfer)
408- }
409- }
410- }
411- }
412- }
413-
414-
415-@Verifier(tx)
416-func verify () = match tx {
417- case _: DataTransaction =>
2+{-# CONTENT_TYPE EXPRESSION #-}
3+match tx {
4+ case _ =>
4185 true
419- case _: SetScriptTransaction =>
420- true
421- case _ =>
422- sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
4236 }
424-

github/deemru/w8io/873ac7e 
42.22 ms