In this tutorial, we’ll show you how to connect to your own private blockchain with MetaMask, MyEtherWallet, and Mist.

These tools have all been separately introduced in the following posts:

To be able to follow along, please launch your own blockchain with --rpc mode active, or follow instructions in our post about Launching a private Ethereum blockchain.

Connecting with MetaMask

MetaMask is an extension for Google Chrome to connect to the Ethereum blockchain. It can connect to the mainnet, a testnet, or a private blockchain.

Read a short introduction into using MetaMask here.

For MetaMask to be able to connect to a private or simulated blockchain, it’s important that the node be running with the IPC interface open, which is what we did by passing in the --rpc flag when running Geth in this post.

To connect to our node, we need to pick Localhost 8545 in the network menu.

MetaMask localhost

If you’re using a newer version of MetaMask’s UI, it will probably look more like this.

MetaMask connects to the same Ethereum address generated for both the mainnet and the testnet, so it’s important to remember that it won’t connect to the node’s coinbase address and see its balance, but will instead be connected to your private blockchain with the address already present in MetaMask. For example, if you have the address 0x2489efb207809c237c85c202d0fa78c8b236709c in MetaMask, then connecting to Localhost 8545 (our own running geth node) will connect with that address, but its balance will be 0 because it hasn’t gotten any ether yet on this blockchain.

If you want to connect MetaMask to the coinbase address of your node, you need to go to the account switching option, select “Import Account”, and locate the JSON file of the coinbase account, then upload it and enter the password.

Metamask Import Account

On the newer UI, it’s more like this:

The JSON file of the coinbase account will be in the folder where our blockchain data is saved (the datadir defined in the last post) in the keystore subfolder. In our example, that’s /Users/swader/blockchain/tutorial/keystore.

MetaMask coinbase account

Connecting with MyEtherWallet

The procedure to connect with MyEtherWallet is identical.

Read a short introduction into MyEtherWallet here.

In the top right menu, select Custom network / node.

Custom network

On the next screen, enter information needed to connect to the node. In the case of running the node locally on your computer, you use 127.0.0.1 as the address, 8545 as the port, and the Custom radio button. The name you pick doesn’t matter.

Custom node

After the tab refreshes automatically, you’ll be able to pick the Send Ether and Tokens option and input the JSON file just like with MetaMask above.

Import JSON

After input, the coinbase wallet of our node will be unlocked and ready for use.

Unlocked

Connecting with Mist

To connect Mist, the Ethereum wallet and decentralized app browser to our node, and thus use its wallet functionality, we need to let Mist know we’re working on a private node of a private blockchain. Without providing Mist with these explicit facts, it will attempt to download the entire Ethereum blockchain when starting up for the first time, and that’s not in anyone’s best interest at this point.

Read a short introduction into Mist here.

On OS X, you can run Mist like so:

/Applications/Mist.app/Contents/MacOS/Mist --rpc http://localhost:8545 --swarmurl "null"

On Windows, the path will depend on where you installed it, but should look like this:

C:\PATH_TO_FILE\mist.exe --rpc http://localhost:8545 --swarmurl "null"

On Linux, it will also depend on the installation location but the same principle applies.

After this is done, a warning about the connection not being secure might sometimes appear. Given that it’s a private network and a private blockchain, this warning can be ignored during development. Afterwards, a small splash window will appear on which the link “Launch Application” has to be clicked to run the app.

After launching, the coinbase account of the node will be visible in the UI, along with its balance.

Mist

If you run the miner in the geth console with miner.start as described in the last post, you’ll see a little mining icon in the bottom left corner of the screen and the number of connected nodes (the people icon) will say “1”, as it will detect your node.

For other tips about Mist and using its features, please see this post.

Conclusion

You now know how to connect to your private blockchain with three of the most common and, arguably, most important Ethereum tools. Each of these allows you to execute transactions on the Ethereum blockchain (your own or a public one), but only Mist will let you truly effectively deploy and debug smart contracts, and that’s something we’ll focus on next time.

We encourage you to try and play around with the private blockchain and the tools from this article. Break something, send ether around, export and import JSON keys from wallets and more – learn to use these harmless tools so that you’re ready for problems if and when they appear in the “real” world.

Stay tuned!


If you found this article useful or interesting, please consider donating to keep our operation running.

2 COMMENTS

  1. Created private node on Amazon ec2 and tried to connect Metamask with that. It shows other wallet address with 0 ether.
    Followed the steps to get keystore json file and imported that to new account. But it asks for a password. What password are we supposed to enter?

    • When you were setting up the node how did you configure the coinbase address of the node? Did you follow instructions from previous post on setting up the coinbase address with the newAccount method in the geth console?

LEAVE A REPLY

Please enter your comment!
Please enter your name here