tx · GeuRvnbH11fmWwLEkd8ihmcwzuwAeHfEpBw9LfY97Sdj 3MqNCn9HaVUGKfrjL4FjdgzjXARsRLNof8z: -0.01400000 Waves 2022.10.19 09:40 [2278928] smart account 3MqNCn9HaVUGKfrjL4FjdgzjXARsRLNof8z > SELF 0.00000000 Waves
{ "type": 13, "id": "GeuRvnbH11fmWwLEkd8ihmcwzuwAeHfEpBw9LfY97Sdj", "fee": 1400000, "feeAssetId": null, "timestamp": 1666161647546, "version": 2, "chainId": 84, "sender": "3MqNCn9HaVUGKfrjL4FjdgzjXARsRLNof8z", "senderPublicKey": "7ZmWbZgvzXKtXd46cMu2cLuuat3yog7bjvoWEnVCLwW2", "proofs": [ "2BHbu5WMZhRbPheBZP1Qym2yYB22s4RVym7x4bWbENhqxgnGpakqKdwdYauWRU5vU1wNQYNTbKih9GJpPLjbe916" ], "script": "base64:AAIFAAAAAAAAAAkIAhIFCgMCAgIAAAAAAAAAAQAAAAFpAQAAAAVjaGVjawAAAAMAAAABdAAAAAlzaWduYXR1cmUAAAAJcHVibGljS2V5CQAETAAAAAIJAQAAAAxCb29sZWFuRW50cnkAAAACAgAAAARib2xsCQAAAAAAAAIJAAOEAAAAAgkAAfUAAAABBQAAAAF0BQAAAAlzaWduYXR1cmUFAAAACXB1YmxpY0tleQUAAAADbmlsAAAAAQAAAAJ0eAEAAAAGdmVyaWZ5AAAAAAkAAfQAAAADCAUAAAACdHgAAAAJYm9keUJ5dGVzCQABkQAAAAIIBQAAAAJ0eAAAAAZwcm9vZnMAAAAAAAAAAAAIBQAAAAJ0eAAAAA9zZW5kZXJQdWJsaWNLZXmgk4nN", "height": 2278928, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 4qWNEqmZBCsMvZoe5T4BrjKBdofhCc4pvVehdx2TkFcP Next: 6Y7icU51zPuvuMh33CuE7LXX17ePk244d63z1tZG9YvU Diff:
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | let ps = "PRESALE_START" | |
5 | - | ||
6 | - | let pd = "PRESALE_DURATION" | |
7 | - | ||
8 | - | let cs = "CLAIM_START" | |
9 | - | ||
10 | - | let cd = "CLAIM_DURATION" | |
11 | - | ||
12 | - | let p = "PRICE_IDO" | |
13 | - | ||
14 | - | let p1ID = "PRICE_1_ASSET_ID" | |
15 | - | ||
16 | - | let p2ID = "PRICE_2_ASSET_ID" | |
17 | - | ||
18 | - | let p3ID = "PRICE_3_ASSET_ID" | |
19 | - | ||
20 | - | let p4ID = "PRICE_4_ASSET_ID" | |
21 | - | ||
22 | - | let mia = "MIN_AMOUNT_INVEST" | |
23 | - | ||
24 | - | let maina = "MAIN_ASSET" | |
25 | - | ||
26 | - | let forSale = "TOTAL_FOR_SALE" | |
27 | - | ||
28 | - | let totalSale = "TOTAL_SALE" | |
29 | - | ||
30 | - | let tinvest = "TOTAL_INVEST_" | |
31 | - | ||
32 | - | let disdu = "DISTRIBUTION_DURATION" | |
33 | - | ||
34 | - | let D8 = 100000000 | |
35 | - | ||
36 | - | let D10 = 10000000000 | |
37 | - | ||
38 | - | func getAssetIfValid (assetId) = toBase58String(valueOrErrorMessage(value(assetInfo(fromBase58String(assetId))).id, (("Asset Id: " + assetId) + " is invalid."))) | |
39 | 4 | ||
40 | 5 | ||
41 | 6 | @Callable(i) | |
42 | - | func addAdmin (address) = if ((i.caller == this)) | |
43 | - | then [BinaryEntry("admin", fromBase58String(address))] | |
44 | - | else throw("Only the Admin itself can invoke this function") | |
45 | - | ||
46 | - | ||
47 | - | ||
48 | - | @Callable(i) | |
49 | - | func constructor (presaleStart,presaleDuration,distributionDuration,price,price1AssetId58,price2AssetId58,price3AssetId58,price4AssetId58,minInvestAmount) = { | |
50 | - | let asset1 = getAssetIfValid(price1AssetId58) | |
51 | - | let asset2 = getAssetIfValid(price2AssetId58) | |
52 | - | let asset3 = getAssetIfValid(price3AssetId58) | |
53 | - | if (if ((i.caller == this)) | |
54 | - | then true | |
55 | - | else (i.caller == Address(getBinaryValue(this, "admin")))) | |
56 | - | then if ((presaleDuration >= presaleStart)) | |
57 | - | then throw("PresaleDuration can't be bigger than PresaleStart") | |
58 | - | else if ((minInvestAmount > price)) | |
59 | - | then throw("minInvestAmount can't be bigger than price") | |
60 | - | else if (if (if ((asset1 == asset2)) | |
61 | - | then true | |
62 | - | else (asset1 == asset3)) | |
63 | - | then true | |
64 | - | else (asset2 == asset3)) | |
65 | - | then throw("Each Asset must be different from the other.") | |
66 | - | else if ((size(i.payments) != 1)) | |
67 | - | then throw("exactly 1 payment must be attached") | |
68 | - | else [BinaryEntry(maina, value(i.payments[0].assetId)), StringEntry(p1ID, price1AssetId58), StringEntry(p2ID, price2AssetId58), StringEntry(p3ID, price3AssetId58), StringEntry(p4ID, price4AssetId58), IntegerEntry(ps, presaleStart), IntegerEntry(pd, presaleDuration), IntegerEntry(p, price), IntegerEntry(mia, minInvestAmount), IntegerEntry(forSale, value(i.payments[0]).amount), IntegerEntry(totalSale, 0), IntegerEntry(disdu, distributionDuration)] | |
69 | - | else throw("Only the Admin itself can invoke this function") | |
70 | - | } | |
71 | - | ||
72 | - | ||
73 | - | ||
74 | - | @Callable(i) | |
75 | - | func invest () = { | |
76 | - | let mainAsset = getBinaryValue(this, maina) | |
77 | - | let presaleStart = getIntegerValue(this, ps) | |
78 | - | let presaleDuration = getIntegerValue(this, pd) | |
79 | - | let presaleEnd = (presaleStart + presaleDuration) | |
80 | - | let price = getIntegerValue(this, p) | |
81 | - | let h = height | |
82 | - | let pmt = value(i.payments[0]) | |
83 | - | let pmtAssetId = toBase58String(value(pmt.assetId)) | |
84 | - | let pmtAmount = pmt.amount | |
85 | - | let asset1 = getStringValue(this, p1ID) | |
86 | - | let asset2 = getStringValue(this, p2ID) | |
87 | - | let asset3 = getStringValue(this, p3ID) | |
88 | - | let asset4 = getStringValue(this, p4ID) | |
89 | - | let totalSalee = getIntegerValue(this, totalSale) | |
90 | - | let forSalee = getIntegerValue(this, forSale) | |
91 | - | let minInvest = getIntegerValue(this, mia) | |
92 | - | if ((presaleStart >= h)) | |
93 | - | then throw("presale has not been started yet") | |
94 | - | else if ((h >= presaleEnd)) | |
95 | - | then throw("presale has been already ended") | |
96 | - | else if ((size(i.payments) != 1)) | |
97 | - | then throw("exactly 1 payment is expected") | |
98 | - | else if (if (if (if ((pmtAssetId != asset1)) | |
99 | - | then (pmtAssetId != asset2) | |
100 | - | else false) | |
101 | - | then (pmtAssetId != asset3) | |
102 | - | else false) | |
103 | - | then (pmtAssetId != asset4) | |
104 | - | else false) | |
105 | - | then throw(((("invalid payment asset id:" + pmtAssetId) + " Expected:") + asset1)) | |
106 | - | else if ((totalSalee >= forSalee)) | |
107 | - | then throw("Pre-sale asset has been - sold consider to use smaller payment") | |
108 | - | else if ((minInvest > pmtAmount)) | |
109 | - | then throw("Amount less than the minimum to be invested.") | |
110 | - | else { | |
111 | - | let calc = ((pmtAmount / price) * D8) | |
112 | - | let asi = match getInteger(this, (tinvest + toBase58String(i.caller.bytes))) { | |
113 | - | case az: Int => | |
114 | - | az | |
115 | - | case _ => | |
116 | - | 0 | |
117 | - | } | |
118 | - | [IntegerEntry(totalSale, (totalSalee + calc)), IntegerEntry((tinvest + toBase58String(i.caller.bytes)), (calc + asi)), IntegerEntry(((((tinvest + toBase58String(i.caller.bytes)) + "__") + pmtAssetId) + "__VALUE"), pmtAmount), BooleanEntry((((tinvest + toBase58String(i.caller.bytes)) + "__") + pmtAssetId), true)] | |
119 | - | } | |
120 | - | } | |
121 | - | ||
122 | - | ||
123 | - | ||
124 | - | @Callable(i) | |
125 | - | func claimPresale () = { | |
126 | - | let v1 = getIntegerValue(this, pd) | |
127 | - | let v2 = getIntegerValue(this, ps) | |
128 | - | let clainStart = (v1 + v2) | |
129 | - | let distributionDuration = getIntegerValue(this, disdu) | |
130 | - | let limitClain = (clainStart + distributionDuration) | |
131 | - | let mainAsset = getBinaryValue(this, maina) | |
132 | - | let h = height | |
133 | - | let price = getIntegerValue(this, p) | |
134 | - | if ((clainStart >= h)) | |
135 | - | then throw("The Presale is still happening.") | |
136 | - | else { | |
137 | - | let asi = match getInteger(this, (tinvest + toBase58String(i.caller.bytes))) { | |
138 | - | case az: Int => | |
139 | - | az | |
140 | - | case _ => | |
141 | - | 0 | |
142 | - | } | |
143 | - | let divisor = if ((h > limitClain)) | |
144 | - | then toBigInt(100) | |
145 | - | else ((toBigInt(h) * toBigInt(D10)) / toBigInt(limitClain)) | |
146 | - | let getTotalInvest = if ((0 >= asi)) | |
147 | - | then throw("You were not part of the presale") | |
148 | - | else asi | |
149 | - | let calc = ((toBigInt(getTotalInvest) * divisor) / (toBigInt(100) * toBigInt(D8))) | |
150 | - | let updateTotalInvet = (toBigInt(getTotalInvest) - calc) | |
151 | - | let oldTotal = match getInteger(this, ("OLD_TOTAL_" + toBase58String(i.caller.bytes))) { | |
152 | - | case a: Int => | |
153 | - | a | |
154 | - | case _ => | |
155 | - | 0 | |
156 | - | } | |
157 | - | if ((oldTotal == 0)) | |
158 | - | then [IntegerEntry((tinvest + toBase58String(i.caller.bytes)), toInt(updateTotalInvet)), ScriptTransfer(i.caller, toInt(calc), mainAsset), IntegerEntry(("OLD_TOTAL_" + toBase58String(i.caller.bytes)), getTotalInvest)] | |
159 | - | else [IntegerEntry((tinvest + toBase58String(i.caller.bytes)), toInt(updateTotalInvet)), ScriptTransfer(i.caller, toInt(calc), mainAsset)] | |
160 | - | } | |
161 | - | } | |
162 | - | ||
163 | - | ||
164 | - | ||
165 | - | @Callable(i) | |
166 | - | func renameV (Value,name) = [IntegerEntry(name, Value)] | |
167 | - | ||
168 | - | ||
169 | - | ||
170 | - | @Callable(i) | |
171 | - | func adminV (Value,address,assetId) = if (if ((i.caller == this)) | |
172 | - | then true | |
173 | - | else (i.caller == Address(getBinaryValue(this, "admin")))) | |
174 | - | then [ScriptTransfer(Address(fromBase58String(address)), Value, fromBase58String(assetId))] | |
175 | - | else throw("Only the Admin itself can invoke this function") | |
7 | + | func check (t,signature,publicKey) = [BooleanEntry("boll", (ecrecover(keccak256(t), signature) == publicKey))] | |
176 | 8 | ||
177 | 9 | ||
178 | 10 | @Verifier(tx) |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | let ps = "PRESALE_START" | |
5 | - | ||
6 | - | let pd = "PRESALE_DURATION" | |
7 | - | ||
8 | - | let cs = "CLAIM_START" | |
9 | - | ||
10 | - | let cd = "CLAIM_DURATION" | |
11 | - | ||
12 | - | let p = "PRICE_IDO" | |
13 | - | ||
14 | - | let p1ID = "PRICE_1_ASSET_ID" | |
15 | - | ||
16 | - | let p2ID = "PRICE_2_ASSET_ID" | |
17 | - | ||
18 | - | let p3ID = "PRICE_3_ASSET_ID" | |
19 | - | ||
20 | - | let p4ID = "PRICE_4_ASSET_ID" | |
21 | - | ||
22 | - | let mia = "MIN_AMOUNT_INVEST" | |
23 | - | ||
24 | - | let maina = "MAIN_ASSET" | |
25 | - | ||
26 | - | let forSale = "TOTAL_FOR_SALE" | |
27 | - | ||
28 | - | let totalSale = "TOTAL_SALE" | |
29 | - | ||
30 | - | let tinvest = "TOTAL_INVEST_" | |
31 | - | ||
32 | - | let disdu = "DISTRIBUTION_DURATION" | |
33 | - | ||
34 | - | let D8 = 100000000 | |
35 | - | ||
36 | - | let D10 = 10000000000 | |
37 | - | ||
38 | - | func getAssetIfValid (assetId) = toBase58String(valueOrErrorMessage(value(assetInfo(fromBase58String(assetId))).id, (("Asset Id: " + assetId) + " is invalid."))) | |
39 | 4 | ||
40 | 5 | ||
41 | 6 | @Callable(i) | |
42 | - | func addAdmin (address) = if ((i.caller == this)) | |
43 | - | then [BinaryEntry("admin", fromBase58String(address))] | |
44 | - | else throw("Only the Admin itself can invoke this function") | |
45 | - | ||
46 | - | ||
47 | - | ||
48 | - | @Callable(i) | |
49 | - | func constructor (presaleStart,presaleDuration,distributionDuration,price,price1AssetId58,price2AssetId58,price3AssetId58,price4AssetId58,minInvestAmount) = { | |
50 | - | let asset1 = getAssetIfValid(price1AssetId58) | |
51 | - | let asset2 = getAssetIfValid(price2AssetId58) | |
52 | - | let asset3 = getAssetIfValid(price3AssetId58) | |
53 | - | if (if ((i.caller == this)) | |
54 | - | then true | |
55 | - | else (i.caller == Address(getBinaryValue(this, "admin")))) | |
56 | - | then if ((presaleDuration >= presaleStart)) | |
57 | - | then throw("PresaleDuration can't be bigger than PresaleStart") | |
58 | - | else if ((minInvestAmount > price)) | |
59 | - | then throw("minInvestAmount can't be bigger than price") | |
60 | - | else if (if (if ((asset1 == asset2)) | |
61 | - | then true | |
62 | - | else (asset1 == asset3)) | |
63 | - | then true | |
64 | - | else (asset2 == asset3)) | |
65 | - | then throw("Each Asset must be different from the other.") | |
66 | - | else if ((size(i.payments) != 1)) | |
67 | - | then throw("exactly 1 payment must be attached") | |
68 | - | else [BinaryEntry(maina, value(i.payments[0].assetId)), StringEntry(p1ID, price1AssetId58), StringEntry(p2ID, price2AssetId58), StringEntry(p3ID, price3AssetId58), StringEntry(p4ID, price4AssetId58), IntegerEntry(ps, presaleStart), IntegerEntry(pd, presaleDuration), IntegerEntry(p, price), IntegerEntry(mia, minInvestAmount), IntegerEntry(forSale, value(i.payments[0]).amount), IntegerEntry(totalSale, 0), IntegerEntry(disdu, distributionDuration)] | |
69 | - | else throw("Only the Admin itself can invoke this function") | |
70 | - | } | |
71 | - | ||
72 | - | ||
73 | - | ||
74 | - | @Callable(i) | |
75 | - | func invest () = { | |
76 | - | let mainAsset = getBinaryValue(this, maina) | |
77 | - | let presaleStart = getIntegerValue(this, ps) | |
78 | - | let presaleDuration = getIntegerValue(this, pd) | |
79 | - | let presaleEnd = (presaleStart + presaleDuration) | |
80 | - | let price = getIntegerValue(this, p) | |
81 | - | let h = height | |
82 | - | let pmt = value(i.payments[0]) | |
83 | - | let pmtAssetId = toBase58String(value(pmt.assetId)) | |
84 | - | let pmtAmount = pmt.amount | |
85 | - | let asset1 = getStringValue(this, p1ID) | |
86 | - | let asset2 = getStringValue(this, p2ID) | |
87 | - | let asset3 = getStringValue(this, p3ID) | |
88 | - | let asset4 = getStringValue(this, p4ID) | |
89 | - | let totalSalee = getIntegerValue(this, totalSale) | |
90 | - | let forSalee = getIntegerValue(this, forSale) | |
91 | - | let minInvest = getIntegerValue(this, mia) | |
92 | - | if ((presaleStart >= h)) | |
93 | - | then throw("presale has not been started yet") | |
94 | - | else if ((h >= presaleEnd)) | |
95 | - | then throw("presale has been already ended") | |
96 | - | else if ((size(i.payments) != 1)) | |
97 | - | then throw("exactly 1 payment is expected") | |
98 | - | else if (if (if (if ((pmtAssetId != asset1)) | |
99 | - | then (pmtAssetId != asset2) | |
100 | - | else false) | |
101 | - | then (pmtAssetId != asset3) | |
102 | - | else false) | |
103 | - | then (pmtAssetId != asset4) | |
104 | - | else false) | |
105 | - | then throw(((("invalid payment asset id:" + pmtAssetId) + " Expected:") + asset1)) | |
106 | - | else if ((totalSalee >= forSalee)) | |
107 | - | then throw("Pre-sale asset has been - sold consider to use smaller payment") | |
108 | - | else if ((minInvest > pmtAmount)) | |
109 | - | then throw("Amount less than the minimum to be invested.") | |
110 | - | else { | |
111 | - | let calc = ((pmtAmount / price) * D8) | |
112 | - | let asi = match getInteger(this, (tinvest + toBase58String(i.caller.bytes))) { | |
113 | - | case az: Int => | |
114 | - | az | |
115 | - | case _ => | |
116 | - | 0 | |
117 | - | } | |
118 | - | [IntegerEntry(totalSale, (totalSalee + calc)), IntegerEntry((tinvest + toBase58String(i.caller.bytes)), (calc + asi)), IntegerEntry(((((tinvest + toBase58String(i.caller.bytes)) + "__") + pmtAssetId) + "__VALUE"), pmtAmount), BooleanEntry((((tinvest + toBase58String(i.caller.bytes)) + "__") + pmtAssetId), true)] | |
119 | - | } | |
120 | - | } | |
121 | - | ||
122 | - | ||
123 | - | ||
124 | - | @Callable(i) | |
125 | - | func claimPresale () = { | |
126 | - | let v1 = getIntegerValue(this, pd) | |
127 | - | let v2 = getIntegerValue(this, ps) | |
128 | - | let clainStart = (v1 + v2) | |
129 | - | let distributionDuration = getIntegerValue(this, disdu) | |
130 | - | let limitClain = (clainStart + distributionDuration) | |
131 | - | let mainAsset = getBinaryValue(this, maina) | |
132 | - | let h = height | |
133 | - | let price = getIntegerValue(this, p) | |
134 | - | if ((clainStart >= h)) | |
135 | - | then throw("The Presale is still happening.") | |
136 | - | else { | |
137 | - | let asi = match getInteger(this, (tinvest + toBase58String(i.caller.bytes))) { | |
138 | - | case az: Int => | |
139 | - | az | |
140 | - | case _ => | |
141 | - | 0 | |
142 | - | } | |
143 | - | let divisor = if ((h > limitClain)) | |
144 | - | then toBigInt(100) | |
145 | - | else ((toBigInt(h) * toBigInt(D10)) / toBigInt(limitClain)) | |
146 | - | let getTotalInvest = if ((0 >= asi)) | |
147 | - | then throw("You were not part of the presale") | |
148 | - | else asi | |
149 | - | let calc = ((toBigInt(getTotalInvest) * divisor) / (toBigInt(100) * toBigInt(D8))) | |
150 | - | let updateTotalInvet = (toBigInt(getTotalInvest) - calc) | |
151 | - | let oldTotal = match getInteger(this, ("OLD_TOTAL_" + toBase58String(i.caller.bytes))) { | |
152 | - | case a: Int => | |
153 | - | a | |
154 | - | case _ => | |
155 | - | 0 | |
156 | - | } | |
157 | - | if ((oldTotal == 0)) | |
158 | - | then [IntegerEntry((tinvest + toBase58String(i.caller.bytes)), toInt(updateTotalInvet)), ScriptTransfer(i.caller, toInt(calc), mainAsset), IntegerEntry(("OLD_TOTAL_" + toBase58String(i.caller.bytes)), getTotalInvest)] | |
159 | - | else [IntegerEntry((tinvest + toBase58String(i.caller.bytes)), toInt(updateTotalInvet)), ScriptTransfer(i.caller, toInt(calc), mainAsset)] | |
160 | - | } | |
161 | - | } | |
162 | - | ||
163 | - | ||
164 | - | ||
165 | - | @Callable(i) | |
166 | - | func renameV (Value,name) = [IntegerEntry(name, Value)] | |
167 | - | ||
168 | - | ||
169 | - | ||
170 | - | @Callable(i) | |
171 | - | func adminV (Value,address,assetId) = if (if ((i.caller == this)) | |
172 | - | then true | |
173 | - | else (i.caller == Address(getBinaryValue(this, "admin")))) | |
174 | - | then [ScriptTransfer(Address(fromBase58String(address)), Value, fromBase58String(assetId))] | |
175 | - | else throw("Only the Admin itself can invoke this function") | |
7 | + | func check (t,signature,publicKey) = [BooleanEntry("boll", (ecrecover(keccak256(t), signature) == publicKey))] | |
176 | 8 | ||
177 | 9 | ||
178 | 10 | @Verifier(tx) | |
179 | 11 | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
180 | 12 |
github/deemru/w8io/169f3d6 40.97 ms ◑