'Accounts provided by ganache-cli has no balance at all

I have initiated a new private test ganache chain by the following commands.

>ganache-cli --db ./db

The db folder is newly created folder so its content is completely empty. I can see those results from console.

Ganache CLI v6.12.2 (ganache-core: 2.13.2)
eth_blockNumber
eth_blockNumber

Available Accounts
==================
(0) 0x57d1037Ff1E3649e3d8b39f8d5977cDe7cFFa233 (100 ETH)
(1) 0xeF60A65e944f0De168EC7ae1E9058bBCC6441682 (100 ETH)
(2) 0xd68AA0635a6677ca20C7471cB17BD2CC2F81f2d6 (100 ETH)
(3) 0x2bD8Ab5d71bdbA78D69b4dc9f4d197E0e4C5D80B (100 ETH)
(4) 0x0a464D9a83889321dfEf3BaF4ffC4344832Ea5c9 (100 ETH)
(5) 0xE5909D5E1488BCddaABd56fd982032659F84118C (100 ETH)
(6) 0xc6b5610DF29849315Ab4694b9bFD6a6DBba215B8 (100 ETH)
(7) 0xcD49EdF273a172B1f852B4c95846d0a3e1D36638 (100 ETH)
(8) 0xd9c559d713837717f5d35814a55443902302Ee16 (100 ETH)
(9) 0xbC1e089E03B72c9FA91DeC5fc2d17D8865F6333B (100 ETH)

Private Keys
==================
(0) 0x9f1ec8b7191984ff76d1743ae0d31123c80e8b4068f293240b34f97a73cf531e
(1) 0x05c619bedbf5f5d40fa1b9cf8aadd568c49a1d6f4d3b94d605edc59b84db996d
(2) 0x94dd1c73df460136a90d2d0b0f8bd168aa84c0d0feba55ab5882d1334079841a
(3) 0x63d10010648e70e192949a824dfba0e0dd36d61482e33e101317a1ba6d03171b
(4) 0x2ec411ed4307f200e6e9fbf6bf7ac6bf57ee68cbc48eb4b1f5ee9d8ce4aab9b0
(5) 0xb538d3e3c21692d900a17c2fce637278e50530f0c3553518f0cbe1433a77cdbf
(6) 0xf629936e0434e33634f54e5a1737e4db7fe3084876eea9d2e9e2af4c263ad898
(7) 0x2470acc3e6f443d45a9a61cbcc16790e4ea4d151636fe9ea500880cd458eaabd
(8) 0x42eba3965d6ccfb67b3cd0c233ee393e801e9c9846bc775184b45b5f62c81adf
(9) 0xaf396c13f47205170bab7bb65db5776602d5ee9a8ff2b3a3947ce994c9b45560

HD Wallet
==================
Mnemonic:      slow token kind frequent elite poem answer reject okay then cradle motor
Base HD Path:  m/44'/60'/0'/0/{account_index}

Gas Price
==================
20000000000

Gas Limit
==================
6721975

Call Gas Limit
==================
9007199254740991

Listening on 127.0.0.1:8545

But I found that the above accounts' balances are all 0 ETH from metamask. Metamask's target chain was set to localhost:8545 which is ganache's RPC url.

It works well with ganache UI but not work properly with ganach-cli.



Solution 1:[1]

I had the same problem. Here's how I fixed it.

  1. Remove the localhost:8545 network in MetaMask. The "localhost" requires a network connection. It's better to specify 127.0.0.1

  2. Add a new network with the values:

    • New RPC URL: HTTP://127.0.0.1:8545
    • Chain ID: 1337
    • Currency: eth

Note the above is for ganache CLI; Ganache runs on HTTP://127.0.0.1:7545

Hope that works!

Solution 2:[2]

SWITCH ACCOUNT -> CREATE NEW WORKSPACE. You will get new accounts with 100 ETH. check screenshot for SWITCH option

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 MsJenniferElle
Solution 2 Nitin Mekhiya