This page may contain legacy content

To get our most up-to-date content please access our documentation

July 12, 2021

Ganache Explained – What is Ganache Blockchain?

Table of Contents

Web3 development has never been more in vogue than now, with frantic activity in the Web3 and decentralized application (dApp) fields. However, when developing dApps you might find that Web3 development is unnecessarily convoluted. This is partly due to the fact that Web3 development still has not evolved to the same extent as traditional Web2 development. This, by extension, is not particularly strange, since as the dApp scene remains somewhat in its infancy. However, Web3 development is still booming, and there are some useful tools and platforms to aid development. You will likely already know that Moralis provides the best blockchain middleware for dApp development, with an impressive suite of powerful features. Moralis should always be your go-to choice for building dApps – but you can supercharge your development by learning more about other Moralis-compatible tools, like Ganache. 

When developing dApps, it is highly beneficial to set up a local Ethereum blockchain where your dApps can be tested in a safe environment. This is precisely what Ganache does, which is why this article will take a closer look at what Ganache is and why we need a local blockchain. 

Furthermore, it’s worth repeating that the easiest way to develop dApps, with our without Ganache, is through Moralis. Moralis is the premier middleware for Web3 development, and provides users with a fully managed, infinitely scalable backend infrastructure which solves the traditional hassle associated with building Web3 apps or dApps. Furthermore, Moralis has native support for Ganache. As this is the case, we will also walk you through connecting Ganache to Moralis. If you are interested in becoming a dApp developer, we recommend signing up with Moralis. Signing up is completely free, and you are provided with several valuable tools that will shorten your development process from months to only days!

What is Ganache Blockchain?

So, to begin with, Ganache is part of the Truffle Suite ecosystem. Specifically, the Truffle Suite consists of Ganache and an additional pair of tools; Truffle and Drizzle. Truffle is a development environment, asset pipeline, and testing framework using the EMV (Ethereum Virtual Machine); meanwhile, Drizzle is a collection of frontend libraries. 

On the other hand, Ganache is a high-end development tool used to run your own local blockchain for both Ethereum and Corda dApp development. Ganache is helpful in all parts of the development process. The local chain allows you to develop, deploy and test your projects and smart contracts in a deterministic and safe environment. 

There are two different ”versions” of Ganache, one desktop application, and one command-line tool. The desktop application is called Ganache UI, and it supports development for both Ethereum and Corda; meanwhile, the command-line tool is called ganache-CLI, which solely supports Ethereum development. Furthermore, all the different versions of Ganache are available for Mac, Windows, and Linux. 

Why do we Need Ganache for Ethereum Development?

As we mentioned, Ganache allows you to set up your blockchain, which in turn provides a safe testing environment for your dApps and smart contracts. However, why do we need this? Why can’t we test on the Ethereum blockchain directly or a testnet?

There are two main reasons for utilizing Ganache; the first one is to save money, and the other one is to save time. When developing, we want to do things as cost-effective and efficient as possible – which will sound familiar to anyone using Moralis. Nevertheless, when uploading smart contracts to the Ethereum chain, we must always pay gas fees. This means that we need to pay a transaction fee for every smart contract that we want to test. This can become very costly, since the gas prices can be quite high and unpredictable. As this is the case, it is much more beneficial to test smart contracts on a local chain since we can avoid the fees. This means that we can wait to pay the transaction costs for deploying the contracts until they are flawless. 

Furthermore, we can also upload our work instantly with our local blockchain. It takes time to upload to both the main- and testnets of Ethereum, and it can be an issue when trying to develop at a rapid pace. This means that we need to wait for our contracts to deploy on the chain before testing them, which can be avoided with a local blockchain set up with Ganache. 

What is Ganache Blockchain? – Getting Started

Setting up your local blockchain with Ganache is relatively easy. The first thing that you need to do is to install Ganache. To download Ganache, all you need to do is visit their official website and hit the ”Download” button. Once clicked, the download will start immediately, and all you need to do is install the application. 

When you have finalized the installation, you can set up your local blockchain with one simple click. All you need to do to get going is to hit the ”QUICKSTART” button in the Ganache UI. Once clicked, the application will launch your own Ethereum blockchain. As soon as the blockchain is up and running, you will see several different tabs at the top of the screen, such as ”Accounts”, ”Blocks”, ”Transactions”, etc., that you are free to explore. 

It is as simple as that to get going with Ganache and set up a local chain. However, there is much more to learn. If you are interested in what more Ganache has to offer, then we recommend their official documentation, where you can find a guide on how to utilize Ganache. 

What is Moralis?

As we mentioned in the initial section, the best way to develop dApps is with Moralis. As this is the case, we should better understand what Moralis is and why we should use the platform. Furthermore, a better understanding will also explain why we want to connect Ganache to Moralis. 

Traditional dApp development can be somewhat of a hassle, and the significant issue is backend development. Not many people are aware of how to build a fully functioning backend for dApps, and as a result, the process is time-consuming and resource-intensive. To solve these issues, we have been provided with Moralis. 

Moralis is an easy-to-use platform that allows you to develop and connect your dApps to a blockchain of your choice. With Moralis, it is possible to save time, money, and effort, which is highly appreciated for all development. This is possible since Moralis provides an infinitely, fully managed backend infrastructure for all users. As a result, the platform users can direct their full attention to the frontend development of their dApps to ensure a phenomenal user experience for their customers. 

Furthermore, Moralis also offers other services and features such as native support for MetaMask, IPFS, the Moralis NFT API, cross-chain compatibility, etc. However, these are just some of the valuable tools that help developers save time and money by shortening the development process. Another neat function is the Moralis Speedy Nodes functionality, which now comes with full WebSocket support

Moralis’ Speedy Nodes are some of the best, most reliable, and fast nodes available. Moralis already offer nodes for four different networks; ETH, Polygon, BSC, and Arbitrum. Furthermore, Moralis also supports archive nodes of all these networks, which means that it is possible to query information from past states of the respective blockchains. 

Changing MetaMask Network from Ethereum to Ganache

To establish a connection between Ganache and our Moralis projects, the first thing we need to do is to connect Ganache to MetaMask. We’ll therefore take this section of the article to go through how it is possible to connect Ganache to MetaMask. 

Before connecting Ganache to MetaMask, we must set up our own local blockchain. This is done by following the instructions in one of the previous sections. Once the chain is up and running, we can move on to connecting Ganache to MetaMask. If you are unfamiliar with MetaMask, we recommend reading the following breakdown of MetaMask before continuing reading. 

The first thing that we need to do is to add a custom network to our MetaMask. This is done by clicking the ”Networks” tab at the top of our MetaMask interface. This will provide us with a dropdown menu with several different alternatives. Here we want to click the ”Custom RPC” alternative, which will allow us to add our local Ganache chain to MetaMask. 

When clicked, we will need to input a name, something like ”Ganache Local”, but it does not matter. What we need to acquire from our Ganache application is the RPC URL. This can be found under the tabs in the Ganache UI. Then we need to input this URL in the ”New RPC URL” field. Lastly, we need to input a Chain ID which, for a local chain, will be ”1337”. Once we have all the accurate information, we can finish the process by hitting ”Save”. 

Adding a new Account

After saving the network, we have established a connection between our MetaMask and our local Ethereum blockchain. However, now that we have the network up and running, we must also connect a wallet with some ETH to our account. 

This we can do by going to the ”Accounts” tab in Ganache, choose an account, click the key icon to the right and copy the private key. Then we can move to MetaMask again, click your profile at the top right and add a new account with the private key. By doing so, we acquire an account with 100 ETH. Obviously, these will not be real ETH, and they can only be used on your local chain for testing your dApp and smart contracts. 

However, here is a video guide from the Moralis YouTube channel explaining the complete process: 

What is Ganache Blockchain? – How to Connect Ganache to Moralis

As we previously mentioned, it is both possible and simple to connect Ganache to Moralis. However, we did not go into the nitty-gritty details about how to establish this connection and why we should do so. The reason for joining Ganache to Moralis is to allow the Moralis server to communicate with the Ganache local blockchain. 

So, the first thing that we need to do is to sign up with Moralis. You will need an account to set up a server, and signing up is entirely free. If you have not already, you need to connect Ganache to MetaMask. Instructions on how this is done can be found in the previous section of the article. 

Once Ganache is connected to MetaMask, and you have a Moralis account, we can connect Ganache to Moralis. When logged into Moralis, we want to create a new server by hitting the ”+ Create a new App” button at the top right of your browser. This will provide you with a dropdown menu, and as Ganache is a local chain, we want to pick the ”Local Devchain Server” alternative. 

This will provide us with a window asking for a name, region, and network(s). We can choose whatever name, but preferably something to do with Ganache, select any region, and choose the ”Local Dev Chain” network. Once we are done with all our options, we can hit the ”Add Instance” button to spin up a server for our local dev chain. Setting up the instance can take a few minutes, but fear not, the server will be up and running shortly.

Connecting Ganache to your Moralis Server

Once the server is initiated, we can click the ”View Details” button for the server in question. This will provide us a popup window with three different tabs. The one we are interested in is the ”Devchain Proxy Server” tab. If we click this tab, we will see that the server is disconnected. The reason for this is that we have not yet established the connection between our local Ganache chain and Moralis. This means that there is no way for Moralis to know if something happens on the chain, but we are about to change that.

To connect to the server, we must follow the instructions provided to us in this tab. The guide consists of three steps:

  • Download the FRP.
  • Change the contents in ”frpc.ini”.
  • Run a command depending on what operating system you are using.

However, more detailed instructions about how to do it can be found in this tab on your own Moralis server. 

Moreover, suppose you want a more detailed guide of how you can connect Ganache to Moralis. In that case, we recommend watching the following clip where Ivan on Tech demonstrates how easy it is to establish the connection:

Ganache Ethereum Development Alternative — Hardhat

Simplifying the development process is not something unique for the Truffle Suite or Ganache. There are other alternatives out on the market which are worth mentioning. One of the largest networks similar to Truffle Suite is Hardhat. Similar to Ganache and Truffle Suite, Hardhat is a development environment for testing, deploying, compiling, and debugging Ethereum-based dApps. This means that, just like Ganache, Hardhat can help developers with some of the inherent tasks to Web3 development. 

Hardhat focuses on Solidity debugging, which makes it ideal for developing Ethereum dApps. As such, the network features some great functionalities such as Solidity stack traces, automatic error messages, and the Hardhat network. 

Furthermore, connecting Hardhat to both Moralis and MetaMask is just as easy as connecting Ganache. The processes are quite similar, and there are only a few necessary tweaks here and there. However, if you are interested in learning more about Hardhat, you should check out the following article. This is a full breakdown of Hardhat and instructions on connecting the network to Moralis and MetaMask. 

What is Ganache Blockchain? — Summary

Developing dApps can be quite the hassle, which is why it’s beneficial to use platforms that expedite the development process. One way in which development can become easier is by setting up a local dev chain where we can test our dApps for free and with high efficiency. One platform that offers just that is Ganache. 

Ganache is part of the Truffle Suite ecosystem, and you use it to deploy your local Ethereum blockchain. Ganache will therefore provide you with a deterministic and safe environment for testing applications and smart contracts before launch. 

Furthermore, Moralis supports Ganache which means that we can connect our Moralis projects to our local blockchain. This makes sure that Ganache can communicate with our Moralis servers allowing Moralis to listen to what happens on the chain. This is a great integration and only one of many reasons to develop dApps with Moralis. Along with this, Moralis also provides a scalable backend infrastructure and other useful tools, one of which is Moralis’ Speedy Nodes. Even better is that Moralis announced just last week that the Speedy Nodes now feature full WebSockets!

So, if you are interested in becoming a dApp developer, we recommend signing up with Moralis for free today! It only takes a few moments, and you can begin developing your dApps straight away and utilize Moralis-compatible tools, such as Ganache, in the process. 

Moralis Money
Stay ahead of the markets with real-time, on-chain data insights. Inform your trades with true market alpha!
Moralis Money
Related Articles
February 17, 2023

Moralis Releases Transaction Labeling

September 22, 2022

GM2 Unveils Tech Partnership with Moralis

March 17, 2023

Moralis Launches NFT Image Preview Feature

October 5, 2022

Polygon Joins Moralis x Google Defining DeFi Hackathon as Gold Tier Sponsor

September 8, 2022

Introducing Self-Hosted Moralis Servers

April 4, 2023

Morningstar Ventures to Empower Web3 Innovation with Moralis

April 8, 2024

Moralis Launches ERC20 Owners Endpoint

November 30, 2022

Moralis Adds Support for Palm Network

March 14, 2024

Moralis is SOC 2 Type 2 Certified