Skip to content

Commit 7662218

Browse files
committing clarifying changes
1 parent 4c44fcb commit 7662218

File tree

5 files changed

+80
-111
lines changed

5 files changed

+80
-111
lines changed

docs/tools/matic-js/get-started.md

Lines changed: 6 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,12 @@ In this get started document we will learn about how we can setup and interact w
44

55
In case you face any issues or have any queries, feel free to raise a [ticket](https://support.polygon.technology/support/tickets/new) to our Support Team or reach out to us on [Discord](https://discord.gg/32j4qNDn).
66

7-
## Installation
7+
!!! important
8+
Make sure you have followed the [installation step](installation.md).
89

9-
**Install the maticjs package via npm:**
10+
## Initializing
1011

11-
```bash
12-
npm install @maticnetwork/maticjs
13-
```
14-
15-
**Install the web3js plugin**
16-
17-
```bash
18-
npm install @maticnetwork/maticjs-web3
19-
```
20-
21-
## Setup
12+
To code with matic, import the relevant libraries in your scripts. For example:
2213

2314
```javascript
2415
import { use } from '@maticnetwork/maticjs'
@@ -28,81 +19,5 @@ import { Web3ClientPlugin } from '@maticnetwork/maticjs-web3'
2819
use(Web3ClientPlugin)
2920
```
3021

31-
In the above code we are initiating maticjs with `web3js` but you can also similarly initiate with [ethers](setup/ethers.md).
32-
33-
## POS client
34-
35-
`POSClient` helps us to interact with POS Bridge.
36-
37-
```js
38-
import { POSClient,use } from "@maticnetwork/maticjs"
39-
import { Web3ClientPlugin } from '@maticnetwork/maticjs-web3'
40-
import HDWalletProvider from "@truffle/hdwallet-provider"
41-
42-
// install web3 plugin
43-
use(Web3ClientPlugin);
44-
45-
const posClient = new POSClient();
46-
await posClient.init({
47-
network: 'testnet',
48-
version: 'mumbai',
49-
parent: {
50-
provider: new HDWalletProvider(privateKey, mainRPC),
51-
defaultConfig: {
52-
from : fromAddress
53-
}
54-
},
55-
child: {
56-
provider: new HDWalletProvider(privateKey, childRPC),
57-
defaultConfig: {
58-
from : fromAddress
59-
}
60-
}
61-
});
62-
63-
```
64-
65-
After `POSClient` is initiated, we need to initiate the required token types like - `erc20`, `erc721` etc.
66-
67-
### ERC20
68-
69-
**Create erc20 child token**
70-
71-
```
72-
const erc20ChildToken = posClient.erc20(<token address>);
73-
```
74-
75-
**Create erc20 parent token**
76-
77-
```
78-
const erc20ParentToken = posClient.erc20(<token address>, true);
79-
80-
```
81-
82-
Once erc20 is initaited, you can call various methods that are available, like - `getBalance`, `approve`, `deposit` , `withdraw` etc.
83-
84-
#### `getBalance`
85-
86-
```
87-
const balance = await erc20ChildToken.getBalance(<userAddress>)
88-
console.log('balance', balance)
89-
```
90-
91-
#### `approve`
92-
93-
```
94-
// approve amount 10 on parent token
95-
const approveResult = await erc20ParentToken.approve(10);
96-
97-
// get transaction hash
98-
const txHash = await approveResult.getTransactionHash();
99-
100-
// get transaction receipt
101-
const txReceipt = await approveResult.getReceipt();
102-
```
103-
104-
As you can see, with its simple APIs maticjs makes it very easy to interact with maticjs bridge.
105-
106-
## Useful links
107-
108-
- [Examples](https://github.com/maticnetwork/matic.js/tree/master/examples)
22+
- Click for more details on POS applications that use [`web3js`](setup/web3js.md).
23+
- Click for more details on POS applications that use [`ethers`](setup/ethers.md).
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
Matic.js is made up of two parts:
1+
Matic.js is made up of a main library and an Ethereum library:
22

3-
## 1. Main library
3+
## Main library
44

5-
The Main library has the core logic and provides different APIs. The user interacts mostly with this library.
5+
The main library has the core logic and provides different APIs. The user interacts mostly with this library.
66

7-
```
7+
```sh
88
npm i @maticnetwork/maticjs
99
```
1010

11-
## 2. Ethereum library
11+
## Ethereum library
1212

13-
Ethereum library allows us to use any favourite ether library. It is injected into maticjs using plugins.
13+
The Ethereum library allows us to use any favorite ether library. It is injected into maticjs using plugins.
1414

1515
matic.js supports two popular library -
1616

@@ -19,12 +19,12 @@ matic.js supports two popular library -
1919

2020
### Web3.js
2121

22-
```
22+
```sh
2323
npm install @maticnetwork/maticjs-web3
2424
```
2525

2626
### ethers
2727

28-
```
28+
```sh
2929
npm install @maticnetwork/maticjs-ethers
3030
```

docs/tools/matic-js/pos/client.md

Lines changed: 60 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,78 @@
1-
Matic.js provides `POSClient` to interact with the **PoS Bridge**.
1+
!!! important
2+
Make sure you have followed the [installation](../installation.md) and [get started](../get-started.md) documentation.
3+
4+
The `POSClient` interacts with the POS bridge.
25

36
```js
47
import { POSClient,use } from "@maticnetwork/maticjs"
8+
import { Web3ClientPlugin } from '@maticnetwork/maticjs-web3'
9+
import HDWalletProvider from "@truffle/hdwallet-provider"
510

6-
const posClient = new POSClient();
11+
// install web3 plugin
12+
use(Web3ClientPlugin);
713

14+
const posClient = new POSClient();
815
await posClient.init({
9-
network: <network name>, // 'testnet' or 'mainnet'
10-
version: <network version>, // 'mumbai' or 'v1'
16+
network: 'testnet',
17+
version: 'mumbai',
1118
parent: {
12-
provider: <parent provider>,
19+
provider: new HDWalletProvider(privateKey, mainRPC),
1320
defaultConfig: {
14-
from: <from address>
21+
from : fromAddress
1522
}
1623
},
1724
child: {
18-
provider: <child provider>,
25+
provider: new HDWalletProvider(privateKey, childRPC),
1926
defaultConfig: {
20-
from: <from address>
27+
from : fromAddress
2128
}
2229
}
2330
});
31+
32+
```
33+
34+
After the `POSClient` is initiated, we can work with token types, such as `erc20`, `erc721` etc.
35+
36+
### ERC20
37+
38+
**Create erc20 child token**
39+
40+
```js
41+
const erc20ChildToken = posClient.erc20(<token address>);
42+
```
43+
44+
**Create erc20 parent token**
45+
46+
```js
47+
const erc20ParentToken = posClient.erc20(<token address>, true);
2448
```
2549

50+
Once erc20 is initaited, you can call various methods that are available, like - `getBalance`, `approve`, `deposit` , `withdraw` etc.
51+
52+
#### `getBalance`
53+
54+
```js
55+
const balance = await erc20ChildToken.getBalance(<userAddress>)
56+
console.log('balance', balance)
57+
```
58+
59+
#### `approve`
60+
61+
```js
62+
// approve amount 10 on parent token
63+
const approveResult = await erc20ParentToken.approve(10);
64+
65+
// get transaction hash
66+
const txHash = await approveResult.getTransactionHash();
67+
68+
// get transaction receipt
69+
const txReceipt = await approveResult.getReceipt();
70+
```
71+
72+
As you can see, with its simple APIs maticjs makes it very easy to interact with maticjs bridge.
73+
74+
## Useful links
75+
76+
- [Examples](https://github.com/maticnetwork/matic.js/tree/master/examples)
77+
2678
Once the `POSClient` is initiated, you can interact with all available APIs.

docs/tools/matic-js/zkevm/initialize.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
!!! important
2+
Make sure you have followed the [installation](../installation.md) and [get started](../get-started.md) documentation.
13

2-
Matic.js library also provides the **ZkEvmClient** to interact with the Polygon zkEVM network.
4+
The `ZkEvmClient` interacts with the POS bridge.
35

46
```js
57
import { ZkEvmClient, use } from "@maticnetwork/maticjs"

mkdocs.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -381,9 +381,9 @@ nav:
381381
- Flair: tools/data/flair.md
382382
- PARSIQ: tools/data/parsiq.md
383383
- Matic.js:
384+
- Installation: tools/matic-js/installation.md
385+
- Get started: tools/matic-js/get-started.md
384386
- POS:
385-
- Get started: tools/matic-js/get-started.md
386-
- Installation: tools/matic-js/installation.md
387387
- POS client: tools/matic-js/pos/client.md
388388
- API overview: tools/matic-js/api-architecture.md
389389
- Setup:
@@ -449,7 +449,7 @@ nav:
449449
- isCheckPointed: tools/matic-js/pos/is-check-pointed.md
450450
- isDeposited: tools/matic-js/pos/is-deposited.md
451451
- zkEVM:
452-
- Initialize: tools/matic-js/zkevm/initialize.md
452+
- zkEVM client: tools/matic-js/zkevm/initialize.md
453453
- ERC20: tools/matic-js/zkevm/erc20.md
454454
- Common methods: tools/matic-js/zkevm/common-methods.md
455455
- Storage:

0 commit comments

Comments
 (0)