3

I start my service by:

ganache-cli -d --gasPrice 0 -q --db=./db

This persists my 10 defaults created accounts, but when I create new accounts using Web3:

web3.eth.personal.newAccount('password')

All the created accounts desapears after I restart the Ganache CLI command. So I cannot unlock this accounts. But all my erc20 token balance are there.

How can I persist the new created accounts?

KQUEIROZ
  • 31
  • 1
  • 4
  • You do not have the -i parameter (network id), it might be the case that it is different between invocations https://ethereum.stackexchange.com/a/40226. – Ismael Apr 20 '19 at 07:20

2 Answers2

3

Command-line option -d does not persist your accounts. It just generates them deterministically, i.e. the same addresses are generated every time you run it. Here is what documentation says about this:

-d or --deterministic: Generate deterministic addresses based on a pre-defined mnemonic.

I doubt ganache is able to persist accounts at all, because it was designed for clean-room testing.

Mikhail Vladimirov
  • 7,313
  • 1
  • 23
  • 38
  • It allows persistence of blockchain data if you use the same parameters -i, -d and -db in each invocation. But I'm not sure if the accounts details are part of the database. – Ismael Apr 20 '19 at 07:17
0

Account won't be persistent when you rerun the ganache-cli