How to add Custom Network to Metamask
Tags: web3, metamask, ethereum
Published: 2022-03-12 19:07:21

Hello guys, this will be a post where I will show you how to add custom local network to Metamask.


{% youtube https://www.youtube.com/watch?v=4dymcK4BJn4 %}

> This article assumes that you already **installed metamask** and you have been **created an account** before. If you don't installed yet, go to [Metamask](https://metamask.io/) and download it to your browser.

## Interacting with Metamask

Click on the extension and go the settings,

![Metamask Preview](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ggjstcpd35n1fisiy6bp.png)

if you scroll down a little bit, you will see network option. Click on that and press add network button. This should open a form in the new tab. 

It should be something like this;

![Add New Network](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c5mteuaax7gzi0fk6wd4.png)

## Adding Custom Network

In our tutorial, we will add custom local network to metamask. [Ganache](https://trufflesuite.com/ganache/) or [Hardhat](https://hardhat.org/) can be an example for that. 

> If you want to add other EVM compatible networks, you can also do that!

**Network Name**: Localhost:7545
**New RPC URL**: http://localhost:7545
**Chain Id**: 1337
**Currency Symbol**: ETH

![Adding Network](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/68tx7wrzv8pmbegus0w4.png)

After you saved that, you can see something like this;

![Network added](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mbkzxnmcfyi1gzg07mec.png)

Wait, whaaat! I can't see my ETH in there. Don't freak out :) It is because we do not imported our local accounts that **node** gives us.

## Installing Ganache

For this tutorial you need to install ganache in order follow along. Go to [Ganache](https://trufflesuite.com/ganache/) and download the CLI.

After you installed it you can run the CLI on your machine.

You should see something like this;

![Ganache CLI](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l211lzskgwgwixcysdah.png)

Click quickstart and you have everything you need.

![Ganache CLI - In Depth](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/b8ox9kru9qnwevmbnuts.png)

## Importing Accounts to Metamask
What we need to grab the private key of one of our test accounts and import it to Metamask.

_For Ganache_, you can grab it inside it Ganache CLI, _for hardhat and other nodes_, you can copy them right through the console once you **start the node** in your terminal.

Click the show keys account that is inside accounts tab. It will open a modal and you grab private key from there.

![Ganache private key](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jlkpks7kldnbutk4l4nh.png)

> **Do not ever use** test accounts in real blockchain

![anache Private Key Modal](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6r8sbt67g8fcnpwnxiid.png)
 

 Copy that private key and click on the Metamask extention again. Go profile > import account and you will see this screen;

![Import Account to Metamask](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w2529g0ln4oio455cb6c.png)
 
and.. paste that private key to that input and click import.

You should see that your active account is changed and it is labeled as imported. And you can also see that it contains test balances inside of the account.

![Labeled as Imported](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pnti65zafr45ay4w7uaw.png)
 
Great!! Now you can build your dream application and test using local nodes.

## (Optional) - Labeling the Account

Metamask also offers labeling the account so that if you use it for development it will be easier to differenciate them from real accounts.

Once you clicked the extension again, click the three dots and go to account details.

![Three Dots](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8t7dnri61lzhn8h4onlw.png)
 
This should open a modal which you see the account information

![Account Info](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i5uonnyt2d7qvf8mxs5v.png)

From there just click the pencil icon and change the name whatever you want. And save it.

![Saving the Name](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9qvhexttjyp1t9168dqa.png)

Now you should see the updated names in myAccounts section

![MyAccounts tab](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/omrr3giefys9ulmbz9mu.png)

---

And that is all from my side! Thank you so much for reading this far, and if you want to learn more topics like this feel free to subscribe [my youtube channel](https://www.youtube.com/channel/UC9CYQu1fmu0hs29_6BjxLSw/videos?sub_confirmation=1) which I started last week!

That's all and have a wonderful day :)

- [Twitter](https://twitter.com/afozbek_)
- [Youtube](https://www.youtube.com/channel/UC9CYQu1fmu0hs29_6BjxLSw/videos?sub_confirmation=1)
- [Instagram](https://instagram.com/furkan.codes)
- [Github](https://github.com/afozbek)