trufflesuite / ganache

:warning: The Truffle Suite is being sunset. For information on ongoing support, migration options and FAQs, visit the Consensys blog. Thank you for all the support over the years.
https://consensys.io/blog/consensys-announces-the-sunset-of-truffle-and-ganache-and-new-hardhat?utm_source=github&utm_medium=referral&utm_campaign=2023_Sep_truffle-sunset-2023_announcement_
MIT License
2.62k stars 680 forks source link

how to load the saved blockchain #1007

Open zasleon opened 5 years ago

zasleon commented 5 years ago

first i used cmd " ganache-cli -p 8545 --mnemonic --networkId 100 --db" to create a blockchain like below.

D:\pv>ganache-cli -p 8545 --mnemonic --networkId 100 --db Ganache CLI v6.3.0 (ganache-core: 2.4.0) Available Accounts ……

there are lots of files created by this command, just like: "!blockHashes!0xe8ca3e76ee368e97c3f55380ffae4fff6743577329f76140046348d3fdbe7a12" "!blockLogs!0" "!blockLogs!length" "!blocks!0" "!blocks!length" "!trie_db!0x2d71ce1e99e7d9b687cf6ea0673404bcad9fa37c2478577c02aa32e4a0332a58" ……………………

i also send several eth from account0 to account1. then i closed this cmd.

Current Behavior

but the second time i restart the cmd and input "ganache-cli -p 8545 --mnemonic --networkId 100 --db" or"ganache-cli -p 8545 --db" or whatever i try , the ganache-cli just create new 12 Mnemonic and all the accounts refresh to become 100eth.

Expected Behavior

shouldn't "--db" load the local file and output the same Mnemonic last time it generated? or am i use wrong form of command to load the local last blockchain file?

davidmurdoch commented 5 years ago

Hey @zasleon, the --db command actually requires that you specify the path.

From the docs:

--db: Specify a path to a directory to save the chain database. If a database already exists, ganache-cli will initialize that chain instead of creating a new one.

the correct command is:

D:\pv>ganache-cli -p 8545 --mnemonic --networkId 100 --db ./my-chaindata-directory

Where my-chaindata-directory is an existing directory (should be empty at first)

Let me know if you have any questions! Thanks!

davidmurdoch commented 5 years ago

For internal reference: Not closing this issue because we shouldn't allow the flag to be specified by the user but not also set. The nargs yargs option may help here.