DEV Community

Cover image for Brownie: How to import Ganache-cli accounts to your MetaMask wallet?
ilija
ilija

Posted on

Brownie: How to import Ganache-cli accounts to your MetaMask wallet?

When we develop our smart contract in local environment with Python based Brownie framework we may be confronted with fact that even if Brownie use Ganache-cli under the hood we cannot find private keys of generated accounts. Accounts loaded with ETH are there but not a private keys. And of course we would need them if we want to import our accounts to MetaMask wallet and that is how synchronize what is going on the level of Brownie, Ganache and MetaMask. In this post I will present simple solution for this problem.

If we type in terminal $ brownie console we will get something like

Brownie generate new account by using Ganache-cli

It is obvious that Ganache accounts are there but there is no private keys which we need if we want to import them to our MetaMask wallet.

And simple solution for this problem is:

Step 1: Open new terminal window and type $ganache-cli and you will get something like >>>

Ganache-cli generated accounts

Step 2: Open new terminal window and type $brownie console

In this moment Brownie will connect to already existing Ganache instance and he will load all created accounts (he will not start new Ganache instance).

Brownie load already existing Ganache-cli accounts

Here we can see that account zero is same as in Ganche-cli terminal window account zero.

Step 3: Add private keys from Ganache-cli to MetaMask import (change network to localhost:8545)

Importing private keys from Ganache-cli to MetaMask

Importing private keys from Ganache-cli to MetaMask

Importing private keys from Ganache-cli to MetaMask

Now you can transfer from account to account in local environment and have all that synchronized across the Brownie, Ganache and MetaMask.

Top comments (0)