tx · EXwfCmDCSS8GdKqYnZMvj68XHg6PsBkhYncEVpgnZyLq 3N4Kzbxu521DHPxcgrmZ4XUqN2kF6TqLTzs: -0.01000000 Waves 2023.08.29 09:20 [2731612] smart account 3N4Kzbxu521DHPxcgrmZ4XUqN2kF6TqLTzs > SELF 0.00000000 Waves
{ "type": 13, "id": "EXwfCmDCSS8GdKqYnZMvj68XHg6PsBkhYncEVpgnZyLq", "fee": 1000000, "feeAssetId": null, "timestamp": 1693290039799, "version": 2, "chainId": 84, "sender": "3N4Kzbxu521DHPxcgrmZ4XUqN2kF6TqLTzs", "senderPublicKey": "8yQuxvQ2qLzXJrgbKZHbsfnNNjuU5wfHheyVujdALGsF", "proofs": [ "5r9oPfmWeKFmvoCPLTscnQtwothADwp729WnbZxHd7JDtFZ4gsMArFZWqbDcyTK4V5KEQGB5gDeQ6QEhRmvk72Ty" ], "script": "base64:BgIOCAISABIAEgQKAggBEgAKAA5sb3R0ZXJ5QXNzZXRJRAkA2QQBAiwzTHoyM21TVXZUMUVzd2NCbjJzVVJZSkcyYXQ4ckc1YUZ1VXJUQXdhUE02UQAKdGlja2V0U2l6ZQCAwtcvARBnZXRJbnRlZ2VyT3JFbHNlAgNrZXkDdmFsCQELdmFsdWVPckVsc2UCCQCfCAEFA2tleQUDdmFsAQJtawEBeAkAuQkCBQF4AgFfARFrZXlBZHJUb3RhbFN0YWtlZAEDYWRyCQECbWsBCQDMCAIFA2FkcgkAzAgCAgt0b3RhbFN0YWtlZAUDbmlsARVrZXlMb3R0ZXJ5VG90YWxTdGFrZWQBC2xvdHRlcnlOYW1lCQECbWsBCQDMCAICB2xvdHRlcnkJAMwIAgULbG90dGVyeU5hbWUJAMwIAgILdG90YWxTdGFrZWQFA25pbAEYa2V5QWRyTG90dGVyeVRvdGFsU3Rha2VkAgtsb3R0ZXJ5TmFtZQNhZHIJAQJtawEJAMwIAgIHbG90dGVyeQkAzAgCBQtsb3R0ZXJ5TmFtZQkAzAgCBQNhZHIJAMwIAg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0cgIACQDMCAIJAQtEZWxldGVFbnRyeQECA3N0cgkAzAgCBQVhc3NldAkAzAgCCQEHUmVpc3N1ZQMFB2Fzc2V0SWQAAQcJAMwIAgkBBEJ1cm4CBQdhc3NldElkAAEJAMwIAgkBDlNjcmlwdFRyYW5zZmVyAwgFAWkGY2FsbGVyAAEFB2Fzc2V0SWQFA25pbAECdHgBBnZlcmlmeQAJAPQDAwgFAnR4CWJvZHlCeXRlcwkAkQMCCAUCdHgGcHJvb2ZzAAAIBQJ0eA9zZW5kZXJQdWJsaWNLZXnWjzX/", "height": 2731612, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: De8zaPU6kVgNjuUpsSHUisXF4FAAE9W5p2bsxN3Wj1g3 Next: FxpiGXxEC6kAsBUbBeZCsWk35CeNb8ehbVbCBNrCDTDy Diff:
Old | New | Differences | |
---|---|---|---|
14 | 14 | func keyAdrTotalStaked (adr) = mk([adr, "totalStaked"]) | |
15 | 15 | ||
16 | 16 | ||
17 | - | func keyLotteryTotalStaked (lotteryName) = mk(["lottery", lotteryName, " | |
17 | + | func keyLotteryTotalStaked (lotteryName) = mk(["lottery", lotteryName, "totalStaked"]) | |
18 | 18 | ||
19 | 19 | ||
20 | 20 | func keyAdrLotteryTotalStaked (lotteryName,adr) = mk(["lottery", lotteryName, adr, "totalStaked"]) | |
21 | 21 | ||
22 | 22 | ||
23 | - | func keyLotteryFinalHeight (lotteryName) = mk(["lottery", lotteryName, " | |
23 | + | func keyLotteryFinalHeight (lotteryName) = mk(["lottery", lotteryName, "finalHeight"]) | |
24 | 24 | ||
25 | 25 | ||
26 | 26 | func getLotteryName () = getStringValue("currentLotteryName") | |
57 | 57 | let callerAddress = toString(i.caller) | |
58 | 58 | let _lotteryTotalStaked = keyLotteryTotalStaked(lotteryName) | |
59 | 59 | let lotteryTotalStaked = getIntegerValue(_lotteryTotalStaked) | |
60 | - | let _owner = mk([lotteryName, toString(lotteryTotalStaked), toString(((lotteryTotalStaked + ticketAmount) - 1)) | |
60 | + | let _owner = mk(["owner", lotteryName, toString(lotteryTotalStaked), toString(((lotteryTotalStaked + ticketAmount) - 1))]) | |
61 | 61 | let _adrTotalStaked = keyAdrTotalStaked(callerAddress) | |
62 | 62 | let adrTotalStaked = getIntegerOrElse(_adrTotalStaked, 0) | |
63 | 63 | let _adrLotteryTotalStaked = keyAdrLotteryTotalStaked(lotteryName, callerAddress) |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let lotteryAssetID = fromBase58String("3Lz23mSUvT1EswcBn2sURYJG2at8rG5aFuUrTAwaPM6Q") | |
5 | 5 | ||
6 | 6 | let ticketSize = 100000000 | |
7 | 7 | ||
8 | 8 | func getIntegerOrElse (key,val) = valueOrElse(getInteger(key), val) | |
9 | 9 | ||
10 | 10 | ||
11 | 11 | func mk (x) = makeString(x, "_") | |
12 | 12 | ||
13 | 13 | ||
14 | 14 | func keyAdrTotalStaked (adr) = mk([adr, "totalStaked"]) | |
15 | 15 | ||
16 | 16 | ||
17 | - | func keyLotteryTotalStaked (lotteryName) = mk(["lottery", lotteryName, " | |
17 | + | func keyLotteryTotalStaked (lotteryName) = mk(["lottery", lotteryName, "totalStaked"]) | |
18 | 18 | ||
19 | 19 | ||
20 | 20 | func keyAdrLotteryTotalStaked (lotteryName,adr) = mk(["lottery", lotteryName, adr, "totalStaked"]) | |
21 | 21 | ||
22 | 22 | ||
23 | - | func keyLotteryFinalHeight (lotteryName) = mk(["lottery", lotteryName, " | |
23 | + | func keyLotteryFinalHeight (lotteryName) = mk(["lottery", lotteryName, "finalHeight"]) | |
24 | 24 | ||
25 | 25 | ||
26 | 26 | func getLotteryName () = getStringValue("currentLotteryName") | |
27 | 27 | ||
28 | 28 | ||
29 | 29 | func activeLotteryName () = if ((valueOrElse(getBoolean("lotteryIsStarted"), false) != true)) | |
30 | 30 | then "" | |
31 | 31 | else { | |
32 | 32 | let lotteryName = getLotteryName() | |
33 | 33 | let lotteryFinalHeight = getIntegerValue(keyLotteryFinalHeight(lotteryName)) | |
34 | 34 | if (((height - 1) >= lotteryFinalHeight)) | |
35 | 35 | then "" | |
36 | 36 | else lotteryName | |
37 | 37 | } | |
38 | 38 | ||
39 | 39 | ||
40 | 40 | @Callable(i) | |
41 | 41 | func stake () = { | |
42 | 42 | let lotteryName = activeLotteryName() | |
43 | 43 | if ((lotteryName == "")) | |
44 | 44 | then throw("Lottery not active") | |
45 | 45 | else if ((size(i.payments) == 0)) | |
46 | 46 | then throw("No payment added") | |
47 | 47 | else if ((size(i.payments) != 1)) | |
48 | 48 | then throw("Too many payments added") | |
49 | 49 | else if ((i.payments[0].assetId != lotteryAssetID)) | |
50 | 50 | then throw("Wrong payment assetId") | |
51 | 51 | else { | |
52 | 52 | let amount = i.payments[0].amount | |
53 | 53 | let ticketAmount = (amount / ticketSize) | |
54 | 54 | if ((ticketAmount == 0)) | |
55 | 55 | then throw("Not enough to buy at least one ticket") | |
56 | 56 | else { | |
57 | 57 | let callerAddress = toString(i.caller) | |
58 | 58 | let _lotteryTotalStaked = keyLotteryTotalStaked(lotteryName) | |
59 | 59 | let lotteryTotalStaked = getIntegerValue(_lotteryTotalStaked) | |
60 | - | let _owner = mk([lotteryName, toString(lotteryTotalStaked), toString(((lotteryTotalStaked + ticketAmount) - 1)) | |
60 | + | let _owner = mk(["owner", lotteryName, toString(lotteryTotalStaked), toString(((lotteryTotalStaked + ticketAmount) - 1))]) | |
61 | 61 | let _adrTotalStaked = keyAdrTotalStaked(callerAddress) | |
62 | 62 | let adrTotalStaked = getIntegerOrElse(_adrTotalStaked, 0) | |
63 | 63 | let _adrLotteryTotalStaked = keyAdrLotteryTotalStaked(lotteryName, callerAddress) | |
64 | 64 | let adrLotteryTotalStaked = getIntegerOrElse(_adrLotteryTotalStaked, 0) | |
65 | 65 | [ScriptTransfer(i.caller, (amount - (ticketAmount * ticketSize)), lotteryAssetID), IntegerEntry(_lotteryTotalStaked, (lotteryTotalStaked + ticketAmount)), StringEntry(_owner, callerAddress), IntegerEntry(_adrTotalStaked, (adrTotalStaked + ticketAmount)), IntegerEntry(_adrLotteryTotalStaked, (adrLotteryTotalStaked + ticketAmount))] | |
66 | 66 | } | |
67 | 67 | } | |
68 | 68 | } | |
69 | 69 | ||
70 | 70 | ||
71 | 71 | ||
72 | 72 | @Callable(i) | |
73 | 73 | func claim () = { | |
74 | 74 | let lotteryName = activeLotteryName() | |
75 | 75 | let stakedInActiveLottery = if ((lotteryName == "")) | |
76 | 76 | then 100 | |
77 | 77 | else 200 | |
78 | 78 | [IntegerEntry("temp", stakedInActiveLottery)] | |
79 | 79 | } | |
80 | 80 | ||
81 | 81 | ||
82 | 82 | ||
83 | 83 | @Callable(i) | |
84 | 84 | func initLottery (lotteryName,lotteryFinalHeight) = if ((i.caller != this)) | |
85 | 85 | then throw("admin only") | |
86 | 86 | else [BooleanEntry("lotteryIsStarted", true), StringEntry("currentLotteryName", lotteryName), IntegerEntry(keyLotteryFinalHeight(lotteryName), lotteryFinalHeight), IntegerEntry(keyLotteryTotalStaked(lotteryName), 0)] | |
87 | 87 | ||
88 | 88 | ||
89 | 89 | ||
90 | 90 | @Callable(i) | |
91 | 91 | func call () = { | |
92 | 92 | let asset = Issue("Asset", "", 1, 0, true, unit, 0) | |
93 | 93 | let assetId = calculateAssetId(asset) | |
94 | 94 | [BinaryEntry("bin", base58''), BooleanEntry("bool", true), IntegerEntry("int", 1), StringEntry("str", ""), DeleteEntry("str"), asset, Reissue(assetId, 1, false), Burn(assetId, 1), ScriptTransfer(i.caller, 1, assetId)] | |
95 | 95 | } | |
96 | 96 | ||
97 | 97 | ||
98 | 98 | @Verifier(tx) | |
99 | 99 | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
100 | 100 |
github/deemru/w8io/169f3d6 28.83 ms ◑