Where does ganache store the Ethereum blockchain
Asked Answered
G

3

10

I'm actually using truffle with Ganache to do some development.

I would like to know where does Ganache store it's blockchain to see how much data is used by my test. Is it stored somewhere accessible on the pc ?

I'm using

  • Ubuntu 17.10 64-bit
  • ganache-1.0.1-x86_64
Glassy answered 4/1, 2018 at 14:18 Comment(0)
S
8

TestRPC used to just be in memory. They only recently released support for writing the blockchain out to the file system. As far as I can tell, the in memory implementation is still the default behavior. If you want to find the blockchain files, you'd specify the location yourself with the --db option.

From their release page (under v4.0.0):

Because we backed the TestRPC via the filesystem, this means you can now save your blockchain's data for later use. That's right, if you close the TestRPC and reopen it later, say, you can start up right where you left off. You'll need to use the new --db option (see the README) to tell the TestRPC where you'd like the data saved. You'll also likely want to use the --mnemonic option to use the same accounts each time.

Slipper answered 4/1, 2018 at 18:13 Comment(1)
Thank you, I tried with ganache-cli and it worked. I tried with ganache as well but it seems that this is not implemented yet.Glassy
I
4

With Ganache v2, there is a new feature allowing you to maintain different workspaces. Each workspace can represent a different ongoing chain, and can be resumed by reading from disk at (just about) any time.

For example (on Windows) a workspace named "sample-spot" would be stored at %AppData%\Ganache\workspaces\sample-spot\chaindata (where %AppData% may be something like C:\Users\yourname\AppData\Roaming\).

Some additional details can be found in code here and documentation here.

Indestructible answered 27/2, 2019 at 20:5 Comment(2)
If on Mac sometimes Ganache breaks and a clean up by removing local files in ~/Library/Application Support/Ganache helps (which is an equivalent of AppData).Pinette
On linux $HOME/.config/Ganache/ui/workspacesLaurence
M
2

If you want to use --db, you need to use parameters --mnemonic and --networkId

Example: ganache-cli -p 7545 --mnemonic --networkId 100 --db .

Ref: https://github.com/trufflesuite/ganache-cli/issues/407#issuecomment-347663452

Michi answered 9/4, 2018 at 4:37 Comment(1)
In my case I had to add a value for the --mnemonic section e.g. ganache-cli -p 7545 --mnemonic "polar velvet stereo oval echo senior cause cruel tube hobby exact angry" --networkId 100 --db . If you run the command multiple times confirm that the available accounts are the same each runAeroneurosis

© 2022 - 2024 — McMap. All rights reserved.