You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on May 26, 2023. It is now read-only.
The following table provides a description of each module and what you may
19
20
want to use it for.
20
21
21
-
| package | description | dependencies |
22
-
| --- | --- | --- |
23
-
|[`@zilliqa-js/core`](./packages/zilliqa-js-core)| Core abstractions and base classes, such as `HTTPProvider` and network logic for interfacing with the Zilliqa JSON-RPC. | none |
24
-
|[`@zilliqa-js/account`](./packages/zilliqa-js-account)|`Wallet`, `Account` and `Transaction` abstractions live in this package. |`@zilliqa-js/core`, `@zilliqa-js/crypto`, `@zilliqa-js/util`, `@zilliqa-js/proto`|
25
-
|[`@zilliqa-js/blockchain`](./packages/zilliqa-js-blockchain)| Main interface to the Zilliqa `JSON-RPC`. | none |
26
-
|[`@zilliqa-js/contract`](./packages/zilliqa-js-contract)| Exposes a `Contracts` module that takes care of smart contract deployment and interaction. |`@zilliqa-js/account`, `@zilliqa-js/blockchain`, `@zilliqa-js/core`, `@zilliqa-js/util`|
27
-
|[`@zilliqa-js/crypto`](./packages/zilliqa-js-crypto)| Exposes several loosely-coupled cryptographic convenience functions for working with the Zilliqa blockchain and its cryptographic primitives, such as Schnorr signatures. |`@zilliqa-js/util`|
|[`@zilliqa-js/core`](./packages/zilliqa-js-core)| Core abstractions and base classes, such as `HTTPProvider` and network logic for interfacing with the Zilliqa JSON-RPC. | none |
25
+
|[`@zilliqa-js/account`](./packages/zilliqa-js-account)|`Wallet`, `Account` and `Transaction` abstractions live in this package. |`@zilliqa-js/core`, `@zilliqa-js/crypto`, `@zilliqa-js/util`, `@zilliqa-js/proto`|
26
+
|[`@zilliqa-js/blockchain`](./packages/zilliqa-js-blockchain)| Main interface to the Zilliqa `JSON-RPC`. | none |
27
+
|[`@zilliqa-js/contract`](./packages/zilliqa-js-contract)| Exposes a `Contracts` module that takes care of smart contract deployment and interaction. |`@zilliqa-js/account`, `@zilliqa-js/blockchain`, `@zilliqa-js/core`, `@zilliqa-js/util`|
28
+
|[`@zilliqa-js/crypto`](./packages/zilliqa-js-crypto)| Exposes several loosely-coupled cryptographic convenience functions for working with the Zilliqa blockchain and its cryptographic primitives, such as Schnorr signatures. |`@zilliqa-js/util`|
|[`@zilliqa-js/util`](./packages/zilliqa-js-util)| Miscellaneous functions that take care of serialisation/deserialisation and validation. | none |
31
+
|[`@zilliqa-js/viewblock`](https://github.com/Ashlar/zilliqa-js-viewblock)| Library interfacing with ViewBlock's APIs |`@zilliqa-js/crypto`|
32
32
33
33
## Pre-Requisite (Windows Users)
34
34
35
-
`zilliqa-js` uses [`scrypt`](https://www.npmjs.com/package/scrypt) library which depends on `node-gyp` in order to compile the binaries from source on Windows.
35
+
`zilliqa-js` uses [`scrypt`](https://www.npmjs.com/package/scrypt) library which depends on `node-gyp` in order to compile the binaries from source on Windows.
36
36
`node-gyp` on Windows requires users to install additional Visual Studio Build tools.
37
37
38
38
To install the required Visual Studio Build tools:
@@ -45,7 +45,6 @@ npm config set msvs_version 2015 # 2015 is more compatible; though 2017 may work
45
45
46
46
Refer to https://github.com/nodejs/node-gyp#installation for more information about `node-gyp` installation on Windows.
47
47
48
-
49
48
## Installation
50
49
51
50
It is recommended that developers install the JavaScript client by making use
@@ -62,17 +61,15 @@ yarn add bn.js
62
61
63
62
## Quick Start
64
63
65
-
>**Ideally, you should [Create a new Nucleus Wallet](https://dev-wallet.zilliqa.com/generate) (an [open source](https://github.com/Zilliqa/nucleus-wallet) Zilliqa testnet wallet)**.
64
+
>**Ideally, you should [Create a new Nucleus Wallet](https://dev-wallet.zilliqa.com/generate) (an [open source](https://github.com/Zilliqa/nucleus-wallet) Zilliqa testnet wallet)**.
66
65
>
67
-
>You should 'fund' the wallet by sending testnet ZIL tokens from the [ZIL faucet](https://dev-wallet.zilliqa.com/faucet)
66
+
>You should 'fund' the wallet by sending testnet ZIL tokens from the [ZIL faucet](https://dev-wallet.zilliqa.com/faucet)
68
67
>
69
-
>You should then replace the value of `const privateKey` with the one from this wallet.
68
+
>You should then replace the value of `const privateKey` with the one from this wallet.
70
69
>
71
-
>The code should work with the existing private key but this cannot be guaranteed.
72
-
70
+
> The code should work with the existing private key but this cannot be guaranteed.
73
71
74
72
```javascript
75
-
76
73
const { BN, Long, bytes, units } =require('@zilliqa-js/util');
@@ -268,15 +265,15 @@ async function testBlockchain() {
268
265
}
269
266
270
267
testBlockchain();
271
-
272
268
```
269
+
273
270
### Notes on the Quick Start script
274
271
275
272
#### Note 1: Account balance
276
273
277
-
The account balance is an object with two fields, `balance` and `nonce`.
274
+
The account balance is an object with two fields, `balance` and `nonce`.
278
275
279
-
`balance` is the account balance in Qa, which is the lowest denomination in Zilliqa.
276
+
`balance` is the account balance in Qa, which is the lowest denomination in Zilliqa.
280
277
For more information about gas accounting, please refer to here: https://forum.zilliqa.com/t/gas-accounting-in-zilliqa/199
281
278
282
279
`nonce` is a counter that keeps track of how many transactions are sent from a given address. In Zilliqa, every transaction sent from an address must have a unique nonce.
@@ -288,33 +285,34 @@ For more information about gas accounting, please refer to here: https://forum.z
`event_logs` comprises of all the events emitted in the transaction. For example, if your transaction calls a transition which emits 3 events, it will be an array of three events. The `address` is the contract address of the contract which emits the event.
313
311
314
312
`success` indicates if the transaction is successful.
315
313
316
-
317
314
## Examples
315
+
318
316
For more examples, visit this [repository](https://github.com/Zilliqa/Zilliqa-JavaScript-Library-Examples).
319
317
320
318
## API Documentation
@@ -352,6 +350,7 @@ yarn bootstrap
352
350
# watch TS source files and recompile on change
353
351
yarn build:ts -w
354
352
```
353
+
355
354
### Tests
356
355
357
356
Tests for each package reside in `packages/src/*/tests`, and are run using
@@ -367,20 +366,19 @@ Once it has been installed and executed, you can run `yarn release:local` to sim
367
366
368
367
#### rollup
369
368
370
-
`zilliqa-js` is bundled using `rollup`. To build the distributable bundles, simple run `yarn bundle`.
369
+
`zilliqa-js` is bundled using `rollup`. To build the distributable bundles, simple run `yarn bundle`.
371
370
This will output two bundles, `*.umd.js` and `*.esm.js`, to `packages/*/dist`. Node.js clients
372
371
are pointed to the `umd` bundle, and bundlers are pointed to `esm`.
373
372
374
-
*NOTE: these bundles are _not_ minified.*
373
+
_NOTE: these bundles are *not* minified._
375
374
376
375
#### webpack
377
376
378
-
To build an all-in-one static js file, first install `webpack` globally using `yarn global add webpack`. Then run `yarn build:web`.
377
+
To build an all-in-one static js file, first install `webpack` globally using `yarn global add webpack`. Then run `yarn build:web`.
379
378
This will generate a `dist` folder in the current path, which contains a file called `zilliqa.min.js`. It can be used in normal html file. (A more specific example please refer to `example/webpack`)
380
379
381
-
*NOTE: there may be some issue to install webpack with npm, thus using yarn is a recommended way*
380
+
_NOTE: there may be some issue to install webpack with npm, thus using yarn is a recommended way_
Adds an account by keystore. This method is asynchronous and returns a `Promise<string>`, in order not to block on the underlying decryption operation.
161
+
Adds an account by keystore. This method is asynchronous and returns a `Promise<string>`, in order not to block on the underlying decryption operation.
160
162
161
163
**Parameters**
162
164
@@ -221,13 +223,13 @@ Sets the default account to sign with.
Sign a `Transaction` with the default `Account`. This method is asynchronous
224
-
as it will attempt to obtain the `nonce` from the `Provider`.
226
+
as it will attempt to obtain the `nonce` from the `Provider`.
225
227
There is an offline mode that can be activated manually by setting the optional `offlineSign` parameter.
226
228
227
229
**Parameters**
228
230
229
231
-`transaction`: `Transaction` - a `Transaction` instance.
230
-
-`offlineSign`: `boolean` (optional) - toggles offline signing on/off. Defaults to `false` if the field is not set. If explicitly set to `true`, offline mode is used and does not require internet connection to sign a transaction.
232
+
-`offlineSign`: `boolean` (optional) - toggles offline signing on/off. Defaults to `false` if the field is not set. If explicitly set to `true`, offline mode is used and does not require internet connection to sign a transaction.
231
233
232
234
**Note**: In offline mode, the nonce must be explicitly set in the Transaction object.
233
235
@@ -245,9 +247,9 @@ There is an offline mode that can be activated manually by setting the optional
245
247
246
248
-`transaction`: `Transaction` - a `Transaction` instance.
247
249
-`address`: `string` - the address of the `Account` to be used for signing.
248
-
-`offlineSign`: `boolean` (optional) - toggles offline signing on/off. Defaults to `false` if the field is not set. If explicitly set to `true`, offline mode is used and does not require internet connection to sign a transaction.
250
+
-`offlineSign`: `boolean` (optional) - toggles offline signing on/off. Defaults to `false` if the field is not set. If explicitly set to `true`, offline mode is used and does not require internet connection to sign a transaction.
249
251
250
-
**Note**: In offline mode, the nonce must be explicitly set in the Transaction object.
252
+
**Note**: In offline mode, the nonce must be explicitly set in the Transaction object.
251
253
252
254
**Returns**
253
255
@@ -300,7 +302,7 @@ for (const signedTx of batchResult) {
300
302
301
303
## `Transaction`
302
304
303
-
A class that represents a single `Transaction` on the Zilliqa network. It is a functor. Its purpose is to encode the possible states a Transaction can be in: Confirmed, Rejected, Pending, or Initialised (i.e., not broadcasted).
305
+
A class that represents a single `Transaction` on the Zilliqa network. It is a functor. Its purpose is to encode the possible states a Transaction can be in: Confirmed, Rejected, Pending, or Initialised (i.e., not broadcasted).
0 commit comments