Brownie under the hood use Ganache. Ones we start brownie console accounts are generate automatically (10 by default) for further use.

Question: is there a way to discover private key from account[0] for example from within Brownie console?

Up date to question: If I try to run ganche-cli (as proposed) it will give us private keys used inside brownie console and that`s ok. Now we know private keys.

enter image description here

enter image description here

But if we try to deploy some contract, while ganache-cli running in background and then to go into interactive mode with brownie run script arg1 arg2 -i interactive flag to see private keys, Brownie will stay stucked in the loop like this:

enter image description here

What I need is to see private keys of address from which I made this deploy in local dev environment and to add them to MetaMask connected to Ganache 8545 port and then to test front-end from deployer address (now present in MetaMask) on function that have onlyOwner modifier.

But to add to MetaMask we need to know private keys which are hard to obtain in explained scenario when deployment (not simple ganche-cli => brownie console) with ganache-cli running in background is involved.

3 Answers 3


I don't think you need to use the brownie console for viewing the private keys of the default accounts that brownie uses. They are generated using the ganache-cli and their private keys will be displayed while running the cli tool. enter image description here

You can, however, view the private keys of the accounts that you have added to brownie. Here's how you can do it.


One easy solution to my question is brownie-config.yaml.

I add mnemonic from which accounts should be generated (same as I have in my dev MetaMask) and Brownie generate accounts. Now when I plug MetaMask to localhost 8545 everything worked just fine.

brownie-config.yaml part:

            accounts: 20
            mnemonic: ${MNEMONIC}
            default_balance: 200 ```

Before this don't forget to put your mnemonic in .env file!

setting the same mnemonic will work fine. You can also generate an account in metamask and give the private key of the account as a parameter while running ganache

ganache-cli --account "0x<account-private-key>"

I think this will also yield similar results

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.