[Ethereum] Metamask TestRPC shows 0 Ether while connecting to Ganache- CLI

etherganache-climetamasktestrpctruffle

I've gone through various Q/A(s) of the problem of ganache-cli and metamask not linking but after trying all the solutions, still doesn't work for me. As soon as I type ganache-cli in windows cmd prompt and many private keys are displayed with fake accounts. My port where ganache is activated is 8545, so I've made changes in truffle-config.js file as well, otherwise the <code>truffle test</code> and <code>truffle migrate</code> wasn't successful.

My truffle-config.js file-

  // See <http://truffleframework.com/docs/advanced/configuration>
  // for more about customizing your Truffle configuration!
  networks: {
    development: {
      host: "127.0.0.1",
      port: 8545,
      network_id: "*" // Match any network id
    },
    develop: {
      port: 8545
    }
  }
};

Using metamask I/ve tried various combinations of TestRPC URL, but none of them work. Also, I've tried connecting localhost:8545 given in list, still doesn't work.

All urls fail

I'm tryng triffle pet shop tutorial, When the GUI opens in browser and I click on adopt, nothing happens.

Best Answer

  1. First, switch network to another network and try to reconnect again to ganache network(http://127.0.0.1:8545).

  2. Make sure While you connecting to matamask using ganache, you have set up a connection like below :

enter image description here

  1. Then you need to import accounts in metamask using private keys provided in ganache. You can see I already imported account that is shown as Account3 with 100ETH in the below image.

enter image description here

That's it. it works fine. Hope it will help you.

Related Topic