UNPKG

47.9 kBMarkdownView Raw
1
2----------
3# Conflux
4
5A sdk of conflux.
6
7
8## Conflux.constructor
9
10
11
12### Parameters
13
14Name | Type | Required | Default | Description
15------------------------|-------------------------|----------|--------------------------|---------------------------------------------------------------
16options | object | false | | Conflux and Provider constructor options.
17options.url | string | false | '' | Url of provider to create.
18options.defaultEpoch | string,number | false | EpochNumber.LATEST_STATE | Default epochNumber.
19options.defaultGasPrice | string,number,BigNumber | false | | The default gas price in drip to use for transactions.
20options.defaultGas | string,number,BigNumber | false | | The default maximum gas provided for a transaction (gasLimit).
21
22### Return
23
24`void`
25
26### Example
27
28```
29> const Conflux = require('conflux-web'); > const cfx = new Conflux({url:'http://testnet-jsonrpc.conflux-chain.org:12537'});
30```
31
32```
33> const cfx = new Conflux({ url: 'http://localhost:8000', defaultGasPrice: 100, defaultGas: 100000, logger: console, });
34```
35
36## Conflux.setProvider
37
38Create and set `provider`.
39
40### Parameters
41
42Name | Type | Required | Default | Description
43--------|--------|----------|---------|------------------------------
44url | string | true | | Url of provider to create.
45options | object | false | | Provider constructor options.
46
47### Return
48
49`Object`
50
51### Example
52
53```
54> cfx.provider;
55 HttpProvider {
56 url: 'http://testnet-jsonrpc.conflux-chain.org:12537',
57 timeout: 60000,
58 ...
59 } > cfx.setProvider('http://localhost:8000'); > cfx.provider;
60 HttpProvider {
61 url: 'http://localhost:8000',
62 timeout: 60000,
63 ...
64 }
65```
66
67## Conflux.Contract
68
69A shout cut for `new Contract(cfx, options);`
70
71### Parameters
72
73Name | Type | Required | Default | Description
74--------|--------|----------|---------|---------------------------
75options | object | true | | See `Contract.constructor`
76
77### Return
78
79`Contract`
80
81
82## Conflux.close
83
84close connection.
85
86### Parameters
87
88`void`
89
90### Return
91
92`void`
93
94### Example
95
96```
97> cfx.close();
98```
99
100## Conflux.getGasPrice
101
102Returns the current gas price oracle. The gas price is determined by the last few blocks median gas price.
103
104### Parameters
105
106`void`
107
108### Return
109
110`Promise.<BigNumber>` Gas price in drip.
111
112### Example
113
114```
115> await cfx.getGasPrice();
116 "0"
117```
118
119## Conflux.getEpochNumber
120
121Returns the current epochNumber the client is on.
122
123### Parameters
124
125Name | Type | Required | Default | Description
126------------|---------------|----------|---------|-----------------------------------------
127epochNumber | string,number | false | | The end epochNumber to count balance of.
128
129### Return
130
131`Promise.<number>` EpochNumber
132
133### Example
134
135```
136> await cfx.getEpochNumber();
137 200109
138```
139
140## Conflux.getLogs
141
142Gets past logs, matching the given options.
143
144### Parameters
145
146Name | Type | Required | Default | Description
147--------------------|-----------------------|----------|---------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
148options | object | false | |
149options.fromEpoch | string,number | false | | The number of the start block. (>=)
150options.toEpoch | string,number | false | | The number of the stop block.(<=)
151options.blockHashes | Array.<string> | false | | The block hash list
152options.address | string,Array.<string> | false | | An address or a list of addresses to only get logs from particular account(s).
153options.topics | array | false | | An array of values which must each appear in the log entries. The order is important, if you want to leave topics out use null, e.g. [null, '0x12...']. You can also pass an array for each topic with options for that topic e.g. [null, ['option1', 'option2']]
154options.limit | number | false | | Limit log number.
155
156### Return
157
158`Promise.<LogIterator>` Array of log objects.
159- `string` address: Address this event originated from.
160- `string[]` topics: An array with max 4 32 Byte topics, topic 1-3 contains indexed parameters of the event.
161- `string` data: The data containing non-indexed log parameter.
162- `string` type: TODO
163- `boolean` removed: TODO
164- `number` epochNumber: The epochNumber this log was created in. null when still pending.
165- `string` blockHash: Hash of the block this event was created in. null when it’s still pending.
166- `string` transactionHash: Hash of the transaction this event was created in.
167- `string` transactionIndex: Integer of the transaction’s index position the event was created in.
168- `number` logIndex: Integer of the event index position in the block.
169- `number` transactionLogIndex: Integer of the event index position in the transaction.
170
171### Example
172
173```
174> await cfx.getLogs({
175 address: '0xbd72de06cd4a94ad31ed9303cf32a2bccb82c404',
176 fromEpoch: 0,
177 toEpoch: 'latest_mined',
178 limit: 1,
179 topics: [
180 '0xb818399ffd68e821c34de8d5fbc5aeda8456fdb9296fc1b02bf6245ade7ebbd4',
181 '0x0000000000000000000000001ead8630345121d19ee3604128e5dc54b36e8ea6'
182 ]
183 });
184
185 [
186 {
187 address: '0xbd72de06cd4a94ad31ed9303cf32a2bccb82c404',
188 blockHash: '0x701afee0ffc49aaebadf0e6618b6ec1715d31e7aa639e2e00dc8df10994e0283',
189 data: '0x',
190 epochNumber: 542556,
191 logIndex: 0,
192 removed: false,
193 topics: [
194 '0xb818399ffd68e821c34de8d5fbc5aeda8456fdb9296fc1b02bf6245ade7ebbd4',
195 '0x0000000000000000000000001ead8630345121d19ee3604128e5dc54b36e8ea6'
196 ],
197 transactionHash: '0x5a301d2c342709d7de9da24bd096ab3754ea328b016d85ab3410d375616f5d0d',
198 transactionIndex: 0,
199 transactionLogIndex: 0,
200 type: 'mined'
201 },
202 ]
203```
204
205```
206> logIter = cfx.getLogs({
207 address: '0xbd72de06cd4a94ad31ed9303cf32a2bccb82c404',
208 fromEpoch: 'latest_mined',
209 limit: 2,
210 }) > await logIter.next({threshold: 0.01, delta: 1000});
211 {
212 address: '0xbd72de06cd4a94ad31ed9303cf32a2bccb82c404',
213 ...
214 } > await logIter.next();
215 {
216 address: '0xbd72de06cd4a94ad31ed9303cf32a2bccb82c404',
217 ...
218 } > await logIter.next();
219 undefined
220```
221
222```
223> logIter = cfx.getLogs({
224 address: '0xbd72de06cd4a94ad31ed9303cf32a2bccb82c404',
225 fromEpoch: 'latest_mined',
226 limit: 2,
227 }) > for await (const log of iter) {
228 console.log(log);
229 }
230 {
231 address: '0xbd72de06cd4a94ad31ed9303cf32a2bccb82c404',
232 ...
233 }
234 ...
235```
236
237## Conflux.getBalance
238
239Get the balance of an address at a given epochNumber.
240
241### Parameters
242
243Name | Type | Required | Default | Description
244------------|---------------|----------|-------------------|-----------------------------------------
245address | string | true | | The address to get the balance of.
246epochNumber | string,number | false | this.defaultEpoch | The end epochNumber to count balance of.
247
248### Return
249
250`Promise.<BigNumber>` Address balance number in drip.
251
252### Example
253
254```
255> let balance = await cfx.getBalance("0xbbd9e9be525ab967e633bcdaeac8bd5723ed4d6b"); > balance;
256 BigNumber { s: 1, e: 18, c: [ 17936, 36034970586632 ] } > Drip.toCFX(balance).toString(10);
257 1.793636034970586632 > balance = await cfx.getBalance("0xbbd9e9be525ab967e633bcdaeac8bd5723ed4d6b", 0); > balance.toString(10);
258 0
259```
260
261## Conflux.getTransactionCount
262
263Get the numbers of transactions sent from this address.
264
265### Parameters
266
267Name | Type | Required | Default | Description
268------------|---------------|----------|-------------------|-----------------------------------------------------
269address | string | true | | The address to get the numbers of transactions from.
270epochNumber | string,number | false | this.defaultEpoch | The end epochNumber to count transaction of.
271
272### Return
273
274`Promise.<number>`
275
276### Example
277
278```
279> await cfx.getTransactionCount("0xbbd9e9be525ab967e633bcdaeac8bd5723ed4d6b");
280 61 > await cfx.getTransactionCount("0xbbd9e9be525ab967e633bcdaeac8bd5723ed4d6b", 0);
281 0
282```
283
284## Conflux.getBlockByEpochNumber
285
286Get the epochNumber pivot block info.
287
288### Parameters
289
290Name | Type | Required | Default | Description
291------------|---------------|----------|---------|--------------------------------------------------------------
292epochNumber | string,number | true | | EpochNumber or string in ["latest_state", "latest_mined"]
293detail | boolean | false | false | `true` return transaction object, `false` return TxHash array
294
295### Return
296
297`Promise.<(object|null)>` The block info (same as `getBlockByHash`).
298
299### Example
300
301```
302> await cfx.getBlockByEpochNumber(449);
303 {
304 hash: '0x59339ff28bc235cceac9fa588ebafcbf61316e6a8c86c7a1d7239b9445d98e40',
305 ...
306 }
307```
308
309## Conflux.getBlocksByEpochNumber
310
311Get block hash array of a epochNumber.
312
313### Parameters
314
315Name | Type | Required | Default | Description
316------------|---------------|----------|---------|----------------------------------------------------------
317epochNumber | string,number | true | | EpochNumber or string in ["latest_state", "latest_mined"]
318
319### Return
320
321`Promise.<Array.<string>>` Block hash array, last one is the pivot block hash of this epochNumber.
322
323### Example
324
325```
326> await cfx.getBlocksByEpochNumber(0);
327 ['0x2da120ad267319c181b12136f9e36be9fba59e0d818f6cc789f04ee937b4f593'] > await cfx.getBlocksByEpochNumber(449);
328 [
329 '0x3d8b71208f81fb823f4eec5eaf2b0ec6b1457d381615eff2fbe24605ea333c39',
330 '0x59339ff28bc235cceac9fa588ebafcbf61316e6a8c86c7a1d7239b9445d98e40'
331 ]
332```
333
334## Conflux.getBestBlockHash
335
336> TODO
337
338### Parameters
339
340`void`
341
342### Return
343
344`Promise.<string>`
345
346### Example
347
348```
349> await cfx.getBestBlockHash();
350 "0x43ddda130fff8539b9f3c431aa1b48e021b3744aacd224cbd4bcdb64373f3dd5"
351```
352
353## Conflux.getBlockByHash
354
355Returns a block matching the block hash.
356
357### Parameters
358
359Name | Type | Required | Default | Description
360----------|---------|----------|---------|--------------------------------------------------------------
361blockHash | string | true | | The hash of block to be get.
362detail | boolean | false | false | `true` return transaction object, `false` return TxHash array
363
364### Return
365
366`Promise.<(object|null)>` Block info object.
367- `string` miner: The address of the beneficiary to whom the mining rewards were given.
368- `string|null` hash: Hash of the block. `null` when its pending block.
369- `string` parentHash: Hash of the parent block.
370- `string[]` refereeHashes: Array of referee hashes.
371- `number|null` epochNumber: The current block epochNumber in the client's view. `null` when it's not in best block's past set.
372- `boolean|null` stable: If the block stable or not. `null` for pending stable.
373- `string` nonce: Hash of the generated proof-of-work. `null` when its pending block.
374- `number` gas: The maximum gas allowed in this block.
375- `string` difficulty: Integer string of the difficulty for this block.
376- `number` height: The block heights. `null` when its pending block.
377- `number` size: Integer the size of this block in bytes.
378- `number` blame: 0 if there's nothing to blame; k if the block is blaming on the state info of its k-th ancestor.
379- `boolean` adaptive: If the block's weight adaptive or not.
380- `number` timestamp: The unix timestamp for when the block was collated.
381- `string` transactionsRoot: The hash of the transactions of the block.
382- `string[]` transactions: Array of transaction objects, or 32 Bytes transaction hashes depending on the last given parameter.
383- `string` deferredLogsBloomHash: The hash of the deferred block's log bloom filter
384- `string` deferredReceiptsRoot: The hash of the receipts of the block after deferred execution.
385- `string` deferredStateRoot: The root of the final state trie of the block after deferred execution.
386- `object` deferredStateRootWithAux: Information of deferred state root
387
388### Example
389
390```
391> await cfx.getBlockByHash('0x59339ff28bc235cceac9fa588ebafcbf61316e6a8c86c7a1d7239b9445d98e40');
392 {
393 "miner": "0x0000000000000000000000000000000000000015",
394 "hash": "0x59339ff28bc235cceac9fa588ebafcbf61316e6a8c86c7a1d7239b9445d98e40",
395 "parentHash": "0xe75f82d86f51cdab5a2ed7b4e225c714d1fda7e0aa568c6b4618015ee6666506",
396 "refereeHashes": [
397 "0x3d8b71208f81fb823f4eec5eaf2b0ec6b1457d381615eff2fbe24605ea333c39"
398 ],
399 "epochNumber": 449,
400 "stable": null,
401 "nonce": 17364797680136698000,
402 "gas": 3000000000,
403 "difficulty": "20000000",
404 "height": 449,
405 "size": 384,
406 "blame": 0,
407 "adaptive": false,
408 "timestamp": 1571150247,
409 "transactionsRoot": "0x2b8f5e08ca12eb66ae89f40a6b52938222ce835f0b786cae0befdbbecd8b55e1"
410 "transactions": [
411 "0xbe007c3eca92d01f3917f33ae983f40681182cf618defe75f490a65aac016914"
412 ],
413 "deferredLogsBloomHash": "0xd397b3b043d87fcd6fad1291ff0bfd16401c274896d8c63a923727f077b8e0b5",
414 "deferredReceiptsRoot": "0x522717233b96e0a03d85f02f8127aa0e23ef2e0865c95bb7ac577ee3754875e4",
415 "deferredStateRoot": "0x39975f9bf46884e7c3c269577177af9a041c5e36a69ef2a4cf581f8a061fa911",
416 "deferredStateRootWithAux": {
417 "auxInfo": {
418 "intermediateDeltaEpochId": "0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470",
419 "previousSnapshotRoot": "0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470"
420 },
421 "stateRoot": {
422 "deltaRoot": "0x752a3f391da1a584812a9f50ec92542abda59c3cc0ad49741461471680cf1528",
423 "intermediateDeltaRoot": "0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470",
424 "snapshotRoot": "0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470"
425 }
426 },
427 }
428```
429
430```
431> await cfx.getBlockByHash('0x59339ff28bc235cceac9fa588ebafcbf61316e6a8c86c7a1d7239b9445d98e40', true);
432 {
433 "hash": "0x59339ff28bc235cceac9fa588ebafcbf61316e6a8c86c7a1d7239b9445d98e40",
434 "transactions": [
435 {
436 "blockHash": "0x59339ff28bc235cceac9fa588ebafcbf61316e6a8c86c7a1d7239b9445d98e40",
437 "transactionIndex": 0,
438 "hash": "0xbe007c3eca92d01f3917f33ae983f40681182cf618defe75f490a65aac016914",
439 "nonce": 0,
440 "from": "0xa70ddf9b9750c575db453eea6a041f4c8536785a",
441 "to": "0x63f0a574987f6893e068a08a3fb0e63aec3785e6",
442 "value": "1000000000000000000"
443 "data": "0x",
444 "gas": 21000,
445 "gasPrice": "819",
446 "status": 0,
447 "contractCreated": null,
448 "r": "0x88e43a02a653d5895ffa5495718a5bd772cb157776108c5c22cee9beff890650",
449 "s": "0x24e3ba1bb0d11c8b1da8d969ecd0c5e2372326a3de71ba1231c876c0efb2c0a8",
450 "v": 0,
451 }
452 ],
453 ...
454 }
455```
456
457## Conflux.getBlockByHashWithPivotAssumption
458
459Get block by `blockHash` if pivot block of `epochNumber` is `pivotBlockHash`.
460
461### Parameters
462
463Name | Type | Required | Default | Description
464---------------|--------|----------|---------|----------------------------------------------------------------
465blockHash | string | true | | Block hash which epochNumber expect to be `epochNumber`.
466pivotBlockHash | string | true | | Block hash which expect to be the pivot block of `epochNumber`.
467epochNumber | number | true | | EpochNumber or string in ["latest_state", "latest_mined"]
468
469### Return
470
471`Promise.<object>` The block info (same as `getBlockByHash`).
472
473### Example
474
475```
476> await cfx.getBlockByHashWithPivotAssumption( '0x3d8b71208f81fb823f4eec5eaf2b0ec6b1457d381615eff2fbe24605ea333c39', '0x59339ff28bc235cceac9fa588ebafcbf61316e6a8c86c7a1d7239b9445d98e40' 449, );
477 {
478 hash: '0x3d8b71208f81fb823f4eec5eaf2b0ec6b1457d381615eff2fbe24605ea333c39',
479 ...
480 }
481```
482
483## Conflux.getTransactionByHash
484
485Returns a transaction matching the given transaction hash.
486
487### Parameters
488
489Name | Type | Required | Default | Description
490-------|--------|----------|---------|----------------------
491txHash | string | true | | The transaction hash.
492
493### Return
494
495`Promise.<(object|null)>` Transaction info object
496- `string` blockHash: Hash of the block where this transaction was in and got executed. `null` when its pending.
497- `number` transactionIndex: Integer of the transactions index position in the block.
498- `string` hash: Hash of the transaction.
499- `number` nonce: The number of transactions made by the sender prior to this one.
500- `string` from: Address of the sender.
501- `string` to: Address of the receiver. null when its a contract creation transaction.
502- `string` value: Value transferred in Drip.
503- `string` data: The data send along with the transaction.
504- `number` gas: Gas provided by the sender.
505- `number` gasPrice: Gas price provided by the sender in Drip.
506- `string` status: '0x0' successful execution; '0x1' exception happened but nonce still increased; '0x2' exception happened and nonce didn't increase.
507- `string|null` contractCreated: The contract address created, if the transaction was a contract creation, otherwise null.
508- `string` r: ECDSA signature r
509- `string` s: ECDSA signature s
510- `string` v: ECDSA recovery id
511
512### Example
513
514```
515> await cfx.getTransactionByHash('0xbe007c3eca92d01f3917f33ae983f40681182cf618defe75f490a65aac016914');
516 {
517 "blockHash": "0x59339ff28bc235cceac9fa588ebafcbf61316e6a8c86c7a1d7239b9445d98e40",
518 "transactionIndex": 0,
519 "hash": "0xbe007c3eca92d01f3917f33ae983f40681182cf618defe75f490a65aac016914",
520 "nonce": 0,
521 "from": "0xa70ddf9b9750c575db453eea6a041f4c8536785a",
522 "to": "0x63f0a574987f6893e068a08a3fb0e63aec3785e6",
523 "value": "1000000000000000000"
524 "data": "0x",
525 "gas": 21000,
526 "gasPrice": "819",
527 "status": 0,
528 "contractCreated": null,
529 "r": "0x88e43a02a653d5895ffa5495718a5bd772cb157776108c5c22cee9beff890650",
530 "s": "0x24e3ba1bb0d11c8b1da8d969ecd0c5e2372326a3de71ba1231c876c0efb2c0a8",
531 "v": 0,
532 }
533```
534
535## Conflux.getTransactionReceipt
536
537Returns the receipt of a transaction by transaction hash.
538
539> Note: The receipt is not available for pending transactions and returns null.
540
541### Parameters
542
543Name | Type | Required | Default | Description
544-------|--------|----------|---------|----------------------
545txHash | string | true | | The transaction hash.
546
547### Return
548
549`Promise.<(object|null)>` - `number` outcomeStatus: `0`: the transaction was successful, `1`: EVM reverted the transaction.
550- `string` stateRoot: The state root of transaction execution.
551- `number` epochNumber: EpochNumber where this transaction was in.
552- `string` blockHash: Hash of the block where this transaction was in.
553- `string` transactionHash: Hash of the transaction.
554- `number` index: Integer of the transactions index position in the block.
555- `string` from: Address of the sender.
556- `string` to: Address of the receiver. null when its a contract creation transaction.
557- `string|null` contractCreated: The contract address created, if the transaction was a contract creation, otherwise null.
558- `number` gasUsed: The amount of gas used by this specific transaction alone.
559- `[object]` logs: Array of log objects, which this transaction generated.
560- `[string]` logs[].address: The address of the contract executing at the point of the `LOG` operation.
561- `[string]` logs[].topics: The topics associated with the `LOG` operation.
562- `[string]` logs[].data: The data associated with the `LOG` operation.
563- `string` logsBloom: Log bloom.
564
565### Example
566
567```
568> await cfx.getTransactionReceipt('0xbe007c3eca92d01f3917f33ae983f40681182cf618defe75f490a65aac016914');
569 {
570 "outcomeStatus": 0,
571 "stateRoot": "0x3854f64be6c124dffd0ddca57270846f0f43a119ea681b4e5d022ade537d9f07",
572 "epochNumber": 449,
573 "blockHash": "0x59339ff28bc235cceac9fa588ebafcbf61316e6a8c86c7a1d7239b9445d98e40",
574 "transactionHash": "0xbe007c3eca92d01f3917f33ae983f40681182cf618defe75f490a65aac016914"
575 "index": 0,
576 "from": "0xa70ddf9b9750c575db453eea6a041f4c8536785a",
577 "to": "0x63f0a574987f6893e068a08a3fb0e63aec3785e6",
578 "contractCreated": null,
579 "gasUsed": 21000,
580 "logs": [],
581 "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
582 }
583```
584
585## Conflux.sendTransaction
586
587Creates new message call transaction or a contract creation, if the data field contains code.
588
589> FIXME: rpc `cfx_sendTransaction` not implement yet.
590
591> NOTE: if `from` options is a instance of `Account`, this methods will sign by account local and send by `cfx_sendRawTransaction`, else send by `cfx_sendTransaction`
592
593### Parameters
594
595Name | Type | Required | Default | Description
596--------|--------|----------|---------|------------------------------
597options | object | true | | See `Transaction.callOptions`
598
599### Return
600
601`Promise.<PendingTransaction>` The PendingTransaction object.
602
603### Example
604
605```
606> // TODO call with address, need `cfx_sendTransaction`
607```
608
609```
610> const account = cfx.wallet.add(KEY); > await cfx.sendTransaction({
611 from: account, // from account instance will sign by local.
612 to: ADDRESS,
613 value: Drip.fromCFX(0.023),
614 });
615 "0x459473cb019bb59b935abf5d6e76d66564aafa313efd3e337b4e1fa6bd022cc9"
616```
617
618```
619> await cfx.sendTransaction({
620 from: account,
621 to: account, // to account instance
622 value: Drip.fromCFX(0.03),
623 }).get(); // send then get transaction by hash.
624 {
625 "blockHash": null,
626 "transactionIndex": null,
627 "hash": "0xf2b258b49d33dd22419526e168ebb79b822889cf8317ce1796e816cce79e49a2",
628 "contractCreated": null,
629 "data": "0x",
630 "from": "0xbbd9e9be525ab967e633bcdaeac8bd5723ed4d6b",
631 "nonce": 111,
632 "status": null,
633 "to": "0xbbd9e9be525ab967e633bcdaeac8bd5723ed4d6b",
634 "value": "30000000000000000",
635 ...
636 }
637```
638
639```
640> const promise = cfx.sendTransaction({ // Not await here, just get promise
641 from: account1,
642 to: ADDRESS1,
643 value: Drip.fromCFX(0.007),
644 }); > await promise; // transaction
645 "0x91fbdfb33f3a585f932c627abbe268c7e3aedffc1633f9338f9779c64702c688" > await promise.get(); // get transaction
646 {
647 "blockHash": null,
648 "transactionIndex": null,
649 "hash": "0x91fbdfb33f3a585f932c627abbe268c7e3aedffc1633f9338f9779c64702c688",
650 ...
651 } > await promise.mined(); // wait till transaction mined
652 {
653 "blockHash": "0xe9b22ce311003e26c7330ac54eea9f8afea0ffcd4905828f27c9e2c02f3a00f7",
654 "transactionIndex": 0,
655 "hash": "0x91fbdfb33f3a585f932c627abbe268c7e3aedffc1633f9338f9779c64702c688",
656 ...
657 } > await promise.executed(); // wait till transaction executed in right status. and return it's receipt.
658 {
659 "blockHash": "0xe9b22ce311003e26c7330ac54eea9f8afea0ffcd4905828f27c9e2c02f3a00f7",
660 "index": 0,
661 "transactionHash": "0x91fbdfb33f3a585f932c627abbe268c7e3aedffc1633f9338f9779c64702c688",
662 "outcomeStatus": 0,
663 ...
664 } > await promise.confirmed(); // wait till transaction risk coefficient '<' threshold.
665 {
666 "blockHash": "0xe9b22ce311003e26c7330ac54eea9f8afea0ffcd4905828f27c9e2c02f3a00f7",
667 "index": 0,
668 "transactionHash": "0x91fbdfb33f3a585f932c627abbe268c7e3aedffc1633f9338f9779c64702c688",
669 "outcomeStatus": 0,
670 ...
671 }
672```
673
674## Conflux.sendRawTransaction
675
676Signs a transaction. This account needs to be unlocked.
677
678### Parameters
679
680Name | Type | Required | Default | Description
681-----|---------------|----------|---------|------------------------
682hex | string,Buffer | true | | Raw transaction string.
683
684### Return
685
686`Promise.<PendingTransaction>` The PendingTransaction object. See `sendTransaction`
687
688### Example
689
690```
691> await cfx.sendRawTransaction('0xf85f800382520894bbd9e9b...');
692 "0xbe007c3eca92d01f3917f33ae983f40681182cf618defe75f490a65aac016914"
693```
694
695## Conflux.getCode
696
697Get the code at a specific address.
698
699### Parameters
700
701Name | Type | Required | Default | Description
702------------|---------------|----------|-------------------|----------------------------------------------------------
703address | string | true | | The contract address to get the code from.
704epochNumber | string,number | false | this.defaultEpoch | EpochNumber or string in ["latest_state", "latest_mined"]
705
706### Return
707
708`Promise.<string>` Code hex string
709
710### Example
711
712```
713> await cfx.getCode('0xb385b84f08161f92a195953b980c8939679e906a');
714 "0x6080604052348015600f57600080fd5b506004361060325760003560e01c806306661abd1460375780638..."
715```
716
717## Conflux.call
718
719Executes a message call transaction, which is directly executed in the VM of the node,
720but never mined into the block chain.
721
722### Parameters
723
724Name | Type | Required | Default | Description
725------------|---------------|----------|-------------------|----------------------------------------
726options | object | true | | See `Transaction.callOptions`
727epochNumber | string,number | false | this.defaultEpoch | The end epochNumber to execute call of.
728
729### Return
730
731`Promise.<string>` Hex bytes the contract method return.
732
733
734## Conflux.estimateGas
735
736Executes a message call or transaction and returns the amount of the gas used.
737
738### Parameters
739
740Name | Type | Required | Default | Description
741--------|--------|----------|---------|------------------------------
742options | object | true | | See `Transaction.callOptions`
743
744### Return
745
746`Promise.<BigNumber>` The used gas for the simulated call/transaction.
747
748
749----------
750# contract.Contract
751
752Contract with all its methods and events defined in its abi.
753
754
755## Contract.constructor
756
757
758
759### Parameters
760
761Name | Type | Required | Default | Description
762----------------|---------|----------|---------|-----------------------------------------------------------------------------------------------------
763cfx | Conflux | true | | Conflux instance.
764options | object | true | |
765options.abi | array | true | | The json interface for the contract to instantiate
766options.address | string | false | | The address of the smart contract to call, can be added later using `contract.address = '0x1234...'`
767options.code | string | false | | The byte code of the contract, can be added later using `contract.constructor.code = '0x1234...'`
768
769### Return
770
771`object`
772
773### Example
774
775```
776> const contract = cfx.Contract({ abi, code }); > contract instanceof Contract;
777 true > contract.abi; // input abi
778 [{type:'constructor', inputs:[...]}, ...] > contract.constructor.code; // input code
779 "0x6080604052600080..." // deploy a contract by send constructor then wait and get contract address by `PendingTransaction.deployed` trick. > await contract.constructor(100).sendTransaction({ from: account }).deployed();
780 "0xc3ed1a06471be1d3bcd014051fbe078387ec0ad8"
781```
782
783```
784> const contract = cfx.Contract({ abi, address }); > contract.address
785 "0xc3ed1a06471be1d3bcd014051fbe078387ec0ad8" > await contract.count(); // call a method without parameter, get decoded return value.
786 BigNumber { _hex: '0x64' } > await contract.inc(1); // call a method with parameters, get decoded return value.
787 BigNumber { _hex: '0x65' } > await contract.count().call({ from: account }); // call a method from a account.
788 BigNumber { _hex: '0x64' } > await contract.count().estimateGas();
789 21655 > await contract.count().estimateGas({ from: ADDRESS, nonce: 68 }); // if from is a address string, nonce is required
790 21655 // send transaction from account instance, then wait till confirmed, and get receipt. > await contract.inc(1)
791 .sendTransaction({ from: account1 })
792 .confirmed({ threshold: 0.01, timeout: 30 * 1000 });
793 {
794 "blockHash": "0xba948c8925f6d7f14faf540c3b9e6d24d33c78168b2dd81a6021a50949d9f0d7",
795 "index": 0,
796 "transactionHash": "0x8a5f48c2de0f1bdacfe90443810ad650e4b327a0d19ce49a53faffb224883e42",
797 "outcomeStatus": 0,
798 ...
799 } > tx = await cfx.getTransactionByHash('0x8a5f48c2de0f1bdacfe90443810ad650e4b327a0d19ce49a53faffb224883e42'); > await contract.abi.decodeData(tx.data)
800 {
801 name: 'inc',
802 params: [BigNumber{0x01}]
803 } > await contract.count(); // data in block chain changed by transaction.
804 BigNumber { _hex: '0x65' } > logs = await contract.SelfEvent(account1.address).getLogs()
805 [
806 {
807 address: '0xc3ed1a06471be1d3bcd014051fbe078387ec0ad8',
808 blockHash: '0xc8cb678891d4914aa66670e3ebd7a977bb3e38d2cdb1e2df4c0556cb2c4715a4',
809 data: '0x000000000000000000000000000000000000000000000000000000000000000a',
810 epochNumber: 545896,
811 logIndex: 0,
812 removed: false,
813 topics: [
814 '0xc4c01f6de493c58245fb681341f3a76bba9551ce81b11cbbb5d6d297844594df',
815 '0x000000000000000000000000bbd9e9be525ab967e633bcdaeac8bd5723ed4d6b'
816 ],
817 transactionHash: '0x9100f4f84f711aa358e140197e9d2e5aab1f99751bc26a660d324a8282fc54d0',
818 transactionIndex: 0,
819 transactionLogIndex: 0,
820 type: 'mined',
821 params: [ '0xbbd9e9be525ab967e633bcdaeac8bd5723ed4d6b', '10' ]
822 }
823 ] > contract.abi.decodeLog(logs[0]);
824 {
825 name: "SelfEvent",
826 params: [
827 '0xbbd9e9be525ab967e633bcdaeac8bd5723ed4d6b',
828 BigNumber{0x64},
829 ]
830 }
831```
832
833----------
834# provider.HttpProvider
835
836Http protocol json rpc provider.
837
838
839## HttpProvider.constructor
840
841
842
843### Parameters
844
845Name | Type | Required | Default | Description
846--------|--------|----------|---------|-------------------------------
847url | string | true | | Full json rpc http url
848options | object | false | | See `BaseProvider.constructor`
849
850### Return
851
852`HttpProvider`
853
854### Example
855
856```
857> const provider = new HttpProvider('http://testnet-jsonrpc.conflux-chain.org:12537', {logger: console});
858```
859
860## HttpProvider.call
861
862Call a json rpc method with params
863
864### Parameters
865
866Name | Type | Required | Default | Description
867----------|--------|----------|---------|------------------------
868method | string | true | | Json rpc method name.
869...params | array | false | | Json rpc method params.
870
871### Return
872
873`Promise.<*>` Json rpc method return value.
874
875### Example
876
877```
878> await provider.call('cfx_epochNumber'); > await provider.call('cfx_getBlockByHash', blockHash);
879```
880
881----------
882# Transaction
883
884
885
886
887## Transaction.constructor
888
889Signs a transaction. This account needs to be unlocked.
890
891### Parameters
892
893Name | Type | Required | Default | Description
894--------|--------|----------|---------|-----------------------------
895options | object | true | | See `Transaction.rawOptions`
896
897### Return
898
899`Transaction`
900
901
902## Transaction.hash
903
904Getter of transaction hash include signature.
905
906> Note: calculate every time.
907
908### Parameters
909
910`void`
911
912### Return
913
914`string,undefined` If transaction has r,s,v return hex string, else return undefined.
915
916
917## Transaction.from
918
919Getter of sender address.
920
921> Note: calculate every time.
922
923### Parameters
924
925`void`
926
927### Return
928
929`string,undefined` If ECDSA recover success return address, else return undefined.
930
931
932## Transaction.sign
933
934Sign transaction and set 'r','s','v'.
935
936### Parameters
937
938Name | Type | Required | Default | Description
939-----------|--------|----------|---------|------------------------
940privateKey | string | true | | Private key hex string.
941
942### Return
943
944`void`
945
946
947## Transaction.encode
948
949Encode rlp.
950
951### Parameters
952
953Name | Type | Required | Default | Description
954-----------------|---------|----------|---------|-----------------------------------------
955includeSignature | boolean | false | false | Whether or not to include the signature.
956
957### Return
958
959`Buffer`
960
961
962## Transaction.serialize
963
964Get the raw tx hex string.
965
966### Parameters
967
968`void`
969
970### Return
971
972`Buffer`
973
974
975## Transaction.sendOptions
976
977
978
979### Parameters
980
981Name | Type | Required | Default | Description
982-----------------|-------------------------|----------|---------|----------------------------------------------------------------------------------------------------
983options | object | true | |
984options.from | string | true | | The address the transaction is send from.
985options.nonce | string,number | true | | This allows to overwrite your own pending transactions that use the same nonce.
986options.gasPrice | string,number | true | | The gasPrice used for each paid gas.
987options.gas | string,number | true | | The gas provided for the transaction execution. It will return unused gas.
988options.to | string | false | | The address the transaction is directed to.
989options.value | string,number,BigNumber | false | | the value sent with this transaction
990options.data | string,Buffer | false | '' | The compiled code of a contract OR the hash of the invoked method signature and encoded parameters.
991
992### Return
993
994`object` Formatted send transaction options object.
995
996
997## Transaction.callOptions
998
999
1000
1001### Parameters
1002
1003Name | Type | Required | Default | Description
1004-----------------|-------------------------|----------|---------|-------------------------------------------------------------------------------------------------------------------------------
1005options | object | true | |
1006options.from | string | false | | The address the transaction is sent from.
1007options.nonce | string,number | false | | The caller nonce (transaction count).
1008options.gasPrice | string,number | false | | The gasPrice used for each paid gas.
1009options.gas | string,number | false | | The gas provided for the transaction execution. `call` consumes zero gas, but this parameter may be needed by some executions.
1010options.to | string | true | | The address the transaction is directed to.
1011options.value | string,number,BigNumber | false | | Integer of the value sent with this transaction.
1012options.data | string,Buffer | false | | Hash of the method signature and encoded parameters.
1013
1014### Return
1015
1016`object` Formatted call contract options object.
1017
1018
1019## Transaction.estimateOptions
1020
1021
1022
1023### Parameters
1024
1025Name | Type | Required | Default | Description
1026-----------------|-------------------------|----------|---------|-------------------------------------------------------------------------------------------------------------------------------
1027options | object | true | |
1028options.from | string | false | | The address the transaction is sent from.
1029options.nonce | string,number | false | | The caller nonce (transaction count).
1030options.gasPrice | string,number | false | | The gasPrice used for each paid gas.
1031options.gas | string,number | false | | The gas provided for the transaction execution. `call` consumes zero gas, but this parameter may be needed by some executions.
1032options.to | string | false | | The address the transaction is directed to.
1033options.value | string,number,BigNumber | false | | Integer of the value sent with this transaction.
1034options.data | string,Buffer | false | | Hash of the method signature and encoded parameters.
1035
1036### Return
1037
1038`object` Formatted call contract options object.
1039
1040
1041## Transaction.rawOptions
1042
1043
1044
1045### Parameters
1046
1047Name | Type | Required | Default | Description
1048-----------------|-------------------------|----------|---------|------------------------------------------------------------------------------------------------------------------------------------------------------------
1049options | object | true | |
1050options.nonce | string,number | true | | This allows to overwrite your own pending transactions that use the same nonce.
1051options.gasPrice | string,number,BigNumber | true | | The price of gas for this transaction in drip.
1052options.gas | string,number | true | | The amount of gas to use for the transaction (unused gas is refunded).
1053options.to | string | false | | The destination address of the message, left undefined for a contract-creation transaction.
1054options.value | string,number,BigNumber | false | 0 | The value transferred for the transaction in drip, also the endowment if it’s a contract-creation transaction.
1055options.data | string,Buffer | false | '' | Either a ABI byte string containing the data of the function call on a contract, or in the case of a contract-creation transaction the initialisation code.
1056options.r | string,Buffer | false | | ECDSA signature r
1057options.s | string,Buffer | false | | ECDSA signature s
1058options.v | string,number | false | | ECDSA recovery id
1059
1060### Return
1061
1062`object` Formatted sign transaction options object.
1063
1064
1065----------
1066# utils.type
1067
1068
1069
1070## type.EpochNumber.LATEST_STATE
1071
1072The latest epochNumber where the latest block with an executed state in.
1073`string`
1074
1075
1076## type.EpochNumber.LATEST_MINED
1077
1078The latest epochNumber where the latest mined block in.
1079`string`
1080
1081
1082## type.Hex
1083
1084Hex formatter, trans value to hex string
1085
1086### Parameters
1087
1088Name | Type | Required | Default | Description
1089------|------------------------------------------|----------|---------|-----------------------------
1090value | string,number,Buffer,Date,BigNumber,null | true | | The value to gen hex string.
1091
1092### Return
1093
1094`string` Hex string.
1095
1096### Example
1097
1098```
1099> Hex(null)
1100 "0x" > Hex(1) // also BigNumber
1101 "0x01" > Hex('10') // from naked hex string
1102 "0x10" > Hex('0x1') // pad prefix 0 auto
1103 "0x01" > Hex(Buffer.from([1, 2]))
1104 "0x0102"
1105```
1106
1107## type.Hex.isHex
1108
1109Check if is hex string.
1110
1111> Hex: /^0x([0-9a-f][0-9a-f])*$/
1112
1113### Parameters
1114
1115Name | Type | Required | Default | Description
1116-----|--------|----------|---------|-------------------
1117hex | string | true | | Value to be check.
1118
1119### Return
1120
1121`boolean`
1122
1123### Example
1124
1125```
1126> Hex.isHex('0x')
1127 true > Hex.isHex('0x01')
1128 true > Hex.isHex('0x1')
1129 false > Hex.isHex('01')
1130 false
1131```
1132
1133## type.Hex.fromNumber
1134
1135Get hex string from number.
1136
1137### Parameters
1138
1139Name | Type | Required | Default | Description
1140------|-------------------------|----------|---------|------------
1141value | number,BigNumber,string | true | |
1142
1143### Return
1144
1145`string`
1146
1147### Example
1148
1149```
1150> Hex.fromNumber('10')
1151 "0x0a" > Hex('10')
1152 "0x10"
1153```
1154
1155## type.Hex.toBuffer
1156
1157Get `Buffer` by `Hex` string.
1158
1159> NOTE: It's importance to only support `Hex` string, cause `Transaction.encode` will not check hex again.
1160
1161### Parameters
1162
1163Name | Type | Required | Default | Description
1164-----|--------|----------|---------|----------------
1165hex | string | true | | The hex string.
1166
1167### Return
1168
1169`Buffer`
1170
1171### Example
1172
1173```
1174> Hex.toBuffer('0x0102')
1175 <Buffer 01 02>
1176```
1177
1178## type.Hex.concat
1179
1180Concat `Hex` string by order.
1181
1182### Parameters
1183
1184Name | Type | Required | Default | Description
1185-------|-------|----------|---------|--------------------
1186values | array | true | | Array of hex string
1187
1188### Return
1189
1190`string`
1191
1192### Example
1193
1194```
1195> Hex.concat('0x01', '0x02', '0x0304')
1196 "0x01020304" > Hex.concat()
1197 "0x"
1198```
1199
1200## type.Address
1201
1202Get and validate `Address` from value
1203
1204### Parameters
1205
1206Name | Type | Required | Default | Description
1207------|--------------------------------|----------|---------|------------
1208value | string,number,Buffer,BigNumber | true | |
1209
1210### Return
1211
1212`string`
1213
1214### Example
1215
1216```
1217> Address('0123456789012345678901234567890123456789')
1218 "0x0123456789012345678901234567890123456789"
1219```
1220
1221## type.Hex32
1222
1223
1224
1225### Parameters
1226
1227Name | Type | Required | Default | Description
1228------|--------------------------------|----------|---------|------------
1229value | string,number,Buffer,BigNumber | true | |
1230
1231### Return
1232
1233`string`
1234
1235### Example
1236
1237```
1238> Hex32('0123456789012345678901234567890123456789012345678901234567890123')
1239 "0x0123456789012345678901234567890123456789012345678901234567890123"
1240```
1241
1242## type.PrivateKey
1243
1244Get and validate `PrivateKey` from value.
1245
1246> same as `Hex32` in coincidence
1247
1248### Parameters
1249
1250Name | Type | Required | Default | Description
1251------|--------------------------------|----------|---------|------------
1252value | string,number,Buffer,BigNumber | true | |
1253
1254### Return
1255
1256`string`
1257
1258
1259## type.BlockHash
1260
1261Get and validate `BlockHash` from value
1262
1263> same as `Hex32` in coincidence
1264
1265### Parameters
1266
1267Name | Type | Required | Default | Description
1268------|--------------------------------|----------|---------|------------
1269value | string,number,Buffer,BigNumber | true | |
1270
1271### Return
1272
1273`string`
1274
1275
1276## type.TxHash
1277
1278Get and validate `TxHash` from value
1279
1280> same as `Hex32` in coincidence
1281
1282### Parameters
1283
1284Name | Type | Required | Default | Description
1285------|--------------------------------|----------|---------|------------
1286value | string,number,Buffer,BigNumber | true | |
1287
1288### Return
1289
1290`string`
1291
1292### Example
1293
1294```
1295> TxHash('0123456789012345678901234567890123456789012345678901234567890123')
1296 "0x0123456789012345678901234567890123456789012345678901234567890123"
1297```
1298
1299## type.Drip
1300
1301
1302
1303### Parameters
1304
1305Name | Type | Required | Default | Description
1306------|--------------------------------|----------|---------|------------
1307value | string,number,Buffer,BigNumber | true | |
1308
1309### Return
1310
1311`string`
1312
1313### Example
1314
1315```
1316> Drip(1)
1317 "0x01"
1318```
1319
1320```
1321> Drip.toGDrip(Drip.fromCFX(1));
1322 "1000000000"
1323```
1324
1325## type.Drip.fromGDrip
1326
1327Get Drip hex string by GDrip value.
1328
1329> NOTE: Rounds towards nearest neighbour. If equidistant, rounds towards zero.
1330
1331### Parameters
1332
1333Name | Type | Required | Default | Description
1334------|-------------------------|----------|---------|----------------
1335value | string,number,BigNumber | true | | Value in GDrip.
1336
1337### Return
1338
1339`string` Hex string in drip.
1340
1341### Example
1342
1343```
1344> Drip.fromGDrip(1)
1345 "0x3b9aca00" > Drip.fromGDrip(0.1)
1346 "0x05f5e100"
1347```
1348
1349## type.Drip.fromCFX
1350
1351Get Drip hex string by CFX value.
1352
1353> NOTE: Rounds towards nearest neighbour. If equidistant, rounds towards zero.
1354
1355### Parameters
1356
1357Name | Type | Required | Default | Description
1358------|-------------------------|----------|---------|--------------
1359value | string,number,BigNumber | true | | Value in CFX.
1360
1361### Return
1362
1363`string` Hex string in drip.
1364
1365### Example
1366
1367```
1368> Drip.fromCFX(1)
1369 "0x0de0b6b3a7640000" > Drip.fromCFX(0.1)
1370 "0x016345785d8a0000"
1371```
1372
1373## type.Drip.toGDrip
1374
1375Get `GDrip` from Drip.
1376
1377### Parameters
1378
1379Name | Type | Required | Default | Description
1380------|-------------------------|----------|---------|------------
1381value | string,number,BigNumber | true | |
1382
1383### Return
1384
1385`BigNumber`
1386
1387### Example
1388
1389```
1390> Drip.toGDrip(1e9)
1391 "1" > Drip.toGDrip(Drip.fromCFX(1))
1392 "1000000000"
1393```
1394
1395## type.Drip.toCFX
1396
1397Get `CFX` from Drip.
1398
1399### Parameters
1400
1401Name | Type | Required | Default | Description
1402------|-------------------------|----------|---------|------------
1403value | string,number,BigNumber | true | |
1404
1405### Return
1406
1407`BigNumber`
1408
1409### Example
1410
1411```
1412> Drip.toCFX(1e18)
1413 "1" > Drip.toCFX(Drip.fromGDrip(1e9))
1414 "1"
1415```
1416
1417## type.EpochNumber
1418
1419Get and validate `EpochNumber` from value
1420
1421### Parameters
1422
1423Name | Type | Required | Default | Description
1424------|--------------------------------|----------|---------|------------
1425value | string,number,Buffer,BigNumber | true | |
1426
1427### Return
1428
1429`string`
1430
1431### Example
1432
1433```
1434> EpochNumber(0)
1435 "0x00" > EpochNumber('100')
1436 "0x64" > EpochNumber('LATEST_STATE')
1437 "latest_state"
1438```
1439
1440----------
1441# wallet.Account
1442
1443
1444
1445
1446## Account.constructor
1447
1448Create a account by privateKey.
1449
1450### Parameters
1451
1452Name | Type | Required | Default | Description
1453-----------|---------------|----------|---------|------------
1454privateKey | string,Buffer | true | |
1455
1456### Return
1457
1458`Account`
1459
1460
1461## Account.signTransaction
1462
1463Sign a transaction.
1464
1465### Parameters
1466
1467Name | Type | Required | Default | Description
1468--------|--------|----------|---------|------------------
1469options | object | true | | See 'Transaction'
1470
1471### Return
1472
1473`Transaction`
1474
1475
1476## Account.toString
1477
1478
1479
1480### Parameters
1481
1482`void`
1483
1484### Return
1485
1486`string` Account address as string.
1487
1488
1489----------
1490# wallet.Wallet
1491
1492Contains an in memory wallet with multiple accounts.
1493
1494
1495## Wallet.constructor
1496
1497
1498
1499### Parameters
1500
1501Name | Type | Required | Default | Description
1502-----|---------|----------|---------|------------
1503cfx | Conflux | true | |
1504
1505### Return
1506
1507`Wallet`
1508
1509
1510## Wallet.size
1511
1512Get the number of account in wallet.
15131 account have 1 address and 1 privateKey as key
1514
1515### Parameters
1516
1517`void`
1518
1519### Return
1520
1521`number`
1522
1523
1524## Wallet.create
1525
1526Create a random Account.
1527
1528### Parameters
1529
1530Name | Type | Required | Default | Description
1531--------|--------|----------|---------|-----------------
1532entropy | string | false | | Hex string seed.
1533
1534### Return
1535
1536`Account`
1537
1538
1539## Wallet.get
1540
1541Get a account in wallet by address or privateKey.
1542
1543### Parameters
1544
1545Name | Type | Required | Default | Description
1546--------------------|--------|----------|---------|------------
1547privateKeyOrAddress | string | true | | Hex string.
1548
1549### Return
1550
1551`Account`
1552
1553
1554## Wallet.add
1555
1556Add a account to wallet by privateKey.
1557
1558### Parameters
1559
1560Name | Type | Required | Default | Description
1561-----------|---------------|----------|---------|------------
1562privateKey | string,Buffer | true | |
1563
1564### Return
1565
1566`Account`
1567
1568
1569## Wallet.remove
1570
1571Remove a account in wallet by address or privateKey
1572
1573### Parameters
1574
1575Name | Type | Required | Default | Description
1576--------------------|--------|----------|---------|------------
1577privateKeyOrAddress | string | true | | Hex string.
1578
1579### Return
1580
1581`Account`
1582
1583
1584## Wallet.clear
1585
1586Clear all account in wallet.
1587
1588### Parameters
1589
1590`void`
1591
1592### Return
1593
1594`void`