Skip to content

Get started

Matic.js a JavaScript library that facilitates interaction with the Polygon network. It provides developers with simplified operations such as depositing, transferring, and withdrawing assets, allowing them to focus on building dApps without requiring in-depth knowledge of blockchain systems.

Matic.js supports two popular libraries:

  1. Web3.js
  2. Ethers

Prerequisites

Ensure that your Node.js version is up to date.

We recommend using Node.js version v18.19.1 for optimal compatibility.

Installation

Matic.js core library

The library contains core logic and provides different APIs. The user interacts mostly with this library.

npm i @maticnetwork/maticjs

Matic.js ethers library

The ethers library allows us to use any ethers function. It is injected into Matic.js using plugins.

npm install @maticnetwork/maticjs-ethers

Matic.js web3 library

The web3 library allows us to use any web3 function.

npm install @maticnetwork/maticjs-web3

Initializing

To code with matic, import the relevant libraries in your scripts. For example:

import { use } from '@maticnetwork/maticjs'
import { Web3ClientPlugin } from '@maticnetwork/maticjs-web3'

// install web3 plugin
use(Web3ClientPlugin)
  • Click for more details on POS applications that use web3js.
  • Click for more details on POS applications that use ethers.

Support

In case you face any issues or have any queries, feel free to raise a ticket to our Support Team or reach out to us on Discord.