tx · 2ob6pbEaQAuNa4tSLrhMhHbGJEbv7CAG1A9Jmya4CTK3 3N4fv2VWdvGnHRZfKyJrrECDKGAQjUC65Jy: -0.01400000 Waves 2019.07.05 08:20 [571768] smart account 3N4fv2VWdvGnHRZfKyJrrECDKGAQjUC65Jy > SELF 0.00000000 Waves
{ "type": 13, "id": "2ob6pbEaQAuNa4tSLrhMhHbGJEbv7CAG1A9Jmya4CTK3", "fee": 1400000, "feeAssetId": null, "timestamp": 1562304045906, "version": 1, "sender": "3N4fv2VWdvGnHRZfKyJrrECDKGAQjUC65Jy", "senderPublicKey": "FZXpRnwebrYEZfd7ntjjRqdwEFqFVFCTNZnt8drP4v18", "proofs": [ "3hEv42ZZ4D1M78G7GvY9vgZZEuHB5gbUhke515y1VvQKN6DjWad4xUpMxUtwGgSt5dFZgPA7tiqCCyu8MDwdh2MY" ], "script": "base64:AAIDAAAAAAAAAAAAAAAWAAAAAA1jdXN0b21Bc3NldElkAQAAACAN9GBcofIUXfoHk7nzbzI6+5GTHM+INtYw4NaZ7MShQgAAAAAOb3duZXJQdWJsaWNLZXkBAAAAIKyMZ2VHJNHrb9vH6vROBnnEQPrwl3Xlp6QC5G1Z45NCAAAAAAxvd25lckFkZHJlc3MJAQAAABRhZGRyZXNzRnJvbVB1YmxpY0tleQAAAAEFAAAADm93bmVyUHVibGljS2V5AAAAABJvd25lckFkZHJlc3NTdHJpbmcCAAAAIzNOOFl4dmlBVERXdXJRc1ZqQTJ6WWp2TDhCR0ZkS3VvREFqAAAAABFhY2NvdW50VGhhdEFsbG93cwkBAAAAB0FkZHJlc3MAAAABAQAAABoBVMYbTDAWhUaVMk5pP6sw+hs730/Z1xCPOwAAAAALYXNzZXREaWdpdHMAAAAAAAAPQkAAAAAAEHN1bUFjY291bnRBc3NldHMAAAAABklTTgAAAAAADGlzc3VlckFzc2V0cwAAAAAAAAAAAAAAAAAKc3RhcnRCbG9jawAAAAAAAAi5dwAAAAASaW5jcmVhc2VQcmljZUJsb2NrA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AAZjYWxsZXIFAAAADWN1cnJlbnRBc3NldHMFAAAADWN1c3RvbUFzc2V0SWQFAAAAA25pbAkBAAAADFNjcmlwdFJlc3VsdAAAAAIJAQAAAAhXcml0ZVNldAAAAAEJAARMAAAAAgkBAAAACURhdGFFbnRyeQAAAAIJAAEsAAAAAgUAAAASa2V5U3VtQW1vdW50UHJlZml4BQAAAApjdXJyZW50S2V5AAAAAAAAAAAACQAETAAAAAIJAQAAAAlEYXRhRW50cnkAAAACCQABLAAAAAIFAAAAEmtleVN1bUFzc2V0c1ByZWZpeAUAAAAKY3VycmVudEtleQAAAAAAAAAAAAUAAAADbmlsCQEAAAALVHJhbnNmZXJTZXQAAAABCQAETAAAAAIJAQAAAA5TY3JpcHRUcmFuc2ZlcgAAAAMIBQAAAAFpAAAABmNhbGxlcgUAAAANY3VycmVudEFtb3VudAUAAAAEdW5pdAUAAAADbmlsAAAAAQAAAAJ0eAEAAAAGdmVyaWZ5AAAAAAQAAAAHJG1hdGNoMAUAAAACdHgHvbRv/A==", "chainId": 84, "height": 571768, "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'wURp9psWx2dRJemd27nzWNTFR6nqKykdBgYmtWi9GVX' | |
5 | + | ||
6 | + | let ownerPublicKey = base58'CcZJHDz7ChhSV8HdJadwNZSjauMfVW5DcRGTzdM6nHWR' | |
7 | + | ||
8 | + | let ownerAddress = addressFromPublicKey(ownerPublicKey) | |
9 | + | ||
10 | + | let ownerAddressString = "3N8YxviATDWurQsVjA2zYjvL8BGFdKuoDAj" | |
11 | + | ||
12 | + | let accountThatAllows = Address(base58'3N7yaGaFS8BvgRrc9trhNy7v5H4qCcxW3Fp') | |
13 | + | ||
14 | + | let assetDigits = 1000000 | |
15 | + | ||
16 | + | let sumAccountAssets = 27000000000 | |
17 | + | ||
18 | + | let issuerAssets = 0 | |
19 | + | ||
20 | + | let startBlock = 571767 | |
21 | + | ||
22 | + | let increasePriceBlock = 592338 | |
23 | + | ||
24 | + | let endBlock = 592338 | |
25 | + | ||
26 | + | let price = 37040000 | |
27 | + | ||
28 | + | let priceSecond = 37040000 | |
29 | + | ||
30 | + | let softCapAmount = 200000000000 | |
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 | + | if ((currentPrice > payment)) | |
78 | + | then throw((("Minimum payment is " + toString(currentPrice)) + " wavelet")) | |
79 | + | else { | |
80 | + | let currentKey = toBase58String(i.caller.bytes) | |
81 | + | let isAccountAllow = match getBoolean(accountThatAllows, (keyAllowAccountPrefix + currentKey)) { | |
82 | + | case a: Boolean => | |
83 | + | a | |
84 | + | case _ => | |
85 | + | false | |
86 | + | } | |
87 | + | if ((isAccountAllow == false)) | |
88 | + | then throw("Your account has no right to send funds.") | |
89 | + | else { | |
90 | + | let accountAssets = match getInteger(this, keySumAccountAssets) { | |
91 | + | case a: Int => | |
92 | + | a | |
93 | + | case _ => | |
94 | + | sumAccountAssets | |
95 | + | } | |
96 | + | if ((0 > (accountAssets - ((payment * assetDigits) / currentPrice)))) | |
97 | + | then throw((("Payment is too big. Maximum possible payment is " + toString(((accountAssets * currentPrice) / assetDigits))) + " wavelet")) | |
98 | + | else { | |
99 | + | let currentAmount = match getInteger(this, (keySumAmountPrefix + currentKey)) { | |
100 | + | case a: Int => | |
101 | + | a | |
102 | + | case _ => | |
103 | + | 0 | |
104 | + | } | |
105 | + | let newAmount = (currentAmount + payment) | |
106 | + | let currentAssets = match getInteger(this, (keySumAssetsPrefix + currentKey)) { | |
107 | + | case a: Int => | |
108 | + | a | |
109 | + | case _ => | |
110 | + | 0 | |
111 | + | } | |
112 | + | let newAssets = (currentAssets + ((payment * assetDigits) / currentPrice)) | |
113 | + | let newAccountAssets = (accountAssets - ((payment * assetDigits) / currentPrice)) | |
114 | + | let newAccountAmount = (accountAmount + payment) | |
115 | + | WriteSet([DataEntry((keySumAmountPrefix + currentKey), newAmount), DataEntry((keySumAssetsPrefix + currentKey), newAssets), DataEntry(keySumAccountAssets, newAccountAssets), DataEntry(keySumWaves, newAccountAmount)]) | |
116 | + | } | |
117 | + | } | |
118 | + | } | |
119 | + | } | |
120 | + | } | |
121 | + | ||
122 | + | ||
123 | + | ||
124 | + | @Callable(i) | |
125 | + | func withdrawal () = { | |
126 | + | let currentKey = toBase58String(i.caller.bytes) | |
127 | + | let currentAssets = match getInteger(this, (keySumAssetsPrefix + currentKey)) { | |
128 | + | case a: Int => | |
129 | + | a | |
130 | + | case _ => | |
131 | + | 0 | |
132 | + | } | |
133 | + | let currentAmount = match getInteger(this, (keySumAmountPrefix + currentKey)) { | |
134 | + | case a: Int => | |
135 | + | a | |
136 | + | case _ => | |
137 | + | 0 | |
138 | + | } | |
139 | + | let accountAmount = match getInteger(this, keySumWaves) { | |
140 | + | case a: Int => | |
141 | + | a | |
142 | + | case _ => | |
143 | + | 0 | |
144 | + | } | |
145 | + | let accountAssets = match getInteger(this, keySumAccountAssets) { | |
146 | + | case a: Int => | |
147 | + | a | |
148 | + | case _ => | |
149 | + | 0 | |
150 | + | } | |
151 | + | if (!(if ((height > endBlock)) | |
152 | + | then true | |
153 | + | else (accountAmount >= hardCapAmount))) | |
154 | + | then throw(("The Tokensale end on block " + toString(endBlock))) | |
155 | + | else if (if ((currentKey == ownerAddressString)) | |
156 | + | then (accountAmount >= softCapAmount) | |
157 | + | else false) | |
158 | + | then { | |
159 | + | let currentIssuerPaidAssets = match getInteger(this, keyIssuer) { | |
160 | + | case a: Int => | |
161 | + | a | |
162 | + | case _ => | |
163 | + | 0 | |
164 | + | } | |
165 | + | if ((currentIssuerPaidAssets == 0)) | |
166 | + | then ScriptResult(WriteSet([DataEntry(keyIssuer, (accountAssets + issuerAssets))]), TransferSet([ScriptTransfer(ownerAddress, (accountAssets + issuerAssets), customAssetId), ScriptTransfer(ownerAddress, accountAmount, unit)])) | |
167 | + | else throw("The issuer has already taken its share!") | |
168 | + | } | |
169 | + | else if ((currentAmount == 0)) | |
170 | + | then throw("Don't have money") | |
171 | + | else if ((accountAmount >= softCapAmount)) | |
172 | + | then ScriptResult(WriteSet([DataEntry((keySumAmountPrefix + currentKey), 0), DataEntry((keySumAssetsPrefix + currentKey), 0)]), TransferSet([ScriptTransfer(i.caller, currentAssets, customAssetId)])) | |
173 | + | else ScriptResult(WriteSet([DataEntry((keySumAmountPrefix + currentKey), 0), DataEntry((keySumAssetsPrefix + currentKey), 0)]), TransferSet([ScriptTransfer(i.caller, currentAmount, unit)])) | |
174 | + | } | |
175 | + | ||
176 | + | ||
177 | + | @Verifier(tx) | |
178 | + | func verify () = match tx { | |
179 | + | case _ => | |
180 | + | false | |
181 | + | } | |
182 | + |
github/deemru/w8io/026f985 36.29 ms ◑