tx · 7KwMYieXCfJz5Cfdc9yHZuyeBYeoGa1FdBhbwykgYYja 3Mt71RiSbWYENDmeyndvwjoJZwUsXfUkR6b: -0.01400000 Waves 2021.02.06 08:08 [1385884] smart account 3Mt71RiSbWYENDmeyndvwjoJZwUsXfUkR6b > SELF 0.00000000 Waves
{ "type": 13, "id": "7KwMYieXCfJz5Cfdc9yHZuyeBYeoGa1FdBhbwykgYYja", "fee": 1400000, "feeAssetId": null, "timestamp": 1612588166993, "version": 2, "chainId": 84, "sender": "3Mt71RiSbWYENDmeyndvwjoJZwUsXfUkR6b", "senderPublicKey": "3BKFQLeo5ExZ5Y1pt9Ftzsno7aRwzD96zoYVHP3tcLgV", "proofs": [ "4RWkJscfACUCho3xWoagjjGZ5F7uKLg2hJYarqMKEeE657Kdn6bVfV2x6RHtQ6FceQxb3LEbqMS9Rbammbp9Amok" ], "script": "base64:AAIDAAAAAAAAABAIARIGCgQBAQEIEgQKAggIAAAACAAAAAARbG90dGVyeXBvb2xhbW91bnQCAAAAEF9sb3R0ZXJ5X2Ftb3VudF8AAAAAFmxvdHRlcnlwb29scHJvYmFiaWxpdHkCAAAADl9sb3R0ZXJ5X3Byb2JfAAAAABBsb3R0ZXJ5cG9vbHByaWNlAgAAAA9fbG90dGVyeV9wcmljZV8AAAAADWxvdHRlcnlwcmljZXMCAAAAEF9sb3R0ZXJ5X3ByaWNlc18BAAAACnJhbmRvbWl6ZXIAAAABAAAAA2ludgQAAAAEcmFuZAkAAMsAAAACCQAAywAAAAIJAADLAAAAAgkAAMsAAAACCAUAAAADaW52AAAADXRyYW5zYWN0aW9uSWQIBQAAAANpbnYAAAAPY2FsbGVyUHVibGljS2V5CAUAAAAJbGFzdEJsb2NrAAAAE2dlbmVyYXRpb25TaWduYXR1cmUJAAGaAAAAAQgFAAAACWxhc3RCbG9jawAAAAl0aW1lc3RhbXAJAAGaAAAAAQgFAAAACWxhc3RCbG9jawAAAAZoZWlnaHQJAAH3AAAAAQUAAAAEcmFuZAEA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jdGlvbgYDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAFFNldFNjcmlwdFRyYW5zYWN0aW9uBgkAAfQAAAADCAUAAAACdHgAAAAJYm9keUJ5dGVzCQABkQAAAAIIBQAAAAJ0eAAAAAZwcm9vZnMAAAAAAAAAAAAIBQAAAAJ0eAAAAA9zZW5kZXJQdWJsaWNLZXk6/8Z3", "height": 1385884, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: B5HQmwtHVX5PYvf3D3RN1aD5WGZTR5RsR3foTJuxUFcs Next: GvkixvU9maLvDjUvANN7espCw77GTvekh3Ftg56MpogZ Diff:
Old | New | Differences | |
---|---|---|---|
16 | 16 | ||
17 | 17 | ||
18 | 18 | func getSizePriceArray () = { | |
19 | - | let tempPrices = extract(getString(this, lotteryprices)) | |
20 | - | let isTempPricesDefined = isDefined(tempPrices) | |
19 | + | let tempPrices = getStringValue(this, lotteryprices) | |
21 | 20 | let trimPrices = take(tempPrices, (size(tempPrices) - 1)) | |
22 | 21 | let pricesArray = split(trimPrices, ",") | |
23 | 22 | size(pricesArray) | |
25 | 24 | ||
26 | 25 | ||
27 | 26 | func getPriceArray () = { | |
28 | - | let tempPrices = extract(getString(this, lotteryprices)) | |
29 | - | let isTempPricesDefined = isDefined(tempPrices) | |
27 | + | let tempPrices = getStringValue(this, lotteryprices) | |
30 | 28 | let trimPrices = take(tempPrices, (size(tempPrices) - 1)) | |
31 | 29 | split(trimPrices, ",") | |
32 | 30 | } |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let lotterypoolamount = "_lottery_amount_" | |
5 | 5 | ||
6 | 6 | let lotterypoolprobability = "_lottery_prob_" | |
7 | 7 | ||
8 | 8 | let lotterypoolprice = "_lottery_price_" | |
9 | 9 | ||
10 | 10 | let lotteryprices = "_lottery_prices_" | |
11 | 11 | ||
12 | 12 | func randomizer (inv) = { | |
13 | 13 | let rand = ((((inv.transactionId + inv.callerPublicKey) + lastBlock.generationSignature) + toBytes(lastBlock.timestamp)) + toBytes(lastBlock.height)) | |
14 | 14 | sha256(rand) | |
15 | 15 | } | |
16 | 16 | ||
17 | 17 | ||
18 | 18 | func getSizePriceArray () = { | |
19 | - | let tempPrices = extract(getString(this, lotteryprices)) | |
20 | - | let isTempPricesDefined = isDefined(tempPrices) | |
19 | + | let tempPrices = getStringValue(this, lotteryprices) | |
21 | 20 | let trimPrices = take(tempPrices, (size(tempPrices) - 1)) | |
22 | 21 | let pricesArray = split(trimPrices, ",") | |
23 | 22 | size(pricesArray) | |
24 | 23 | } | |
25 | 24 | ||
26 | 25 | ||
27 | 26 | func getPriceArray () = { | |
28 | - | let tempPrices = extract(getString(this, lotteryprices)) | |
29 | - | let isTempPricesDefined = isDefined(tempPrices) | |
27 | + | let tempPrices = getStringValue(this, lotteryprices) | |
30 | 28 | let trimPrices = take(tempPrices, (size(tempPrices) - 1)) | |
31 | 29 | split(trimPrices, ",") | |
32 | 30 | } | |
33 | 31 | ||
34 | 32 | ||
35 | 33 | func updateAmountClaimForToken (token) = { | |
36 | 34 | let currentAmount = getIntegerValue(this, (lotterypoolamount + token)) | |
37 | 35 | if ((currentAmount == 0)) | |
38 | 36 | then throw("Amount exceeded") | |
39 | 37 | else { | |
40 | 38 | let returnValue = (currentAmount - 1) | |
41 | 39 | returnValue | |
42 | 40 | } | |
43 | 41 | } | |
44 | 42 | ||
45 | 43 | ||
46 | 44 | @Callable(i) | |
47 | 45 | func updateprobability (probability,amount,poolprice,token) = { | |
48 | 46 | let tempValue = match getString(this, lotteryprices) { | |
49 | 47 | case a: String => | |
50 | 48 | a | |
51 | 49 | case _ => | |
52 | 50 | "" | |
53 | 51 | } | |
54 | 52 | let containKey = indexOf(tempValue, token) | |
55 | 53 | let finalValue = match containKey { | |
56 | 54 | case _: Unit => | |
57 | 55 | ((tempValue + token) + ",") | |
58 | 56 | case x: Int => | |
59 | 57 | tempValue | |
60 | 58 | case _ => | |
61 | 59 | throw("Match error") | |
62 | 60 | } | |
63 | 61 | let updateLotteryPool = WriteSet([DataEntry((lotterypoolamount + token), amount), DataEntry((lotterypoolprobability + token), probability), DataEntry((lotterypoolprice + token), poolprice), DataEntry(lotteryprices, finalValue)]) | |
64 | 62 | ScriptResult(updateLotteryPool, TransferSet(nil)) | |
65 | 63 | } | |
66 | 64 | ||
67 | 65 | ||
68 | 66 | ||
69 | 67 | @Callable(i) | |
70 | 68 | func startlotto (token,walletAddress) = { | |
71 | 69 | let currentKey = toBase58String(i.caller.bytes) | |
72 | 70 | let recipientaddress = addressFromStringValue(walletAddress) | |
73 | 71 | let storedToken = getIntegerValue(this, (lotterypoolamount + token)) | |
74 | 72 | let prob = getIntegerValue(this, (lotterypoolprobability + token)) | |
75 | 73 | let price = getIntegerValue(this, (lotterypoolprice + token)) | |
76 | 74 | let randhash = randomizer(i) | |
77 | 75 | let sizeTempPrice = getSizePriceArray() | |
78 | 76 | let priceList = getPriceArray() | |
79 | 77 | let datSizePriceEntry = DataEntry((currentKey + "_winprices_size_"), sizeTempPrice) | |
80 | 78 | if ((prob > (toInt(randhash) % 1000))) | |
81 | 79 | then { | |
82 | 80 | let winTransfer = TransferSet([ScriptTransfer(recipientaddress, price, unit)]) | |
83 | 81 | let newAmount = updateAmountClaimForToken(token) | |
84 | 82 | let writeSets = WriteSet([DataEntry((currentKey + "_winning_ticket_"), price), DataEntry((currentKey + "_wininning_address_"), walletAddress), DataEntry((lotterypoolamount + token), newAmount), datSizePriceEntry]) | |
85 | 83 | ScriptResult(writeSets, winTransfer) | |
86 | 84 | } | |
87 | 85 | else { | |
88 | 86 | let writeSets = WriteSet([DataEntry((currentKey + "_winning_ticket_"), ""), DataEntry((currentKey + "_wininning_address_"), ""), datSizePriceEntry]) | |
89 | 87 | ScriptResult(writeSets, TransferSet(nil)) | |
90 | 88 | } | |
91 | 89 | } | |
92 | 90 | ||
93 | 91 | ||
94 | 92 | @Verifier(tx) | |
95 | 93 | func verify () = match tx { | |
96 | 94 | case _: DataTransaction => | |
97 | 95 | true | |
98 | 96 | case _: SetScriptTransaction => | |
99 | 97 | true | |
100 | 98 | case _ => | |
101 | 99 | sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
102 | 100 | } | |
103 | 101 |
github/deemru/w8io/169f3d6 52.51 ms ◑