Search code examples
ethereum

Add ETH to a Ganache account


Is there a way to add ETH to a Ganache account? I am aware that I can typically refresh the accounts by restarting ganache cli, but I'm using the --db option, which means the accounts are persistent. Because of this, they've run dry pretty quickly.


Solution

  • AFAIK, you can't add ether. Your best option is initialize your accounts with very large balances using either --defaultBalanceEther for all accounts or with --account="<PRIVATE_KEY>,<BALANCE>" for static accounts.

    Example with 90,000 ETH

    ganache-cli --defaultBalanceEther 9000000000000000000000
    

    or

    ganache-cli --account "0x70f1384b24df3d2cdaca7974552ec28f055812ca5e4da7a0ccd0ac0f8a4a9b00,9000000000000000000000"
    

    This should at least minimize how frequently you have to deal with the issue.