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

@maticnetwork/lxlyjs

v2.0.0-beta.1

Published

Javascript developer library for interacting with Polygon LxLy Bridge

Downloads

149

Readme

LxLy SDK

GitHub version Build Status npm version GitHub

This repository contains the lxlyjs client library. lxlyjs makes it easy for developers, who may not be deeply familiar with smart contract development, to interact with the various components of Polygon LxLy Aggregator bridge.

This library will help developers to move assets between Ethereum chain and Polygon CDK chains.

Installation

You can install the package using NPM

Using NPM

npm install @maticnetwork/lxlyjs

Usage

Import lxly.js module

// Use web3 client
const { LxLyClient, use } = require("@maticnetwork/lxlyjs");
const { Web3ClientPlugin } = require("@maticnetwork/maticjs-web3");
use(Web3ClientPlugin);
// Use ethers client
const { LxLyClient, use } = require("@maticnetwork/lxlyjs");
const { Web3ClientPlugin } = require("@maticnetwork/maticjs-ethers");
use(Web3ClientPlugin);

Client Initialization

const client = new LxLyClient();
await client.init({
  log: true,
  network: "mainnet", // "testnet" from testnet chains
  providers: {
    0: {
      provider: // Provider for network 0 chain ,
      configuration: {
        bridgeAddress: // Bridge Address on 0 network,
        wrapperAddress: // Wrapper Address on 0 network,
        isEIP1559Supported: true
      },
      defaultConfig: {
        from
      }
    },
    1: {
      provider: // Provider for network 1 chain ,
      configuration: {
        bridgeAddress: // Bridge Address on 1 network,
        wrapperAddress: // Wrapper Address on 0 network,
        isEIP1559Supported: false
      },
      defaultConfig: {
        from
      }
    }
  }
});

Configuration details can be found here for Mainnet and Testnet

Custom Network

Custom networks can also be integrated into the client.

It's worth noting that the lxly.js library might not inherently support the merkle-proof API for custom networks. To address this, users can provide a custom Proof API by utilizing the setProofApi function call. This allows for seamless integration and support of merkle-proof functionalities within the custom network setup. Further details on the format for Proof Generation API can be found here.

const { LxLyClient, use, setProofApi } = require("@maticnetwork/lxlyjs");

const client = new LxLyClient();
await client.init({
  log: true,
  network: "mainnet", // "testnet" from testnet chains
  providers: {
    <CustomNetworkId>: {
      provider: // Provider for custom network Chain ,
      configuration: {
        bridgeAddress: // Bridge Address on custom network,
        wrapperAddress: // Wrapper Address on custom network,
        isEIP1559Supported: // is EIP1559 Supported on custom network
      },
      defaultConfig: {
        from
      }
    }
  }
});

setProofApi(url)

ERC20 Token initialization

// Initialize ERC20 token with the token address and network ID
const erc20 = new client.erc20(tokenAddress, networkId);

// Example usage: get the balance of a specific address
const balance = erc20.getBalance(address);

Custom Contracts

// Initialize Custom contract
const customContract = new client.contract(abi, tokenAddress, networkId);

// read contract
await customContract.read(methodName, ...args);

// write contract
await customContract.write(transactionOptions = {}, methodName, ...args);

For the complete function implementation, please refer to the example here or codebase available here.

Support

Our Discord is the best way to reach us ✨.

Contributors

You are very welcome to contribute, please see contributing guidelines - [Contribute].

Thank you to all the people who already contributed to lxly.js!

Made with contributors-img.

Development

Setup

npm ci

How to debug

Write your code inside file test/debug_web3.js and run below code

npm run debug

Above command will build the source code & install the built version into test folder, which will be used by debug_web3.js.

Lint

# To check lint errors
npm run lint

# To fix most common lint errors
# Note that it might not fix all errors, some need manual intervention
npm run lint:fix

Build code

npm run build

Generate distribution files

npm run deploy

NPM publish

Before running publish script, make sure you have updated version properly.

Note that prepublishOnly script will be automatically called while publishing. It will check lint, clean dist/lib folders and build fresh distribution files before it executes npm publish.

npm publish

License

MIT