tx · Hmd2DE4nhU4gJotnd4jscEcDKtZS66qg5mRz7PWpLcYG 3MugVLz68nyN2JcEoXRYgXmrs1QsvWGukuJ: -0.01000000 Waves 2019.07.29 16:35 [607437] smart account 3MugVLz68nyN2JcEoXRYgXmrs1QsvWGukuJ > SELF 0.00000000 Waves
{ "type": 13, "id": "Hmd2DE4nhU4gJotnd4jscEcDKtZS66qg5mRz7PWpLcYG", "fee": 1000000, "feeAssetId": null, "timestamp": 1564407337717, "version": 1, "sender": "3MugVLz68nyN2JcEoXRYgXmrs1QsvWGukuJ", "senderPublicKey": "BZvD5tF1Sfo9mEg2evDWQXn6REHS1LHFqqZRaiJzSb3b", "proofs": [ "jLiHWenRLqMS629UYYXPst6JhJcX3Zb7X2Uzj7h1iLhLrMPEZXsqqrTma8zQJKKNompKzPrhPcSprkYQkMHJWh1" ], "script": "base64:AAIDAAAAAAAAAAAAAAAZAAAAAA1pc3N1ZXJBc3NldElkAQAAACAZh+J6O8zV1Vw51KbdYrhDiBb+dF8aTABqZN4UigzxWgAAAAARaW52ZXN0bWVudEFzc2V0SWQBAAAABBOr2TMAAAAAGGludmVzdG1lbnRBc3NldElkSXNXYXZlcwYAAAAADm93bmVyUHVibGljS2V5AQAAACDiG+q9WUODx9t4AytNVZbtyJ0YtS0O7EagSr17yAUmPgAAAAAMb3duZXJBZGRyZXNzCQEAAAAUYWRkcmVzc0Zyb21QdWJsaWNLZXkAAAABBQAAAA5vd25lclB1YmxpY0tleQAAAAASb3duZXJBZGRyZXNzU3RyaW5nAgAAACMzTjk2d0duczVzeUZ5aXh4Znh5VlhhM2tSNmFockF5UDFFeAAAAAARYWNjb3VudFRoYXRBbGxvd3MJAQAAAAdBZGRyZXNzAAAAAQEAAAAaAVTGG0wwFoVGlTJOaT+rMPobO99P2dcQjzsAAAAAFWFjY291bnRUaGF0QWxsb3dEQXBwcwkBAAAAB0FkZHJlc3MAAAABAQAAABoBVMYbTDAWhUaVMk5pP6sw+hs730/Z1xCPOwAAAAALY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W1vdW50BQAAABFpbnZlc3RtZW50QXNzZXRJZAUAAAADbmlsAAAAAQAAAAJ0eAEAAAAGdmVyaWZ5AAAAAAQAAAAHJG1hdGNoMAUAAAACdHgDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAFFNldFNjcmlwdFRyYW5zYWN0aW9uBAAAAAJ0eAUAAAAHJG1hdGNoMAkAAfQAAAADCAUAAAACdHgAAAAJYm9keUJ5dGVzCQABkQAAAAIIBQAAAAJ0eAAAAAZwcm9vZnMAAAAAAAAAAAAIBQAAAAJ0eAAAAA9zZW5kZXJQdWJsaWNLZXkHApbFDA==", "chainId": 84, "height": 607437, "spentComplexity": 0 } View: original | compacted Prev: none Next: none Full:
Old | New | Differences | |
---|---|---|---|
1 | - | # no script | |
1 | + | {-# STDLIB_VERSION 3 #-} | |
2 | + | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | + | {-# CONTENT_TYPE DAPP #-} | |
4 | + | let issuerAssetId = base58'2ifNS9383oSgNYtiMm222tmPHGNk6PHaHPCzQWop3jWZ' | |
5 | + | ||
6 | + | let investmentAssetId = base58'WAVES' | |
7 | + | ||
8 | + | let investmentAssetIdIsWaves = true | |
9 | + | ||
10 | + | let ownerPublicKey = base58'GDdq7jWcHDMvQughWo58GnZrfGGi3TjMrau7tW1pYUub' | |
11 | + | ||
12 | + | let ownerAddress = addressFromPublicKey(ownerPublicKey) | |
13 | + | ||
14 | + | let ownerAddressString = "3N96wGns5syFyixxfxyVXa3kR6ahrAyP1Ex" | |
15 | + | ||
16 | + | let accountThatAllows = Address(base58'3N7yaGaFS8BvgRrc9trhNy7v5H4qCcxW3Fp') | |
17 | + | ||
18 | + | let accountThatAllowDApps = Address(base58'3N7yaGaFS8BvgRrc9trhNy7v5H4qCcxW3Fp') | |
19 | + | ||
20 | + | let assetDigits = 10000 | |
21 | + | ||
22 | + | let sumAccountAssets = 10000000 | |
23 | + | ||
24 | + | let issuerAssets = 0 | |
25 | + | ||
26 | + | let startBlock = 607429 | |
27 | + | ||
28 | + | let increasePriceBlock = 609486 | |
29 | + | ||
30 | + | let endBlock = 609486 | |
31 | + | ||
32 | + | let price = 1000000000 | |
33 | + | ||
34 | + | let priceSecond = 1000000000 | |
35 | + | ||
36 | + | let softCapAmount = 10000000000 | |
37 | + | ||
38 | + | let hardCapAmount = 1000000000000 | |
39 | + | ||
40 | + | let keySumAmountPrefix = "sumAmount " | |
41 | + | ||
42 | + | let keySumPaidAmountPrefix = "paidAmount " | |
43 | + | ||
44 | + | let keySumAssetsPrefix = "sumAssets " | |
45 | + | ||
46 | + | let keyAllowAccountPrefix = "allow " | |
47 | + | ||
48 | + | let keyDistAssets = "assets" | |
49 | + | ||
50 | + | let keyCollectedAmount = "amount" | |
51 | + | ||
52 | + | let keyIssuer = "issuer" | |
53 | + | ||
54 | + | @Callable(i) | |
55 | + | func deposit () = { | |
56 | + | let currentPrice = if ((increasePriceBlock > height)) | |
57 | + | then price | |
58 | + | else priceSecond | |
59 | + | let accountAmount = match getInteger(this, keyCollectedAmount) { | |
60 | + | case a: Int => | |
61 | + | a | |
62 | + | case _ => | |
63 | + | 0 | |
64 | + | } | |
65 | + | if ((startBlock > height)) | |
66 | + | then throw(((("The Tokensale works between " + toString(startBlock)) + " and ") + toString(endBlock))) | |
67 | + | else if (if ((height > endBlock)) | |
68 | + | then true | |
69 | + | else (accountAmount >= hardCapAmount)) | |
70 | + | then throw("The required amount has already been accumulated. If you are an investor, you can withdraw your funds.") | |
71 | + | else { | |
72 | + | let payment = match i.payment { | |
73 | + | case p: AttachedPayment => | |
74 | + | let isPaymentOk = match p.assetId { | |
75 | + | case assetId: ByteVector => | |
76 | + | if (!(investmentAssetIdIsWaves)) | |
77 | + | then (assetId == investmentAssetId) | |
78 | + | else false | |
79 | + | case _ => | |
80 | + | (investmentAssetIdIsWaves == true) | |
81 | + | } | |
82 | + | if (isPaymentOk) | |
83 | + | then p.amount | |
84 | + | else throw("Invalid asset ID of investment") | |
85 | + | case _ => | |
86 | + | throw("Payment must be attached") | |
87 | + | } | |
88 | + | let currentKey = toBase58String(i.caller.bytes) | |
89 | + | let isAccountAllow = match getInteger(accountThatAllows, currentKey) { | |
90 | + | case a: Int => | |
91 | + | a | |
92 | + | case _ => | |
93 | + | -255 | |
94 | + | } | |
95 | + | if ((-1 > isAccountAllow)) | |
96 | + | then throw("Your account has no right to send funds.") | |
97 | + | else { | |
98 | + | let accountAssets = match getInteger(this, keyDistAssets) { | |
99 | + | case a: Int => | |
100 | + | a | |
101 | + | case _ => | |
102 | + | sumAccountAssets | |
103 | + | } | |
104 | + | if ((0 > (accountAssets - ((payment * assetDigits) / currentPrice)))) | |
105 | + | then throw((("Payment is too big. Maximum possible payment is " + toString(((accountAssets * currentPrice) / assetDigits))) + " wavelet")) | |
106 | + | else { | |
107 | + | let currentAmount = match getInteger(this, (keySumAmountPrefix + currentKey)) { | |
108 | + | case a: Int => | |
109 | + | a | |
110 | + | case _ => | |
111 | + | 0 | |
112 | + | } | |
113 | + | let newAmount = (currentAmount + payment) | |
114 | + | let currentAssets = match getInteger(this, (keySumAssetsPrefix + currentKey)) { | |
115 | + | case a: Int => | |
116 | + | a | |
117 | + | case _ => | |
118 | + | 0 | |
119 | + | } | |
120 | + | let newAssets = (currentAssets + ((payment * assetDigits) / currentPrice)) | |
121 | + | let newAccountAssets = (accountAssets - ((payment * assetDigits) / currentPrice)) | |
122 | + | let newAccountAmount = (accountAmount + payment) | |
123 | + | WriteSet([DataEntry((keySumAmountPrefix + currentKey), newAmount), DataEntry((keySumAssetsPrefix + currentKey), newAssets), DataEntry(keyDistAssets, newAccountAssets), DataEntry(keyCollectedAmount, newAccountAmount)]) | |
124 | + | } | |
125 | + | } | |
126 | + | } | |
127 | + | } | |
128 | + | ||
129 | + | ||
130 | + | ||
131 | + | @Callable(i) | |
132 | + | func withdrawal () = { | |
133 | + | let isDAppAllow = match getInteger(accountThatAllowDApps, toString(this)) { | |
134 | + | case a: Int => | |
135 | + | a | |
136 | + | case _ => | |
137 | + | 0 | |
138 | + | } | |
139 | + | if ((isDAppAllow == 0)) | |
140 | + | then throw("Withdrawals are not available until the issuer passes verification") | |
141 | + | else { | |
142 | + | let currentKey = toBase58String(i.caller.bytes) | |
143 | + | let currentAssets = match getInteger(this, (keySumAssetsPrefix + currentKey)) { | |
144 | + | case a: Int => | |
145 | + | a | |
146 | + | case _ => | |
147 | + | 0 | |
148 | + | } | |
149 | + | let currentAmount = match getInteger(this, (keySumAmountPrefix + currentKey)) { | |
150 | + | case a: Int => | |
151 | + | a | |
152 | + | case _ => | |
153 | + | 0 | |
154 | + | } | |
155 | + | let accountAmount = match getInteger(this, keyCollectedAmount) { | |
156 | + | case a: Int => | |
157 | + | a | |
158 | + | case _ => | |
159 | + | 0 | |
160 | + | } | |
161 | + | let accountAssets = match getInteger(this, keyDistAssets) { | |
162 | + | case a: Int => | |
163 | + | a | |
164 | + | case _ => | |
165 | + | 0 | |
166 | + | } | |
167 | + | if (!(if ((height > endBlock)) | |
168 | + | then true | |
169 | + | else (accountAmount >= hardCapAmount))) | |
170 | + | then throw(("The Tokensale end on block " + toString(endBlock))) | |
171 | + | else if (if (if ((currentKey == ownerAddressString)) | |
172 | + | then (accountAmount >= softCapAmount) | |
173 | + | else false) | |
174 | + | then (isDAppAllow == 1) | |
175 | + | else false) | |
176 | + | then { | |
177 | + | let currentIssuerPaidAssets = match getInteger(this, keyIssuer) { | |
178 | + | case a: Int => | |
179 | + | a | |
180 | + | case _ => | |
181 | + | 0 | |
182 | + | } | |
183 | + | if ((currentIssuerPaidAssets == 0)) | |
184 | + | then ScriptResult(WriteSet([DataEntry(keyIssuer, (accountAssets + issuerAssets))]), TransferSet([ScriptTransfer(ownerAddress, (accountAssets + issuerAssets), issuerAssetId), ScriptTransfer(ownerAddress, accountAmount, investmentAssetId)])) | |
185 | + | else throw("The issuer has already taken its share!") | |
186 | + | } | |
187 | + | else if ((currentAmount == 0)) | |
188 | + | then throw("Don't have money") | |
189 | + | else if (if ((accountAmount >= softCapAmount)) | |
190 | + | then (isDAppAllow == 1) | |
191 | + | else false) | |
192 | + | then ScriptResult(WriteSet([DataEntry((keySumAmountPrefix + currentKey), 0), DataEntry((keySumAssetsPrefix + currentKey), 0)]), TransferSet([ScriptTransfer(i.caller, currentAssets, issuerAssetId)])) | |
193 | + | else ScriptResult(WriteSet([DataEntry((keySumAmountPrefix + currentKey), 0), DataEntry((keySumAssetsPrefix + currentKey), 0)]), TransferSet([ScriptTransfer(i.caller, currentAmount, investmentAssetId)])) | |
194 | + | } | |
195 | + | } | |
196 | + | ||
197 | + | ||
198 | + | @Verifier(tx) | |
199 | + | func verify () = match tx { | |
200 | + | case tx: SetScriptTransaction => | |
201 | + | sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
202 | + | case _ => | |
203 | + | false | |
204 | + | } | |
205 | + |
github/deemru/w8io/026f985 19.41 ms ◑