How To Migrate Dapp from Rinkeby to Mumbai
Tags: blockchain, rinkeby, rpc, ethereum
Published: 2022-09-04 05:30:51

We Web3 Developers are facing, once in a lifetime tragedy. Tragedy, none of us think we will ever face. Saying Good Bye to our favorite and most popular Testnetwork **_Rinkeby_**. During this period of Grief. We have to handle, one more humongous task of Migrating our dApps from rinkeby to another testnet. This article will not take away your sorrows of losing Rinkeby but will help you migrate your dApp.

## Steps Involve 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 RPC Node of the new Testnetwork, for our example, we will be using _Mumbai_ Testnetwork. You can use any Node Provider to get Mumbai testnetwork RPC Node. I will use [Ankr](https://www.ankr.com/).

Go to their RPC Service section by clicking on this [link](https://www.ankr.com/rpc/).

Now Search for Polygon Network in Ankr Endpoint. Click on the "More" Button to view Polygon Mainnet and Polygon Mumbai Testnetwork.


![Ankr Endpoint Page](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/664k6940ymbg1m6u5q5r.png)

Select Testnet on the network section and Copy the Public RPC Key.

![Ankr Testnet Section](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nv0wgrrorjz7bta34m60.png)

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

I am assuming you are using "Hardhat" as a Solidity Development Framework. Most probably if you are following any quality tutorial or documentation. You probably store your RPC Key in `.env` file. You need to replace it with a new Mumbai RPC node.


![Ankr RPC Node in .env](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nutvwpykjpxl47f51scz.png)

As we are using Public RPC Node. You can also simply put your RPC key in your `hardhat.config.js`.

![RPC Key in Public](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ae9oxyl95olq9xw5tlsj.png)

You can also use this preferred method of storing all your keys like Private Key, PolygonScan key, and RPC key in the `.env` file and importing them in the `hardhat.config.js` file. Now in your `hardhat.config.js` file. Replace `rinkeby` with `mumbai` inside the `networks` section.

![Replacing Rinkeby To Mumbai](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ysijhw9yakas6mq61mot.png)

##2. Re-Deploy the Contract
First, make sure you have some test Matic in our wallet, which you are using for deploying the smart contract. You can use this Mumbai Faucet to get some test Matic. [Mumbai Faucet](https://mumbaifaucet.com/)

Run this command to deploy your smart contract.
`npx hardhat run scripts/deploy.js --network mumbai` 
                            or
`npx hardhat run <location of your deploy script> --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.

![Contract Address](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xl9afc1blnxz0ak8f9cc.png)

##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'.

![chainID= 80001](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4ysptr1pkwcz7iyxlmqg.png)

> Rinkeby will always be remembered in our hearts and in 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 amazing work.
  

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

You can follow me on [Twitter](https://twitter.com/Aayush_gupta_ji), [GitHub](https://github.com/AAYUSH-GUPTA-coder) and [Linkedin](https://www.linkedin.com/in/aayush-gupta-20023b183/). Keep your suggestions and comments coming!