tx · 2zAEnCMo4o9pQEm57rHWbZwV4pM2mF7PnUxD1L1hx8hS 3N8bfBHf85mChgxdRoTj11XEHHREfQmz6dw: -0.01000000 Waves 2023.03.13 01:23 [2487412] smart account 3N8bfBHf85mChgxdRoTj11XEHHREfQmz6dw > SELF 0.00000000 Waves
{ "type": 13, "id": "2zAEnCMo4o9pQEm57rHWbZwV4pM2mF7PnUxD1L1hx8hS", "fee": 1000000, "feeAssetId": null, "timestamp": 1678659813067, "version": 2, "chainId": 84, "sender": "3N8bfBHf85mChgxdRoTj11XEHHREfQmz6dw", "senderPublicKey": "6G9zJtFnV938b3kA2t6HebP8i69A1NMGVQ5qQ78fF1FR", "proofs": [ "4HZvEdZGHaPRxwnSB9svcMeEsVMM8dCM8GrVRf3Mp46j4MhUonYUThzn2b1fcn3omEwzE1NngwDvZkTQ2ULWTC34" ], "script": "base64:AAIFAAAAAAAAACYIAhIDCgEIEgsKCQEBAQEICAgIARIAEgASBQoDAQgIEgUKAwEBAQAAABMAAAAAAnBzAgAAAA1QUkVTQUxFX1NUQVJUAAAAAAJwZAIAAAAQUFJFU0FMRV9EVVJBVElPTgAAAAACY3MCAAAAC0NMQUlNX1NUQVJUAAAAAAJjZAIAAAAOQ0xBSU1fRFVSQVRJT04AAAAAAXACAAAACVBSSUNFX0lETwAAAAAEcDFJRAIAAAAQUFJJQ0VfMV9BU1NFVF9JRAAAAAAKYWRtaW5FcnJvcgIAAAAuT25seSB0aGUgQWRtaW4gaXRzZWxmIGNhbiBpbnZva2UgdGhpcyBmdW5jdGlvbgAAAAAEcDJJRAIAAAAQUFJJQ0VfMl9BU1NFVF9JRAAAAAAEcDNJRAIAAAAQUFJJQ0VfM19BU1NFVF9JRAAAAAAEcDRJRAIAAAAQUFJJQ0VfNF9BU1NFVF9JRAAAAAADbWlhAgAAABFNSU5fQU1PVU5UX0lOVkVTVAAAAAAFbWFpbmECAAAACk1BSU5fQVNTRVQAAAAAB2ZvclNhbGUCAAAADlRPVEFMX0ZPU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AAAAggFAAAAAnR4AAAABnByb29mcwAAAAAAAAAAAAgFAAAAAnR4AAAAD3NlbmRlclB1YmxpY0tleZ01PvI=", "height": 2487412, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: H1itMcQrnno3MgwxwkeD2oSusuYcVskDZvwrT8G334zp Next: kGvUWxe2yKtbURaYe33xr3PLryapsWWpjuvCryTf6en Diff:
Old | New | Differences | |
---|---|---|---|
40 | 40 | func getAssetIfValid (assetId) = toBase58String(valueOrErrorMessage(value(assetInfo(fromBase58String(assetId))).id, (("Asset Id: " + assetId) + " is invalid."))) | |
41 | 41 | ||
42 | 42 | ||
43 | - | let adminAddress = "3N1io5kDA3VhQyxrLyXtGaeLxoPtZfkAgEc" | |
43 | + | @Callable(i) | |
44 | + | func AddAdmin (address) = if ((i.caller.bytes == this.bytes)) | |
45 | + | then [StringEntry("admin", address)] | |
46 | + | else throw(adminError) | |
44 | 47 | ||
45 | - | ||
48 | + | ||
46 | 49 | ||
47 | 50 | @Callable(i) | |
48 | 51 | func constructor (presaleStart,presaleDuration,distributionDuration,price,price1AssetId58,price2AssetId58,price3AssetId58,price4AssetId58,minInvestAmount) = { | |
51 | 54 | let asset3 = getAssetIfValid(price3AssetId58) | |
52 | 55 | if (if ((i.caller == this)) | |
53 | 56 | then true | |
54 | - | else (i.caller.bytes == getBinaryValue( | |
57 | + | else (i.caller.bytes == getBinaryValue(this, "admin"))) | |
55 | 58 | then if ((presaleDuration >= presaleStart)) | |
56 | 59 | then throw("PresaleDuration can't be bigger than PresaleStart") | |
57 | 60 | else if ((minInvestAmount > price)) | |
71 | 74 | @Callable(i) | |
72 | 75 | func set () = if (if ((i.caller == this)) | |
73 | 76 | then true | |
74 | - | else (i.caller.bytes == getBinaryValue( | |
77 | + | else (i.caller.bytes == getBinaryValue(this, "admin"))) | |
75 | 78 | then if ((size(i.payments) != 1)) | |
76 | 79 | then throw("exactly 1 payment must be attached") | |
77 | 80 | else [IntegerEntry(forSale, value(i.payments[0]).amount), BinaryEntry(maina, value(i.payments[0].assetId))] |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let ps = "PRESALE_START" | |
5 | 5 | ||
6 | 6 | let pd = "PRESALE_DURATION" | |
7 | 7 | ||
8 | 8 | let cs = "CLAIM_START" | |
9 | 9 | ||
10 | 10 | let cd = "CLAIM_DURATION" | |
11 | 11 | ||
12 | 12 | let p = "PRICE_IDO" | |
13 | 13 | ||
14 | 14 | let p1ID = "PRICE_1_ASSET_ID" | |
15 | 15 | ||
16 | 16 | let adminError = "Only the Admin itself can invoke this function" | |
17 | 17 | ||
18 | 18 | let p2ID = "PRICE_2_ASSET_ID" | |
19 | 19 | ||
20 | 20 | let p3ID = "PRICE_3_ASSET_ID" | |
21 | 21 | ||
22 | 22 | let p4ID = "PRICE_4_ASSET_ID" | |
23 | 23 | ||
24 | 24 | let mia = "MIN_AMOUNT_INVEST" | |
25 | 25 | ||
26 | 26 | let maina = "MAIN_ASSET" | |
27 | 27 | ||
28 | 28 | let forSale = "TOTAL_FOR_SALE" | |
29 | 29 | ||
30 | 30 | let totalSale = "TOTAL_SALE" | |
31 | 31 | ||
32 | 32 | let tinvest = "TOTAL_INVEST_" | |
33 | 33 | ||
34 | 34 | let disdu = "DISTRIBUTION_DURATION" | |
35 | 35 | ||
36 | 36 | let D8 = 100000000 | |
37 | 37 | ||
38 | 38 | let D10 = 10000000000 | |
39 | 39 | ||
40 | 40 | func getAssetIfValid (assetId) = toBase58String(valueOrErrorMessage(value(assetInfo(fromBase58String(assetId))).id, (("Asset Id: " + assetId) + " is invalid."))) | |
41 | 41 | ||
42 | 42 | ||
43 | - | let adminAddress = "3N1io5kDA3VhQyxrLyXtGaeLxoPtZfkAgEc" | |
43 | + | @Callable(i) | |
44 | + | func AddAdmin (address) = if ((i.caller.bytes == this.bytes)) | |
45 | + | then [StringEntry("admin", address)] | |
46 | + | else throw(adminError) | |
44 | 47 | ||
45 | - | ||
48 | + | ||
46 | 49 | ||
47 | 50 | @Callable(i) | |
48 | 51 | func constructor (presaleStart,presaleDuration,distributionDuration,price,price1AssetId58,price2AssetId58,price3AssetId58,price4AssetId58,minInvestAmount) = { | |
49 | 52 | let asset1 = getAssetIfValid(price1AssetId58) | |
50 | 53 | let asset2 = getAssetIfValid(price2AssetId58) | |
51 | 54 | let asset3 = getAssetIfValid(price3AssetId58) | |
52 | 55 | if (if ((i.caller == this)) | |
53 | 56 | then true | |
54 | - | else (i.caller.bytes == getBinaryValue( | |
57 | + | else (i.caller.bytes == getBinaryValue(this, "admin"))) | |
55 | 58 | then if ((presaleDuration >= presaleStart)) | |
56 | 59 | then throw("PresaleDuration can't be bigger than PresaleStart") | |
57 | 60 | else if ((minInvestAmount > price)) | |
58 | 61 | then throw("minInvestAmount can't be bigger than price") | |
59 | 62 | else if (if (if ((asset1 == asset2)) | |
60 | 63 | then true | |
61 | 64 | else (asset1 == asset3)) | |
62 | 65 | then true | |
63 | 66 | else (asset2 == asset3)) | |
64 | 67 | then throw("Each Asset must be different from the other.") | |
65 | 68 | else [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(totalSale, 0), IntegerEntry(disdu, distributionDuration)] | |
66 | 69 | else throw(adminError) | |
67 | 70 | } | |
68 | 71 | ||
69 | 72 | ||
70 | 73 | ||
71 | 74 | @Callable(i) | |
72 | 75 | func set () = if (if ((i.caller == this)) | |
73 | 76 | then true | |
74 | - | else (i.caller.bytes == getBinaryValue( | |
77 | + | else (i.caller.bytes == getBinaryValue(this, "admin"))) | |
75 | 78 | then if ((size(i.payments) != 1)) | |
76 | 79 | then throw("exactly 1 payment must be attached") | |
77 | 80 | else [IntegerEntry(forSale, value(i.payments[0]).amount), BinaryEntry(maina, value(i.payments[0].assetId))] | |
78 | 81 | else throw(adminError) | |
79 | 82 | ||
80 | 83 | ||
81 | 84 | ||
82 | 85 | @Callable(i) | |
83 | 86 | func invest () = { | |
84 | 87 | let mainAsset = getBinaryValue(this, maina) | |
85 | 88 | let presaleStart = getIntegerValue(this, ps) | |
86 | 89 | let presaleDuration = getIntegerValue(this, pd) | |
87 | 90 | let presaleEnd = (presaleStart + presaleDuration) | |
88 | 91 | let price = getIntegerValue(this, p) | |
89 | 92 | let h = height | |
90 | 93 | let pmt = value(i.payments[0]) | |
91 | 94 | let pmtAssetId = toBase58String(value(pmt.assetId)) | |
92 | 95 | let pmtAmount = pmt.amount | |
93 | 96 | let asset1 = getStringValue(this, p1ID) | |
94 | 97 | let asset2 = getStringValue(this, p2ID) | |
95 | 98 | let asset3 = getStringValue(this, p3ID) | |
96 | 99 | let asset4 = getStringValue(this, p4ID) | |
97 | 100 | let totalSalee = getIntegerValue(this, totalSale) | |
98 | 101 | let forSalee = getIntegerValue(this, forSale) | |
99 | 102 | let minInvest = getIntegerValue(this, mia) | |
100 | 103 | if ((presaleStart >= h)) | |
101 | 104 | then throw("presale has not been started yet") | |
102 | 105 | else if ((h >= presaleEnd)) | |
103 | 106 | then throw("presale has been already ended") | |
104 | 107 | else if ((size(i.payments) != 1)) | |
105 | 108 | then throw("exactly 1 payment is expected") | |
106 | 109 | else if (if (if (if ((pmtAssetId != asset1)) | |
107 | 110 | then (pmtAssetId != asset2) | |
108 | 111 | else false) | |
109 | 112 | then (pmtAssetId != asset3) | |
110 | 113 | else false) | |
111 | 114 | then (pmtAssetId != asset4) | |
112 | 115 | else false) | |
113 | 116 | then throw(((("invalid payment asset id:" + pmtAssetId) + " Expected:") + asset1)) | |
114 | 117 | else if ((totalSalee >= forSalee)) | |
115 | 118 | then throw("Pre-sale asset has been - sold consider to use smaller payment") | |
116 | 119 | else if ((minInvest > pmtAmount)) | |
117 | 120 | then throw("Amount less than the minimum to be invested.") | |
118 | 121 | else { | |
119 | 122 | let calc = ((pmtAmount / price) * D8) | |
120 | 123 | let asi = match getInteger(this, (tinvest + toBase58String(i.caller.bytes))) { | |
121 | 124 | case az: Int => | |
122 | 125 | az | |
123 | 126 | case _ => | |
124 | 127 | 0 | |
125 | 128 | } | |
126 | 129 | [ScriptTransfer(i.caller, calc, mainAsset), 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)] | |
127 | 130 | } | |
128 | 131 | } | |
129 | 132 | ||
130 | 133 | ||
131 | 134 | ||
132 | 135 | @Callable(i) | |
133 | 136 | func adminV (Value,address,assetId) = if (if ((i.caller == this)) | |
134 | 137 | then true | |
135 | 138 | else (i.caller == Address(getBinaryValue(this, "admin")))) | |
136 | 139 | then [ScriptTransfer(Address(fromBase58String(address)), Value, fromBase58String(assetId))] | |
137 | 140 | else throw(adminError) | |
138 | 141 | ||
139 | 142 | ||
140 | 143 | ||
141 | 144 | @Callable(i) | |
142 | 145 | func time (presaleStart,presaleDuration,distributionDuration) = if (if ((i.caller == this)) | |
143 | 146 | then true | |
144 | 147 | else (i.caller.bytes == getBinaryValue(this, "admin"))) | |
145 | 148 | then if ((presaleDuration >= presaleStart)) | |
146 | 149 | then throw("PresaleDuration can't be bigger than PresaleStart") | |
147 | 150 | else [IntegerEntry(ps, presaleStart), IntegerEntry(pd, presaleDuration), IntegerEntry(disdu, distributionDuration)] | |
148 | 151 | else throw(adminError) | |
149 | 152 | ||
150 | 153 | ||
151 | 154 | @Verifier(tx) | |
152 | 155 | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
153 | 156 |
github/deemru/w8io/169f3d6 52.24 ms ◑