Is there a way to store Ganache in memory blockchain into a folder? I saw that we have ganache-cli --db which allow us to do this, but I'm interested if I can do the same thing with Ganache GUI.
1 Answers
Ganache UI does not have a parameter which supports the --db parameter offered by ganache-cli. However, it is possible to specify this location by manually building and running Ganache UI on your machine (note: this is a bit of a work-around)
Follow these steps for cloning the ganache repo and installing the necessary npm packages.
Then, within the cloned repo, navigate to the src/chain/chain.js file. Search for the line of code which starts the ganache-core server. It should look like this:
server = ganacheLib.server(options);
Now, add a line of code before this to specify the database path:
// This option will tell ganache-core where to instantiate the database.
options.db_path = "C://my_example_db_folder";
server = ganacheLib.server(options);
Finally, all you have to do is run the application from the source code by utilizing the npm start command. (You may need to also install electron-forge via npm install -g electron-forge.) You will now have Ganache UI running with the database pointed to the folder you have designated.
As a note, Ganache utilizes LevelDB and the levelup JavaScript library to persist and interact with the data. Also note that you may need to blow away the contents of the folder when re-starting Ganache UI.