Skip to main content
Matic.js is the legacy SDK for interacting with the Polygon Chain bridge contracts. If you’re looking for a modern API to move money on Polygon (stablecoin payments, on-ramps, custodial wallets, virtual accounts), use the Open Money Stack Payments API instead. The full endpoint reference is in the Open Money Stack API reference.
The Matic.js library follows common api architecture throughout and the APIs are divided into two types:
  1. Read API
  2. Write API

Read API

Read methods do not publish anything on blockchain, so they do not consume any gas. For example:
Read methods are very simple and return results directly.

Write API

Write methods publish some data on the blockchain, so they consumes gas. Example of write methods are approve, deposit etc. A write method returns (at least) two data items:
  1. TransactionHash
  2. TransactionReceipt
For example:

Transaction option

There are some configurable options that are available for all API’s. These configurations can be passed as parameters. Available configurations are -
  • from?: string | number - The address transactions should be made from.
  • to?: string - The address transactions should be made to.
  • value?: number | string | BN - The value transferred for the transaction in wei.
  • gasLimit?: number | string - The maximum gas provided for a transaction (gas limit).
  • gasPrice?: number | string | BN - The gas price in wei to use for transactions.
  • data?: string - The byte code of the contract.
  • nonce?: number;
  • chainId?: number;
  • chain?: string;
  • hardfork?: string;
  • returnTransaction?: boolean - making it true will return the transaction object which can be used to send transaction manually.
This example configures the gas price: