npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@fxportal/maticjs-fxportal

v1.1.1

Published

Library for interacting with fx-portal bridge.

Downloads

58

Readme

TEST npm version

maticjs-fxportal

FxPortal bridge plugin for maticjs. It provides FxPortalClient to interact with fxportal bridge.

Installation

npm i @fxportal/maticjs-fxportal

Install ethers library

Currently matic.js support two ethers library -

1. web3.js

npm i @maticnetwork/maticjs-web3

2. Ethers

npm i @maticnetwork/maticjs-ethers

DOCS

Initiate client

const { use } = require("@maticnetwork/maticjs");
const { Web3ClientPlugin } = require("@maticnetwork/maticjs-web3");
const { FxPortalClient } = require("@fxportal/maticjs-fxportal");

const HDWalletProvider = require("@truffle/hdwallet-provider");

// add Web3Plugin

use(Web3ClientPlugin);

const fxPortalClient = new FxPortalClient();

await fxPortalClient.init({
    network: 'testnet',
    version: 'mumbai',
    parent: {
        provider: new HDWalletProvider(privateKey, rootRPC),
        defaultConfig: {
            from
        }
    },
    child: {
        provider: new HDWalletProvider(privateKey, childRPC),
        defaultConfig: {
            from
        }
    }
});

ERC20

Method erc20 allows you to interact with erc20 token.

const erc20 = fxPortalClient.erc20(<tokenAddress>, <isRoot>);

getBalance

Get balance of a user by supplying user address

const balance = await erc20.getBalance(<user address>);

getName

Get name of token

const name = await erc20.getName();

getDecimals

Get decimals of token

const decimals = await erc20.getDecimals();

getSymbol

Get symbol of token

const decimals = await erc20.getSymbol();

approve

Approve required amount for depositing to polygon chain

const approveResult = await erc20.approve(<amount>);
const txHash = await approveResult.getTransactionHash();
const receipt = await approveResult.getReceipt();

approveMax

Approve max amount for depositing to polygon chain

const approveResult = await erc20.approveMax();
const txHash = await approveResult.getTransactionHash();
const receipt = await approveResult.getReceipt();

getAllowance

Get approve amount of a user by supplying user address

const balance = await erc20.getAllowance(<user address>);

deposit

Deposit required amount from ethereum to polygon

const result = await erc20.deposit(<amount>, <user address>);
const txHash = await result.getTransactionHash();
const receipt = await result.getReceipt();

withdrawStart

Initiate withdraw process by burning the required amount.

const result = await erc20.withdrawStart(<amount>);
const txHash = await result.getTransactionHash();
const receipt = await result.getReceipt();

withdrawToStart

Initiate withdrawTo process by burning the required amount.

const result = await erc20.withdrawToStart(<amount>, <to address>);
const txHash = await result.getTransactionHash();
const receipt = await result.getReceipt();

withdrawExit

Exit withdraw process by providng txHash received in withdrawStart process.

Note:- withdrawExit can be called after checkpoint has been submitted for withdrawStart.

const result = await erc20.withdrawExit(<burn tx hash>);
const txHash = await result.getTransactionHash();
const receipt = await result.getReceipt();

withdrawExitFaster

Faster exit withdraw process by providng txHash received in withdrawStart process.

It is faster because it uses api to create the proof.

const result = await erc20.withdrawExitFaster(<burn tx hash>);
const txHash = await result.getTransactionHash();
const receipt = await result.getReceipt();

isCheckPointed

Check if transaction has been checkpointed or not.

await fxPortalClient.isCheckPointed(<tx hash>);

isWithdrawExited

Check if withdraw process has been completed by supplying burn transaction hash.

const balance = await erc20.isExited(<burn tx hash>);

isDeposited

Check if deposit is completed.

const balance = await erc20.isDeposited(<tx hash>);