tx · 2pfyZveKrFgGSvKGhwsKPikVuwKTQgH5HDZYzYCedZFG 3MwzYUXjwakGySYHEL5SSixviLwxM1GWmuH: -0.01400000 Waves 2019.07.29 01:08 [606497] smart account 3MwzYUXjwakGySYHEL5SSixviLwxM1GWmuH > SELF 0.00000000 Waves
{ "type": 13, "id": "2pfyZveKrFgGSvKGhwsKPikVuwKTQgH5HDZYzYCedZFG", "fee": 1400000, "feeAssetId": null, "timestamp": 1564351757346, "version": 1, "sender": "3MwzYUXjwakGySYHEL5SSixviLwxM1GWmuH", "senderPublicKey": "HjEBeMSJiZoyPbam1wDoXNrGaYHALyd3YJKT87TWDXDc", "proofs": [ "2qjUd5Ryu2ueFpLZumCv7VcTQQZiaQHawsp2EsvBFTG7JhWM5aMSGJRzvxeGD2xuziVdG9KnqvWN14udetV4VzKR" ], "script": "base64:AAIDAAAAAAAAAAAAAAAWAAAAAA1jdXN0b21Bc3NldElkAQAAACBQ3oXtzD5L5zyt5Lq12socqpgpMeY2SmqOJYo1E7uwPgAAAAAOb3duZXJQdWJsaWNLZXkBAAAAIAxJTR5mCZ6irBTkArxC5blM0tAUZ862rc8mFnaibpwEAAAAAAxvd25lckFkZHJlc3MJAQAAABRhZGRyZXNzRnJvbVB1YmxpY0tleQAAAAEFAAAADm93bmVyUHVibGljS2V5AAAAABJvd25lckFkZHJlc3NTdHJpbmcCAAAAIzNONDhWYjQyY1dyZzJKaFpNd1JOU1Q4eUdjWFhLOXljSnVEAAAAABFhY2NvdW50VGhhdEFsbG93cwkBAAAAB0FkZHJlc3MAAAABAQAAABoBVMYbTDAWhUaVMk5pP6sw+hs730/Z1xCPOwAAAAALYXNzZXREaWdpdHMAAAAAAAX14QAAAAAAEHN1bUFjY291bnRBc3NldHMAAEcN5N+CAAAAAAAADGlzc3VlckFzc2V0cwAARw3k34IAAAAAAAAKc3RhcnRCbG9jawAAAAAAAAlBEgAAAAASaW5jcmVhc2VQcmljZUJsb2NrAAAAAAAACVEhAAAAAAhlbmRCb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1cnJlbnRLZXkAAAAAAAAAAAAJAARMAAAAAgkBAAAACURhdGFFbnRyeQAAAAIJAAEsAAAAAgUAAAASa2V5U3VtQXNzZXRzUHJlZml4BQAAAApjdXJyZW50S2V5AAAAAAAAAAAABQAAAANuaWwJAQAAAAtUcmFuc2ZlclNldAAAAAEJAARMAAAAAgkBAAAADlNjcmlwdFRyYW5zZmVyAAAAAwgFAAAAAWkAAAAGY2FsbGVyBQAAAA1jdXJyZW50QW1vdW50BQAAAAR1bml0BQAAAANuaWwAAAABAAAAAnR4AQAAAAZ2ZXJpZnkAAAAABAAAAAckbWF0Y2gwBQAAAAJ0eAfMVQv1", "chainId": 84, "height": 606497, "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'6SgR9smmBsh3tTBwzMLc1h34Lsdf8b1PZkyzBqQ987VP' | |
5 | + | ||
6 | + | let ownerPublicKey = base58'pxinK2hvfLJeZuiTgMyupYuzhooJXxjXMqWxnzfTsmu' | |
7 | + | ||
8 | + | let ownerAddress = addressFromPublicKey(ownerPublicKey) | |
9 | + | ||
10 | + | let ownerAddressString = "3N48Vb42cWrg2JhZMwRNST8yGcXXK9ycJuD" | |
11 | + | ||
12 | + | let accountThatAllows = Address(base58'3N7yaGaFS8BvgRrc9trhNy7v5H4qCcxW3Fp') | |
13 | + | ||
14 | + | let assetDigits = 100000000 | |
15 | + | ||
16 | + | let sumAccountAssets = 20000000000000000 | |
17 | + | ||
18 | + | let issuerAssets = 20000000000000000 | |
19 | + | ||
20 | + | let startBlock = 606482 | |
21 | + | ||
22 | + | let increasePriceBlock = 610593 | |
23 | + | ||
24 | + | let endBlock = 610593 | |
25 | + | ||
26 | + | let price = 1003 | |
27 | + | ||
28 | + | let priceSecond = 1003 | |
29 | + | ||
30 | + | let softCapAmount = 10000000000 | |
31 | + | ||
32 | + | let hardCapAmount = 200600000000 | |
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 23.60 ms ◑