6

I am attempting the Truffle "Ethereum pet-shop tutorial":

http://truffleframework.com/tutorials/pet-shop

I am in the stage where I am attempting to implement the smart contract on the local Ganache block chain, where I have to use the Ganache seed phrase to import the applicable Ganache den. However, I have an existing MetaMask den with some tokens and real ETH in it.

My question is: How can I import the Ganache den for local testing?

I have tried disabling and re-enabling the extension, but upon entering my password, it takes me to my existing den with the multiple tokens and ETH in it.

Help will be greatly appreciated.

  • 2
    Okay I seem to have gotten it right, if anyone else struggles with this: just click on the three bars in the top right corner of the MetaMask interface, select settings, and paste the Ganache URL in to the test RPC URL box. This will connect MetaMask to the private Ganache network. – Kuyler007 Dec 24 '17 at 15:00
  • 1
    I'd be nice if you can add an answer with your solution so it can help others. – Ismael Dec 26 '17 at 5:00
10

You can import a new account from the private key of a Ganache's test address, not the seed phrase.

The private key can be seen by clicking the key icon on the right of an account row in Ganache.

enter image description here

  • Also working back the other way you can create a new account in MetaMask by importing a private key from Ganache startup. – MrYellow Jan 27 '18 at 22:07
  • where we have to paste private key in meta mask – Zeeshan Ahmad Khalil Jun 14 at 17:38
3

Ok so the solution I found for this:

You do not need to use the Ganache seed phrase and therefore neither the specific Ganache MetaMask den.

You can use your existing den with your own unique seed phrase. Even if you have other accounts with real value tokens in them, these existing accounts and the tokens in them will not be influenced.

To connect to the local Ganache block chain:

Click on the three horizontal bars in the top-right corner of the MetaMask interface in your existing den, select settings, and then paste the URL in the Ganache interface into the test RPC URL box.

This is all you need to do to connect to the local Ganache block chain and your existing accounts will remain uninfluenced. Note that if you follow the above steps, MetaMask will indicate that you are connected to a testnet where it usually says Main Ethereum Network.

Hope this helps somebody.

  • 3
    This works, but the account got 0 eth....? It should be 100, no? – tomsoft Jan 26 '18 at 8:22
  • unless you use the same mnemonic, you're only connecting to the local network, but not using any of the accounts that ganache generated – emilebaizel Aug 9 '18 at 17:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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