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

@ethereumnetwork/matic-bridge

v0.0.10

Published

matic bridge

Downloads

6

Readme

Matic POS bridges

This library helps you in easy way for transfering ethereum, ERC20, ERC721 and ERC1155 tokens from matic chain to ethereum chain and from matic chain to ethereum chain. It uses the Matic SDK under the hood.

Table of Contents:

Supported networks

  • Matic Testnet (Mumbai) - Ethereum Testnet (Goerli)
  • Matic Mainnet - Ethereum Mainnet

Supported protocols

  • ETH
  • ERC20
  • ERC721
  • ERC1155

Prerequisites

  • Node.js v.10 or greater is required
  • npm or yarn
  • submited mapping request like here

How To Install

 yarn add @ethereumnetwork/matic-bridge

or

 npm install @ethereumnetwork/matic-bridge

Supported methods

transferETHFromEthereumToMaticUsingPOSBridge

| Property | Required | Default value | Description | | :-------------------------- | :------: | :------------: | :----------------------------------------------------------- | | maticApiUrl | ✅ | - | Matic url to the node api | | ethereumAccountPrivateKey | ✅ | - | Ethereaum private key to the account from where you send ETH | | ethereumApiUrl | ✅ | - | Ethereum url to the node api | | recipientAddress | ✅ | - | Address of the recipient | | amountWei | ✅ | - | Amount to send in wei | | maticNetwork | :x: | testnet | Network of matic. Set to mainnet for mainnet transfer | | maticVersion | :x: | mumbai | Version of matic. Set to v1 for mainnet transfer | | gasPrice | :x: | 100000000000 | Gas price of the transfer |

example usage

import { transferETHFromEthereumToMaticUsingPOSBridge } from "@ethereumnetwork/matic-bridge";

...

await transferETHFromEthereumToMaticUsingPOSBridge({
    maticApiUrl: 'https://polygon-mumbai.g.alchemy.com/v2/<your-api-key>',
    ethereumApiUrl: 'https://eth-goerli.g.alchemy.com/v2/<your-api-key>',
    ethereumAccountPrivateKey: '<private-key-to-ethereum-account-of-sender>',
    amountWei: 1000000000,
    recipientAddress: '0x89205A3A3b2A69De6Dbf7f01ED13B2108B2c43e7'
})

transferERC20FromEthereumToMaticUsingPOSBridge

| Property | Required | Default value | Description | | :-------------------------- | :------: | :------------: | :----------------------------------------------------------- | | maticApiUrl | ✅ | - | Matic url to the node api | | ethereumAccountPrivateKey | ✅ | - | Ethereaum private key to the account from where you send ETH | | ethereumApiUrl | ✅ | - | Ethereum url to the node api | | recipientAddress | ✅ | - | Address of the recipient | | amountWei | ✅ | - | Amount to send in wei | | rootTokenAddress | ✅ | - | Token address on ethereum chain | | maticNetwork | :x: | testnet | Network of matic. Set to mainnet for mainnet transfer | | maticVersion | :x: | mumbai | Version of matic. Set to v1 for mainnet transfer | | gasPrice | :x: | 100000000000 | Gas price of the transfer |

example usage

import { transferERC20FromEthereumToMaticUsingPOSBridge } from "@ethereumnetwork/matic-bridge";

...

await transferERC20FromEthereumToMaticUsingPOSBridge({
    maticApiUrl: 'https://polygon-mumbai.g.alchemy.com/v2/<your-api-key>',
    ethereumApiUrl: 'https://eth-goerli.g.alchemy.com/v2/<your-api-key>',
    ethereumAccountPrivateKey: '<private-key-to-ethereum-account-of-sender>',
    amountWei: 1000000000,
    rootTokenAddress: '0x655F2166b0709cd575202630952D71E2bB0d61Af', // DummyERC20Token
    recipientAddress: '0x89205A3A3b2A69De6Dbf7f01ED13B2108B2c43e7'
})

transferERC20FromMaticToEthereumUsingPOSBridge

Note: it can take up to 10 minutes on the testnet and up to 30 minutes on the mainnet. Please don't shut the program during this time as it waits and listens for the proof of burn to occur on the ethereum.

| Property | Required | Default value | Description | | :------------------------- | :------: | :------------------------------------------: | :------------------------------------------------------------------------------------------------------------------- | | maticApiUrl | ✅ | - | Matic url to the node api | | accountPrivateKey | ✅ | - | Account private key to the account from where you send ERC20 | | ethereumHttpsApiUrl | ✅ | - | Ethereum https url to the node api | | ethereumWebsocktesApiUrl | ✅ | - | Ethereum websockets url to the node api | | recipientAddress | ✅ | - | Address of the recipient | | amountWei | ✅ | - | Amount to send in wei | | childTokenAddress | ✅ | - | Token address on the matic chain | | rootChainProxyAddress | :x: | 0x2890ba17efe978480615e330ecb65333b880928e | Address of the chain proxy on the ethereum. Set to 0x86E4Dc95c7FBdBf52e33D563BbDB00823894C287 for mainnet transfer | | maticNetwork | :x: | testnet | Network of matic. Set to mainnet for mainnet transfer | | maticVersion | :x: | mumbai | Version of matic. Set to v1 for mainnet transfer | | gasPrice | :x: | 100000000000 | Gas price of the transfer |

example usage

import { transferERC20FromMaticToEthereumUsingPOSBridge } from "@ethereumnetwork/matic-bridge";

...

await transferERC20FromMaticToEthereumUsingPOSBridge({
    maticApiUrl: 'https://polygon-mumbai.g.alchemy.com/v2/<your-api-key>',
    ethereumHttpsApiUrl: 'https://eth-goerli.g.alchemy.com/v2/<your-api-key>',
    ethereumWebsocktesApiUrl: 'wss://eth-goerli.g.alchemy.com/v2/<your-api-key>',
    accountPrivateKey: '<private-key-to-matic-account-of-sender>',
    amountWei: 1000000000,
    childTokenAddress: '0xfe4F5145f6e09952a5ba9e956ED0C25e3Fa4c7F1', // DummyERC20Token
    recipientAddress: '0x89205A3A3b2A69De6Dbf7f01ED13B2108B2c43e7'
})

transferERC721FromEthereumToMaticUsingPOSBridge

| Property | Required | Default value | Description | | :-------------------------- | :------: | :------------: | :----------------------------------------------------------- | | maticApiUrl | ✅ | - | Matic url to the node api | | ethereumAccountPrivateKey | ✅ | - | Ethereaum private key to the account from where you send ETH | | ethereumApiUrl | ✅ | - | Ethereum url to the node api | | recipientAddress | ✅ | - | Address of the recipient | | tokenId | ✅ | - | Token id | | rootTokenAddress | ✅ | - | Token address on ethereum chain | | maticNetwork | :x: | testnet | Network of matic. Set to mainnet for mainnet transfer | | maticVersion | :x: | mumbai | Version of matic. Set to v1 for mainnet transfer | | gasPrice | :x: | 100000000000 | Gas price of the transfer |

example usage

import { transferERC721FromEthereumToMaticUsingPOSBridge } from "@ethereumnetwork/matic-bridge";

...

await transferERC721FromEthereumToMaticUsingPOSBridge({
    maticApiUrl: 'https://polygon-mumbai.g.alchemy.com/v2/<your-api-key>',
    ethereumApiUrl: 'https://eth-goerli.g.alchemy.com/v2/<your-api-key>',
    ethereumAccountPrivateKey: '<private-key-to-ethereum-account-of-sender>',
    tokenId: 5,
    rootTokenAddress: '0x084297B12F204Adb74c689be08302FA3f12dB8A7', // DummyERC721Token
    recipientAddress: '0x89205A3A3b2A69De6Dbf7f01ED13B2108B2c43e7'
})

transferERC721FromMaticToEthereumUsingPOSBridge

Note: it can take up to 10 minutes on the testnet and up to 30 minutes on the mainnet. Please don't shut the program during this time as it waits and listens for the proof of burn to occur on the ethereum.

| Property | Required | Default value | Description | | :------------------------- | :------: | :------------------------------------------: | :------------------------------------------------------------------------------------------------------------------- | | maticApiUrl | ✅ | - | Matic url to the node api | | accountPrivateKey | ✅ | - | Account private key to the account from where you send ERC20 | | ethereumHttpsApiUrl | ✅ | - | Ethereum https url to the node api | | ethereumWebsocktesApiUrl | ✅ | - | Ethereum websockets url to the node api | | recipientAddress | ✅ | - | Address of the recipient | | tokenId | ✅ | - | Token id | | childTokenAddress | ✅ | - | Token address on the matic chain | | rootChainProxyAddress | :x: | 0x2890ba17efe978480615e330ecb65333b880928e | Address of the chain proxy on the ethereum. Set to 0x86E4Dc95c7FBdBf52e33D563BbDB00823894C287 for mainnet transfer | | maticNetwork | :x: | testnet | Network of matic. Set to mainnet for mainnet transfer | | maticVersion | :x: | mumbai | Version of matic. Set to v1 for mainnet transfer | | gasPrice | :x: | 100000000000 | Gas price of the transfer |

example usage

import { transferERC721FromMaticToEthereumUsingPOSBridge } from "@ethereumnetwork/matic-bridge";

...

await transferERC721FromMaticToEthereumUsingPOSBridge({
    maticApiUrl: 'https://polygon-mumbai.g.alchemy.com/v2/<your-api-key>',
    ethereumHttpsApiUrl: 'https://eth-goerli.g.alchemy.com/v2/<your-api-key>',
    ethereumWebsocktesApiUrl: 'wss://eth-goerli.g.alchemy.com/v2/<your-api-key>',
    accountPrivateKey: '<private-key-to-matic-account-of-sender>',
    tokendId: 5,
    childTokenAddress: '0x757b1BD7C12B81b52650463e7753d7f5D0565C0e', // DummyERC721Token
    recipientAddress: '0x89205A3A3b2A69De6Dbf7f01ED13B2108B2c43e7'
})

transferERC1155FromEthereumToMaticUsingPOSBridge

| Property | Required | Default value | Description | | :-------------------------- | :------: | :------------: | :----------------------------------------------------------- | | maticApiUrl | ✅ | - | Matic url to the node api | | ethereumAccountPrivateKey | ✅ | - | Ethereaum private key to the account from where you send ETH | | ethereumApiUrl | ✅ | - | Ethereum url to the node api | | recipientAddress | ✅ | - | Address of the recipient | | tokenIds | ✅ | - | Token ids | | amounts | ✅ | - | Amounts in wei | | rootTokenAddress | ✅ | - | Token address on ethereum chain | | maticNetwork | :x: | testnet | Network of matic. Set to mainnet for mainnet transfer | | maticVersion | :x: | mumbai | Version of matic. Set to v1 for mainnet transfer | | gasPrice | :x: | 100000000000 | Gas price of the transfer |

example usage

import { transferERC1155FromEthereumToMaticUsingPOSBridge } from "@ethereumnetwork/matic-bridge";

...

await transferERC1155FromEthereumToMaticUsingPOSBridge({
    maticApiUrl: 'https://polygon-mumbai.g.alchemy.com/v2/<your-api-key>',
    ethereumApiUrl: 'https://eth-goerli.g.alchemy.com/v2/<your-api-key>',
    ethereumAccountPrivateKey: '<private-key-to-ethereum-account-of-sender>',
    tokenIds: [5, 2],
    amounts: [1000000000, 5000000000],
    rootTokenAddress: '0x2e3Ef7931F2d0e4a7da3dea950FF3F19269d9063', // DummyERC1155Token
    recipientAddress: '0x89205A3A3b2A69De6Dbf7f01ED13B2108B2c43e7'
})

transferERC1155FromMaticToEthereumUsingPOSBridge

Note: it can take up to 10 minutes on the testnet and up to 30 minutes on the mainnet. Please don't shut the program during this time as it waits and listens for the proof of burn to occur on the ethereum.

| Property | Required | Default value | Description | | :------------------------- | :------: | :------------------------------------------: | :------------------------------------------------------------------------------------------------------------------- | | maticApiUrl | ✅ | - | Matic url to the node api | | accountPrivateKey | ✅ | - | Account private key to the account from where you send ERC20 | | ethereumHttpsApiUrl | ✅ | - | Ethereum https url to the node api | | ethereumWebsocktesApiUrl | ✅ | - | Ethereum websockets url to the node api | | recipientAddress | ✅ | - | Address of the recipient | | tokenIds | ✅ | - | Token ids | | amounts | ✅ | - | Amounts in wei | | childTokenAddress | ✅ | - | Token address on the matic chain | | rootChainProxyAddress | :x: | 0x2890ba17efe978480615e330ecb65333b880928e | Address of the chain proxy on the ethereum. Set to 0x86E4Dc95c7FBdBf52e33D563BbDB00823894C287 for mainnet transfer | | maticNetwork | :x: | testnet | Network of matic. Set to mainnet for mainnet transfer | | maticVersion | :x: | mumbai | Version of matic. Set to v1 for mainnet transfer | | gasPrice | :x: | 100000000000 | Gas price of the transfer |

example usage

import { transferERC1155FromMaticToEthereumUsingPOSBridge } from "@ethereumnetwork/matic-bridge";

...

await transferERC1155FromMaticToEthereumUsingPOSBridge({
    maticApiUrl: 'https://polygon-mumbai.g.alchemy.com/v2/<your-api-key>',
    ethereumHttpsApiUrl: 'https://eth-goerli.g.alchemy.com/v2/<your-api-key>',
    ethereumWebsocktesApiUrl: 'wss://eth-goerli.g.alchemy.com/v2/<your-api-key>',
    accountPrivateKey: '<private-key-to-matic-account-of-sender>',
    tokenIds: [5, 2],
    amounts: [1000000000, 5000000000],
    childTokenAddress: '0xA07e45A987F19E25176c877d98388878622623FA', // DummyERC1155Token
    recipientAddress: '0x89205A3A3b2A69De6Dbf7f01ED13B2108B2c43e7'
})

Full docs

License

MIT