tx · bEaUTjyz7kijyugAKVpJe4dRaFijkwf2vwoUQ5R5AZs 3N85zfHFTdsLub6pgCFdKQf6GBYFg2MyzSx: -0.01400000 Waves 2019.08.06 15:52 [619070] smart account 3N85zfHFTdsLub6pgCFdKQf6GBYFg2MyzSx > SELF 0.00000000 Waves
{ "type": 13, "id": "bEaUTjyz7kijyugAKVpJe4dRaFijkwf2vwoUQ5R5AZs", "fee": 1400000, "feeAssetId": null, "timestamp": 1565095947747, "version": 1, "sender": "3N85zfHFTdsLub6pgCFdKQf6GBYFg2MyzSx", "senderPublicKey": "E9ZH32VRfUUMvV9MRxbZxn656zr8nfjefiCp5oPmdWij", "proofs": [ "4pnLhDT6tFQzt9KF79LeD1BekjCAdQ9bUMS9HpcW64qgy3xACUDLZ5TxWWXdATF2rpp2BouuVcFWanRT6FzEfmEC" ], "script": "base64:AAIDAAAAAAAAAAAAAAAWAAAAAA1jdXN0b21Bc3NldElkAQAAACDnkRMj/prznNxtXni6UKQcGyyl7w+5RXdrBHf6OXjqJgAAAAAOb3duZXJQdWJsaWNLZXkBAAAAIABchgMU2kkNK3o286aPu+WmDmToXn4Dy1aGZXozRw9BAAAAAAxvd25lckFkZHJlc3MJAQAAABRhZGRyZXNzRnJvbVB1YmxpY0tleQAAAAEFAAAADm93bmVyUHVibGljS2V5AAAAABJvd25lckFkZHJlc3NTdHJpbmcCAAAAIzNNcnhDOG5wbTdOOEZQSHJEeFNQcWFoTWI3dGFtZ0FBNWlaAAAAABFhY2NvdW50VGhhdEFsbG93cwkBAAAAB0FkZHJlc3MAAAABAQAAABoBVMYbTDAWhUaVMk5pP6sw+hs730/Z1xCPOwAAAAALYXNzZXREaWdpdHMAAAAAAAAPQkAAAAAAEHN1bUFjY291bnRBc3NldHMAAAAAAlQL5AAAAAAADGlzc3VlckFzc2V0cwAAAAAAAAAAAAAAAAAKc3RhcnRCbG9jawAAAAAAAAlyLgAAAAASaW5jcmVhc2VQcmljZUJsb2NrAAAAAAAACXo3AAAAAAh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AAAACmN1cnJlbnRLZXkAAAAAAAAAAAAJAARMAAAAAgkBAAAACURhdGFFbnRyeQAAAAIJAAEsAAAAAgUAAAASa2V5U3VtQXNzZXRzUHJlZml4BQAAAApjdXJyZW50S2V5AAAAAAAAAAAABQAAAANuaWwJAQAAAAtUcmFuc2ZlclNldAAAAAEJAARMAAAAAgkBAAAADlNjcmlwdFRyYW5zZmVyAAAAAwgFAAAAAWkAAAAGY2FsbGVyBQAAAA1jdXJyZW50QW1vdW50BQAAAAR1bml0BQAAAANuaWwAAAABAAAAAnR4AQAAAAZ2ZXJpZnkAAAAABAAAAAckbWF0Y2gwBQAAAAJ0eAe2lONS", "chainId": 84, "height": 619070, "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 customAssetId = base58'GawV1xWDaVTtwndwpsvgRFEL5je2BzxkykkyXa11EL6H' | |
5 | + | ||
6 | + | let ownerPublicKey = base58'12Qq3CKTABFKDNNSTxRDRt8EgFyqPMeSCotPApN4jBtk' | |
7 | + | ||
8 | + | let ownerAddress = addressFromPublicKey(ownerPublicKey) | |
9 | + | ||
10 | + | let ownerAddressString = "3MrxC8npm7N8FPHrDxSPqahMb7tamgAA5iZ" | |
11 | + | ||
12 | + | let accountThatAllows = Address(base58'3N7yaGaFS8BvgRrc9trhNy7v5H4qCcxW3Fp') | |
13 | + | ||
14 | + | let assetDigits = 1000000 | |
15 | + | ||
16 | + | let sumAccountAssets = 10000000000 | |
17 | + | ||
18 | + | let issuerAssets = 0 | |
19 | + | ||
20 | + | let startBlock = 619054 | |
21 | + | ||
22 | + | let increasePriceBlock = 621111 | |
23 | + | ||
24 | + | let endBlock = 621111 | |
25 | + | ||
26 | + | let price = 100000000 | |
27 | + | ||
28 | + | let priceSecond = 100000000 | |
29 | + | ||
30 | + | let softCapAmount = 1000000000000 | |
31 | + | ||
32 | + | let hardCapAmount = 1000000000000 | |
33 | + | ||
34 | + | let keySumAmountPrefix = "sumAmount " | |
35 | + | ||
36 | + | let keySumPaidAmountPrefix = "paidAmount " | |
37 | + | ||
38 | + | let keySumAssetsPrefix = "sumAssets " | |
39 | + | ||
40 | + | let keyAllowAccountPrefix = "allow " | |
41 | + | ||
42 | + | let keySumAccountAssets = "assets" | |
43 | + | ||
44 | + | let keySumWaves = "waves" | |
45 | + | ||
46 | + | let keyIssuer = "issuer" | |
47 | + | ||
48 | + | @Callable(i) | |
49 | + | func deposit () = { | |
50 | + | let currentPrice = if ((increasePriceBlock > height)) | |
51 | + | then price | |
52 | + | else priceSecond | |
53 | + | let accountAmount = match getInteger(this, keySumWaves) { | |
54 | + | case a: Int => | |
55 | + | a | |
56 | + | case _ => | |
57 | + | 0 | |
58 | + | } | |
59 | + | if ((startBlock > height)) | |
60 | + | then throw(((("The Tokensale works between " + toString(startBlock)) + " and ") + toString(endBlock))) | |
61 | + | else if (if ((height > endBlock)) | |
62 | + | then true | |
63 | + | else (accountAmount >= hardCapAmount)) | |
64 | + | then throw("The required amount has already been accumulated. If you are an investor, you can withdraw your funds.") | |
65 | + | else { | |
66 | + | let payment = match i.payment { | |
67 | + | case p: AttachedPayment => | |
68 | + | match p.assetId { | |
69 | + | case assetId: ByteVector => | |
70 | + | throw("Waves only") | |
71 | + | case _ => | |
72 | + | p.amount | |
73 | + | } | |
74 | + | case _ => | |
75 | + | throw("Payment must be attached") | |
76 | + | } | |
77 | + | let currentKey = toBase58String(i.caller.bytes) | |
78 | + | let isAccountAllow = match getBoolean(accountThatAllows, (keyAllowAccountPrefix + currentKey)) { | |
79 | + | case a: Boolean => | |
80 | + | a | |
81 | + | case _ => | |
82 | + | false | |
83 | + | } | |
84 | + | if ((isAccountAllow == false)) | |
85 | + | then throw("Your account has no right to send funds.") | |
86 | + | else { | |
87 | + | let accountAssets = match getInteger(this, keySumAccountAssets) { | |
88 | + | case a: Int => | |
89 | + | a | |
90 | + | case _ => | |
91 | + | sumAccountAssets | |
92 | + | } | |
93 | + | if ((0 > (accountAssets - ((payment * assetDigits) / currentPrice)))) | |
94 | + | then throw((("Payment is too big. Maximum possible payment is " + toString(((accountAssets * currentPrice) / assetDigits))) + " wavelet")) | |
95 | + | else { | |
96 | + | let currentAmount = match getInteger(this, (keySumAmountPrefix + currentKey)) { | |
97 | + | case a: Int => | |
98 | + | a | |
99 | + | case _ => | |
100 | + | 0 | |
101 | + | } | |
102 | + | let newAmount = (currentAmount + payment) | |
103 | + | let currentAssets = match getInteger(this, (keySumAssetsPrefix + currentKey)) { | |
104 | + | case a: Int => | |
105 | + | a | |
106 | + | case _ => | |
107 | + | 0 | |
108 | + | } | |
109 | + | let newAssets = (currentAssets + ((payment * assetDigits) / currentPrice)) | |
110 | + | let newAccountAssets = (accountAssets - ((payment * assetDigits) / currentPrice)) | |
111 | + | let newAccountAmount = (accountAmount + payment) | |
112 | + | WriteSet([DataEntry((keySumAmountPrefix + currentKey), newAmount), DataEntry((keySumAssetsPrefix + currentKey), newAssets), DataEntry(keySumAccountAssets, newAccountAssets), DataEntry(keySumWaves, newAccountAmount)]) | |
113 | + | } | |
114 | + | } | |
115 | + | } | |
116 | + | } | |
117 | + | ||
118 | + | ||
119 | + | ||
120 | + | @Callable(i) | |
121 | + | func withdrawal () = { | |
122 | + | let currentKey = toBase58String(i.caller.bytes) | |
123 | + | let currentAssets = match getInteger(this, (keySumAssetsPrefix + currentKey)) { | |
124 | + | case a: Int => | |
125 | + | a | |
126 | + | case _ => | |
127 | + | 0 | |
128 | + | } | |
129 | + | let currentAmount = match getInteger(this, (keySumAmountPrefix + currentKey)) { | |
130 | + | case a: Int => | |
131 | + | a | |
132 | + | case _ => | |
133 | + | 0 | |
134 | + | } | |
135 | + | let accountAmount = match getInteger(this, keySumWaves) { | |
136 | + | case a: Int => | |
137 | + | a | |
138 | + | case _ => | |
139 | + | 0 | |
140 | + | } | |
141 | + | let accountAssets = match getInteger(this, keySumAccountAssets) { | |
142 | + | case a: Int => | |
143 | + | a | |
144 | + | case _ => | |
145 | + | 0 | |
146 | + | } | |
147 | + | if (!(if ((height > endBlock)) | |
148 | + | then true | |
149 | + | else (accountAmount >= hardCapAmount))) | |
150 | + | then throw(("The Tokensale end on block " + toString(endBlock))) | |
151 | + | else if (if ((currentKey == ownerAddressString)) | |
152 | + | then (accountAmount >= softCapAmount) | |
153 | + | else false) | |
154 | + | then { | |
155 | + | let currentIssuerPaidAssets = match getInteger(this, keyIssuer) { | |
156 | + | case a: Int => | |
157 | + | a | |
158 | + | case _ => | |
159 | + | 0 | |
160 | + | } | |
161 | + | if ((currentIssuerPaidAssets == 0)) | |
162 | + | then ScriptResult(WriteSet([DataEntry(keyIssuer, (accountAssets + issuerAssets))]), TransferSet([ScriptTransfer(ownerAddress, (accountAssets + issuerAssets), customAssetId), ScriptTransfer(ownerAddress, accountAmount, unit)])) | |
163 | + | else throw("The issuer has already taken its share!") | |
164 | + | } | |
165 | + | else if ((currentAmount == 0)) | |
166 | + | then throw("Don't have money") | |
167 | + | else if ((accountAmount >= softCapAmount)) | |
168 | + | then ScriptResult(WriteSet([DataEntry((keySumAmountPrefix + currentKey), 0), DataEntry((keySumAssetsPrefix + currentKey), 0)]), TransferSet([ScriptTransfer(i.caller, currentAssets, customAssetId)])) | |
169 | + | else ScriptResult(WriteSet([DataEntry((keySumAmountPrefix + currentKey), 0), DataEntry((keySumAssetsPrefix + currentKey), 0)]), TransferSet([ScriptTransfer(i.caller, currentAmount, unit)])) | |
170 | + | } | |
171 | + | ||
172 | + | ||
173 | + | @Verifier(tx) | |
174 | + | func verify () = match tx { | |
175 | + | case _ => | |
176 | + | false | |
177 | + | } | |
178 | + |
github/deemru/w8io/026f985 19.51 ms ◑