# 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](https://sitemedia.ams3.digitaloceanspaces.com/blog_banner_v1_d1653cce08.png)](https://devdao.to/blog-newsletter-1)

## 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](https://www.ankr.com/).

Go to their RPC service section by clicking on this [link](https://www.ankr.com/rpc/). 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](https://cdn.hashnode.com/res/hashnode/image/upload/v1662288085210/DPEVa0MSj.png align="left")

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

![Ankr Testnet Section](https://cdn.hashnode.com/res/hashnode/image/upload/v1662288131868/8Ww9kMe1y.png align="left")

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](https://cdn.hashnode.com/res/hashnode/image/upload/v1662288199965/39O9E7f7r.png align="left")

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

![RPC key in public](https://cdn.hashnode.com/res/hashnode/image/upload/v1662288259492/QKK06g8oB.png align="left")

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](https://cdn.hashnode.com/res/hashnode/image/upload/v1662288312623/bg7BVhCAX.png align="left")

## 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](https://mumbaifaucet.com/) to get some testnet Matic. 

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.


![address.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1662288380278/Znlxn2Den.png align="left")

##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://cdn.hashnode.com/res/hashnode/image/upload/v1662288520666/9NdxOeWM8.png align="left")

> 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](https://sitemedia.ams3.digitaloceanspaces.com/blog_banner_v1_d1653cce08.png)](https://devdao.to/blog-newsletter-1)

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!
