Connecting MetaMask with a Private Blockchain (2024)

Connecting MetaMask with a Private Blockchain (2)

Jefferson Xavier

Posted on • Updated on

Connecting MetaMask with a Private Blockchain (3) Connecting MetaMask with a Private Blockchain (4) Connecting MetaMask with a Private Blockchain (5) Connecting MetaMask with a Private Blockchain (6) Connecting MetaMask with a Private Blockchain (7)

This post is the second in a series of posts that demonstrate how to create your own Private Blockchain. The previous post shows the step by step to create the private ethereum blockchain, we will connect to that blockchain using the MetaMask.

Below you can see the current structure of the private blockchain built:

You can read the previous post here.

MetaMask

The MetaMask is a crypto wallet to Ethereum. Can be used to start and manage private wallets to users in blockchain network. By default is set to the Ethereum Mainnet, but can be used to any others blockchains based on Ethereum.

Get Start

Follow the next steps to finish this tutorial:

  • Install MetaMask and create an account
  • Add My Blockchain network
  • Import the miner account created using Geth
  • Transfer funds between accounts

Install MetaMask and Create the First Account

The MetaMask can be installed like an extension to most popular browsers or a mobile app. In this post, we will use MetaMask like a extension in Brave. This process is similar for other browsers like Chrome or Firefox.

Go to download page and click at "Install Metamask For BROWSER_NAME". Follow the installation steps until finish.

A similar window should be open at the end of installation:

Click at "Get Started" to initialize MetaMask. In next step you can import or create a new wallet. Let's create a new one.

Define the MetaMask password and keep account recovery words in a safe place. Without your private key or that words it's impossible recover your blockchain account.

After that, you should see the inital MetaMask screen with your account created like this:

The account was created on the main ethereum network as shown in the upper right corner of the screen: Ethereum Mainnet.

Add My Blockchain Network

Let's add our Blockchain Network to MetaMask. Click on Ethereum Mainnet and select Add New Network option.

Define values to My Blockchain and click o Save button.

  • Network Name: My Blockchain
  • New RPC URL: http://127.0.0.1:8545
  • Chain ID: 1234
  • Currency Symbol: MYBL

Explanation:

  • Network Name: Any string to reference your blockchain name.
  • New RPC URL: The HTTP Server URL. In our the HTTP Server is running on Node1 in default port 8545.
  • Chain ID: The chainId defined in genesis block.
  • Currency Symbol: A symbol to reference the coin in your blockchain. If you not define it, the default value is ETH.

All Done!! Your blockchain network has been added and you should be see your account created in this network without balance.

Import Account

In previous post we create an account using Geth and we did the mining of some blocks with that account. Let's import that account to MetaMask to see balance and transfer funds to account created in this post.

Select "Import Account" option in MetaMask, choose "Select Type" as JSON File, choose account json file in your blockchain, type the password and click on "Import" button.

The account json file can be found in database of the Node1 in your blockchain, the path to this file contains the account address, something like this:

node1/keystore/UTC--2022-03-17T20-40-36.929865867Z--bd3156b239e2bb8d073406e67eba59a651be18f0

All Done! The account has been imported to MetaMask. You can see that account in inital page selecting the Account 2.

Transfer Funds

Let's transfer some value from Account 2 to Account 1 to validate the structure and finish this post.

First, go to Account 1 in MetaMask and copy the Account Public Address and back to Account 2. In my case the public address of the Account 1 is:

0xE4f4206F11C249aeCfE5AD8a4DDcfae60343d746.

In Account 2 click on "Send" button, paste the public address of the Account 1 and type the value to transfer. Click on "Next" button and then click on "Confirm" button.

The transaction will be with status "Pending", waiting for a block to be mined for validation.

Now, it's necessary start the mining to validate that transaction. Let's do this in our blockchain using Geth in Javascript Console from Node1. Type the command:

miner.start()

Waiting some seconds and verify your account in MetaMask again.

Obs: If you want, you can stop the mining in Node1 after the transaction validation. Type command to stop the mining:

miner.stop()

All Done!. The transaction was validated and the Account 1 received the 100 MYBL.

Blockchain Structure

Next Steps

You can create new accounts to your blockchain using MetaMask or Geth to increment your tests. Do more transactions, using other accounts to execute mining in Node1 or Node2. That's it.

References

Go Ethereum
MetaMask

Connecting MetaMask with a Private Blockchain (2024)

FAQs

Connecting MetaMask with a Private Blockchain? ›

Select "Import Account" option in MetaMask, choose "Select Type" as JSON File, choose account json file in your blockchain, type the password and click on "Import" button. All Done! The account has been imported to MetaMask. You can see that account in inital page selecting the Account 2.

How to connect MetaMask to a private network? ›

Adding a custom network to MetaMask with Chainlist

Connect to your Ledger ETH account. On Chainlist, you need to select the network you want to add to MetaMask. For example, choose Binance Smart Chain. Allow Chainlist to add a network to MetaMask by clicking Approve.

How to connect MetaMask to different blockchains? ›

Getting the Chain ID & Currency Symbol

After getting the RPC URL, we need to get the chain ID and currency symbol for that particular network. Chain ID is a unique identifier assigned to each blockchain network. It is like a digital fingerprint that helps MetaMask recognize and connect to the right network.

How do I connect local blockchain to MetaMask? ›

Steps to connect to a blockchain network
  1. Log in to your MetaMask wallet. Log in (MetaMask)
  2. Go to “Settings” from the account options, which is a circle icon. Settings (MetaMask)
  3. In settings, select “Networks.” Network settings (MetaMask)
  4. Press the “Add Network” button. Add network (MetaMask)
Jul 7, 2022

What blockchains are compatible with MetaMask? ›

MetaMask is a widely acclaimed cryptocurrency wallet renowned for its extensive support of multiple blockchains, including Ethereum, Binance Smart Chain, and many layer 2 networks like Arbitrum, Polygon, etc.

How does MetaMask communicate with blockchain? ›

Metamask is primarily used for facilitating transactions and interacting with decentralized applications on the Ethereum blockchain. Users can send and receive Ether and ERC-20 tokens, as well as engage in decentralized exchanges (DEXs), lending and borrowing protocols, and yield farming.

Does MetaMask know my private key? ›

You should never share your private key with anyone, including the MetaMask team. No MetaMask representative, including our Support team, will ever ask for your private key, regardless of the context. If someone does ask for your private key, assume they are trying to scam you, and do not hand it over.

What is bridging in MetaMask? ›

The Bridge feature in MetaMask Portfolio does exactly what it says on the tin: it pulls together bridging quotes for you to choose from. From here, you can pick the best quote for you and move your tokens to the network you need. Think of it as an aggregator of aggregators, or meta-aggregator.

Does MetaMask report to the IRS? ›

MetaMask itself does not report to the IRS or any tax authorities. However, it's important to note that individuals are generally responsible for reporting their cryptocurrency transactions and any resulting taxable events to the IRS or relevant tax authorities.

What is the default network for MetaMask? ›

MetaMask is set up for use on Ethereum by default.

How do I manually connect MetaMask wallet? ›

Manually connecting to a dapp
  1. In MetaMask, click on the three dots menu in the upper right corner, and then on Connected sites:
  2. Click the Manually connect to current site button at the bottom of the list.
  3. Next, select the account(s) you want to connect, then follow the prompts to confirm the process:

How do I connect my crypto wallet to MetaMask? ›

Click your profile icon, and then click My Settings. Click Connect wallet > MetaMask. Note: You'll be prompted to install the MetaMask extension (browser) or app (phone) if you don't already have them. In the MetaMask extension or mobile app, enter your MetaMask wallet password, and then click Unlock.

Does MetaMask support all chains? ›

MetaMask is built specifically for Ethereum and Ethereum Virtual Machine (EVM) compatible chains. In other words, MetaMask is built only for blockchains that can run Ethereum smart contracts. Because Solana is not EVM-compatible, MetaMask does not support the ability to hold and trade Solana-based assets.

What is the difference between MetaMask and blockchain? ›

By comparing MetaMask vs Blockchain overall scores, we clearly see that MetaMask has the higher overall score of 6.6. Blockchain, on the other hand, has scored 6.0 final points. One of the best hardware cryptocurrency wallets ever made.

How to get rpc url? ›

Dashboard Configuration
  1. Go to the Configurations page in your Dashboard.
  2. Click on the chain to open the details tab.
  3. Click the down down arrow to expand a network.
  4. Enter your Provider Url.
  5. Click the test button to check url.

How do I manually add a network to MetaMask? ›

Adding a network manually​
  1. Click on the network selector button. This will display a list of networks that you've added already.
  2. Click 'Add network':
  3. MetaMask will open in a new tab in fullscreen mode. From here, find and the 'Add network manually' button at the bottom of the network list.

Top Articles
Latest Posts
Article information

Author: Jerrold Considine

Last Updated:

Views: 5715

Rating: 4.8 / 5 (58 voted)

Reviews: 89% of readers found this page helpful

Author information

Name: Jerrold Considine

Birthday: 1993-11-03

Address: Suite 447 3463 Marybelle Circles, New Marlin, AL 20765

Phone: +5816749283868

Job: Sales Executive

Hobby: Air sports, Sand art, Electronics, LARPing, Baseball, Book restoration, Puzzles

Introduction: My name is Jerrold Considine, I am a combative, cheerful, encouraging, happy, enthusiastic, funny, kind person who loves writing and wants to share my knowledge and understanding with you.