Code Monkey home page Code Monkey logo

ethtopolygon_bridge's Introduction

ERC721Mint

Deploy

npx hardhat run scripts/ethereum/deploy_ERC721Mint.js --network mainnet

Verify

npx hardhat run scripts/ethereum/verify_ERC721Mint.js --network mainnet

Polygon ERC721Mint

Deploy

npx hardhat run scripts/polygon/deploy_PolygonERC721Mint.js --network polygon

Verify

npx hardhat run scripts/polygon/verify_PolygonERC721Mint.js --network polygon


Instruction for transfer tokens between Ethereum and Polygon

After our contracts are linked in mapper, we can move tokens from Ethereum to Polygon and back.
Attention! Only one of the managers appointed by the owner can produce mint of the ERC721Mint contract,
so you must first add the desired address to the managers.

Child Chain Manager address: 0xA6FA4fB5f76172d178d61B04b0ecd319C5d1C0aa

How to edit env

  1. You have to copy the fields of env.example to .env
  2. Let's analyze each field:
  • PRIVATE_KEY: the private key of your wallet
  • SCAN_API_KEY: API key created from your ethereum account dashboard
  • SCAN_API_KEY_POLYGON: API key created from your polygon account dashboard
  • RPC_NODE_URL_RINKEBY: link to the rpc_node of the rinkeby network
  • RPC_NODE_URL_MAINNET: link to the rpc_node of the mainnet network
  • RPC_NODE_URL_GOERLI: link to the rpc_node of the goerli network
  • RPC_NODE_URL_MUMBAI: link to the rpc_node of the mumbai network
  • RPC_NODE_URL_POLYGON: link to the rpc_node of the polygon network
  • ERC721MINT_NAME: desired erc721 token name
  • ERC721MINT_SYMBOL: desired symbol of the token
  • ERC721MINT_URI: link to the URI of your token
  • ETHEREUM_ERC721: the address of your erc721 token in ethereum network
  • POLYGON_ERC721: the address of your erc721 token in polygon network
  • USER1_FROM: the address of your wallet
  1. Fill in the empty fields

How config.js and utils.js work

utils.js - script exports functionality to connect to the matic network

You can change parameters into getPOSClient for testing needs, for example:

const getPOSClient = (network = 'testnet', version = 'mumbai')

config.js - exports variables for .env file:

  • pos.parent.erc721 and pos.child.erc721 - smart contract addresses for ethereum and matic networks
  • user address and private key
  • backend service and proof api links
  • rpc node urls

All raw addresses are default.

Deposit (or how to transfer tokens from Ethereum to Polygon)

  1. Approve token id from ERC721Mint to the address ERC721PredicateProxy (0xE6F45376f64e1F568BD1404C155e5fFD2F80F7AD)
  2. Go to the RootChainManagerProxy and execute depositFor (0x7CfA0f105a4922E89666D7D63689d9C9b1eA7a19)
  • user (address) - the address of the user to whom the token will be transferred (specify your own)
  • rootToken (address) - address ERC721Mint
  • depositData (bytes) - encoded abi tokenId

Withdraw (or how to transfer tokens from Polygon to Ethereum)

  1. We specify the necessary token addresses in .env:
  • parent erc721 (ERC721Mint): ETHEREUM_ERC721
  • child erc721 (Polygon_ERC721Mint): POLYGON_ERC721
  • sender's address: USER1_FROM
  1. Withdrawal process:
  • Open withdraw_start.js, change the tokenId to the token id hash (for example, for token id = 5, token id hash will be equal to โ€˜0x0000000000000000000000000000000000000000000000000000000000000005โ€™), execute the script, copy the txHash
  • Waiting for the checkpoint (~15 minutes)
  • Opening withdraw_exit.js, substitute txHash in withdrawStartTxHash, execute the script

ethtopolygon_bridge's People

Contributors

xopek1337 avatar molpecj avatar m1ntm1nd avatar gogolevdms avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.