What is Ganache?
Ganache is a tool for ethereum dapp developers, supported by the Truffle team. It has 2 components:
- The Ganache CLI
- The Ganache GUI
Ganache CLI allows you to run a local ethereum blockchain on your computer. This blockchain is only local and not connected to any public testnet, nor the mainet. This is great for local development because you have absolute control over this local blockchain: you can create it, restart it, create pre-funded accounts and more. Ganache CLI is already included in Truffle, so you don’t need to install it.
Ganache GUI is a visual interface for Ganache CLI. It has many features, but can be generally described as a blockchain explorer. It is built with electron and can run as a stand-alone desktop app.
How about testrpc?
In previous episodes, I used a tool called testrpc instead of Ganache CLI. The testrpc npm package still exists but the development has been moved to Ganache CLI.
Installing Ganache GUI
The first step is to install Ganache GUI on your computer. On the home page of Ganache, there is a button to download an app file. There are specific formats for Windows, Linux and Mac. I tried on Linux and Windows this method, but it failed. You might have more luck than me, but if you want to save yourself some troubles, I would recommend to run it directly from the source code.
For this, first open a terminal window, create a folder for ganache and clone the source code:
mkdir ~/ganache git clone https://github.com/trufflesuite/ganache.git
This will download the latest version of the
develop branch. If you want to use something more stable, you might prefer to download the latest release version instead.
Once this is done, in the same folder install the required dependencies:
The install process might take a while, so feel free to let the task run on its own and come back to it later.
Once this is done, you will be able to run the Ganache GUI like this:
A window will open, and will ask you if you agree to send analytics data to Truffle, the organization which created Ganache. Agree or disagree to send them this analytics data, click on the continue button, and you should finally see the home page of Ganache!
Congrats! In the next episode, we will see how to use Ganache.