MCDEX
Search…
Quick Start
The following guides will help you use ethers.js to return state date from the EVM, and the Mai Protocol V3 SDK to manipulate it once it has been retrieved.

Installation

To interact with the V3 SDK - we recommend installing though the npm package
1
npm i --save-dev @mcdex/mai3.js
Copied!

Connect to Blockchain

Take Arb-Rinkeby for example
1
import { JsonRpcProvider } from "@ethersproject/providers";
2
const provider = new JsonRpcProvider('https://rinkeby.arbitrum.io/rpc')
Copied!

Creating the signer object by providing private key.

1
const signer = new ethers.Wallet(pk, provider)
Copied!

Get the reader object by calling getReaderContract

Get MAI3 reader object by getReaderContract function.
1
import { getReaderContract } from "@mcdex/mai3.js"
2
const reader = await getReaderContract(provider)
Copied!

Util function

Util function provides useful function for handle or correct result.
  • fromWei is common function in typescript for transferring from WEI unit to ETH unit.
  • toWei is common function in typescript for transferring from ETH unit to WEI unit.
1
export function fromWei(n: string) { return ethers.utils.formatEther(n); }
2
export function toWei(n: string) { return ethers.utils.parseEther(n) };
Copied!

List

Last modified 23d ago