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