1. Home
  2. Docs
  3. Matic
  4. PoS Bridge
  5. Mapping Assets Using POS

Mapping Assets Using POS

Mapping Assets using POS

Introduction

Mapping is necessary in order to transfer your assets to and from the Ethereum and Matic Network.

  • The Root chain :: refers to either Goerli or Ethereum Mainnet
  • The Child chain :: refers to either Matic Mumbai or Matic Matic Mainnet

If you already have your token contract deployed on the Root chain and want to move it to Child chain, then you should follow this walkthrough, but if you intend to deploy your contract on Matic Mainnet first, mint the tokens on the Child chain first and then move them back to the Root chain. You should then follow this guide.

Standard Child Token

If you just need a standard ERC20/ERC721/ERC1155 contract, then you can go ahead and submit a mapping request at https://mapper.matic.today/ and we will auto deploy the standard child token contract for you.

Standard Child Token contract will look like these:-

  1. ERC20
  2. ERC721
  3. ERC1155

Please visit this link to understand how to create a new mapping request.

Custom Child Token

If you need a custom child token contract which has additional functions to the standard functions, then you will have to deploy your token contracts on the Child chain and submit a mapping request here and include the address of your deployed child token contract. Let’s describe an example of creating a custom child token contract.

Your custom child contract should follow certain guidelines before you deploy it on the child chain.

deposit method should be present in your custom child contract. This function is called by the ChildChainManagerProxy contract whenever a deposit is initiated from the root chain. This deposit function internally mints the token on the child chain.

withdraw method should be present in your custom child contract. It can be called to burn your tokens on the child chain. Burning is the first step of your withdrawal process. This withdraw function will internally burn the token on the child chain.

These rules need to followed to maintain proper balance of assets between two chains.

Note: No token minting in constructor of child token contract.

Implementation

Now that we covered why we need to implement deposit & withdraw methods in child token contract, we can now proceed for implementing it.

One thing you might notice in the code sample above is that the deposit function can be called by anyone, which is not allowed. In order to prevent this, we’re going to make sure it can only be called by ChildChainManagerProxy.

This updated implementation can be used for mapping.

Steps :

  1. Deploy root token on root chain i.e. {Goerli, Ethereum Mainnet}
  2. Ensure your child token has the deposit & withdraw functions.
  3. Deploy the child token on child chain i.e. {Matic Mumbai, Matic Mainnet}
  4. Submit a mapping request, to be resolved by team.

Request Submission

Please go use this link to submit a mapping request.

Originally published @ https://docs.matic.network/docs/develop/ethereum-matic/pos/mapping-assets

Was this article helpful to you? Yes No

How can we help?