Connecting a chain to MetaMask
So you have a Testnet running with a chain and you'd like to test. With Harbor commands, we can execute a command to retrieve logs on a running chain by using the harbor log
:
harbor log actor --testnet-id <testnet_id> --name <chain_name/actor_name>
But what if you wanted to take testing to the next level? For example: if you have a dApp that you'd like to test on your private chain, then connecting our private chain to MetaMask would be ideal.
Let's follow the steps below to connect MetaMask to our private chain.
Retrieve the endpoint​
You can retrieve your chain's endpoint via the UI or the CLI.
UI​
If you have a running Testnet in your project, click on the Testnet card to navigate to its details page.
In the Testnet details page, pick the chain you'd like to connect to and retrieve the endpoint by clicking on the copy icon in the top right corner
CLI​
We can also retrieve our endpoints through the CLI. To do so, run the following command:
harbor describe testnet --name <testnet_name>
This will give you the Testnet information in the following format:
Testnet name: sample-testnet-name
+----------+---------+---------------------------+
| CHAINS | STATUS | ENDPOINT |
+----------+---------+---------------------------+
| ethereum | RUNNING | http://34.213.53.1:3000 |
+----------+---------+---------------------------+
Total chains count: 1
+--------+---------+---------------------------+
| ACTORS | STATUS | ENDPOINT |
+--------+---------+---------------------------+
| ipfs | RUNNING | http://43.205.242.46:5000 |
+--------+---------+---------------------------+
Total off-chain actors count: 1
Wallets and Contracts for chain ethereum
+--------------------------------------------+----------+---------+-------------------------------+----------+
| ADDRESS | TYPE | NAME | BALANCE | CHAIN |
+--------------------------------------------+----------+---------+-------------------------------+----------+
| 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 | wallet | - | ETH-9999999068271250000000, | ethereum |
| 0x70997970C51812dc3A010C7d01b50e0d17dc79C8 | wallet | - | ETH-10000000000000000000000, | ethereum |
| 0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC | wallet | - | ETH-10000000000000000000000, | ethereum |
| 0x5FbDB2315678afecb367f032d93F642f64180aa3 | contract | Greeter | ETH-0, | ethereum |
+--------------------------------------------+----------+---------+-------------------------------+----------+
Find your chain of choice and copy the endpoint.
Connect MetaMask to endpoint​
Using your endpoint, open MetaMask via your browser of choice. Currently, MetaMask is supported on Chrome, Firefox, Brave, Edge, and Opera.
If you haven't already, download MetaMask's browser extension here.
Manually add a network​
After downloading the MetaMask extension and configuring your account, open it again from the browser.
Click on the Ethereum Mainnet
button on the top to drop down a list of Networks. At the bottom of the list, you should see the Add network
button. Click on that button to be taken to the next page.
A new tab should open in your browser of choice. You are now on a page where you can add pre-configurated networks. At the bottom of the page, you should see the Add a network manually
button. Click on that button to be taken to the next page.
You should see a form to add the Network:
The inputs you need to add are the following:
Network name
is the name of your custom Harbor chain. Add a name of your choiceNew RPC URL
is the endpoint that you retrieved earlier via the CLI or the UIChain ID
should be1337
, or whatever your configuration saysCurrency symbol
should be:ETH
if you are adding an Ethereum chainAVAX
if you are adding an Avalanche chainMATIC
if you are adding an Polygon chainFTM
if you are adding an Fantom chainOP
if you are adding an Optimism chain
After you add all the values, click the Save
button to connect to your new Harbor-based network!
Sometimes, the network you are trying to add has the same chain ID as another network. Read on how to resolve this.
Add tokens​
To see your tokens, you need to add the token addresses into your MetaMask extension. Open the MetaMask extension, click on the Assets
tab, then click Import tokens
under Don't see your token?
after scrolling down.
Once the Import tokens
page is open, paste in the following:
Token contract address
Token symbol
Token decimal
The above error message under the Token contract address
is raised because we are on a chain ID that's different than the mainnet. You can ignore it because our Testnet forks the mainnet, even if it has a different chain ID. So therefore the contract address is the same.
Sometimes, the token(s) you are trying to add will be unsuccessful. Read on how to resolve this.
Find all the supported tokens' addresses, symbols and decimals here. These tokens are only supported in Ethereum.