How to Migrate DApp from Rinkeby to Mumbai

How to Migrate DApp from Rinkeby to Mumbai

We Web3 developers are facing, once in lifetime tragedy. A tragedy none of us think we will ever meet. We have to say "good bye" to our favorite and most popular test network Rinkeby.

During this period of grief, we have to handle one more enormous task of migrating our DApps from Rinkeby to another testnet. This article will not remove your sorrows of losing Rinkeby but will help you migrate your DApp.

D_D Newsletter CTA

Steps Involved in Migrating

  1. Update the RPC node
  2. Re-deploy the smart contract
  3. Make adjustments in frontend

1. Update the RPC Node

The first task for migrating your DApp is to get a new RPC node of the Mumbai testnet. You can use any RPC provider to get a Mumbai testnet RPC node, but I will use Ankr.

Go to their RPC service section by clicking on this link. Search for "Polygon Network" in the Ankr endpoint list. Click on the "More" button to view Polygon mainnet and Polygon Mumbai testnet.

Ankr Endpoint Page

Select testnet on the network section and copy the public RPC key.

Ankr Testnet Section

That's it. You got a Mumbai RPC node. Now that we have RPC Node, we will replace our old Rinkeby RPC with the new Mumbai RPC key in our DApp. Let's Go!

I assume you are using "Hardhat" as a Solidity development environment. If you are following any quality tutorial or documentation, you probably store your RPC key in an .env file. You need to replace it with a new Mumbai RPC key.

Ankr RPC node in .env

As we are using a public RPC node. You can also put your RPC key in your hardhat.config.js.

RPC key in public

You can also use this preferred method of storing your private key for your PolygonScan and RPC key in the .env file and importing them in the hardhat.config.js.

In your hardhat.config.js file, replace rinkeby with mumbai inside the networks section.

ankr rinkeby to mumbai.png

2. Re-Deploy the Contract

First, ensure you have some test Matic in our wallet, which you use to deploy the smart contract. You can use this Mumbai faucet to get some testnet Matic.

Run this command to deploy your smart contract.

$ npx hardhat run scripts/deploy.js --network mumbai


$ npx hardhat run --network mumbai

If everything works according to plan, you will get an updated "Contract Address." If you added console.log in your deploy script, which you should. You will get output like this.


##3. Make adjustments in frontend Update your smart contract address in your frontend folder or index file.

Set chainId to 80001 like chainId == 80001 and replace the word 'Rinkeby' with 'Mumbai'.


Rinkeby will always be remembered in our hearts and the stories we will tell to our future generation.

Don't forget to push your code to GitHub so all the world can see your fantastic work.

I hope you learned something new and solved the problem. Thanks for reading. Have fun!

D_D Newsletter CTA

You can follow me on Twitter, GitHub and Linkedin. Keep your suggestions and comments coming!