How to create a Local Blockchain with ganache?

Spread the love

To create a local blockchain, use Ganache, one of the four basic tools. Therefore, it must already be installed on your computer. When you launch this tool, you will see a Ganache workspace window with options for “QUICK START” and “NEW WORKSPACE” (see image below).


In the next step, you need to name your workspace. You can name it “First Blockchain”, but you can name it whatever you like. Also, you can now reliably save your workspace by ignoring the “TRUFFLE PROJECTS” option.


Saving your workspace creates a “sandbox” environment with multiple ETH addresses, each with a significant amount of money available. Test your dApp using one of these addresses. In addition, there is a key icon next to each address. Click on it to access the private key for that account.

private key

Import the test net into MetaMask

The next to-do list is to connect your play account to MetaMask. It’s also one of the four basic tools you need to prepare. Therefore, log in using the MetaMask browser extension. Before you can import your account into MetaMask, you need to connect your account to your local blockchain. Therefore, to learn how to build a dApps on Ethereum, connect it to your custom RPC. To do this, you need to click on the Network tab at the top. This will bring up a drop-down menu. Then select the Custom RPC option as shown below.

custom RPC

Next, you need to enter three pieces of information: the network name, the new RPC URL, and the chain ID. You can make the first one whatever you like (named “FirstGanache”), copy the RPC URL from the Ganache workspace (RPC server) and enter “1337” as the chain ID. Leave the rest blank and click Save.


The imported network is empty, so you’ll need to add the play account provided by the Ganache workspace. To do this, click the icon in the upper right corner of MetaMask, then click the Import Account option in the drop-down menu.

We also recommend renaming the imported account for clarity. To do this, click on the three vertical dots in the upper right corner of MetaMask. This will bring up a drop-down menu as shown in the image below. Then select the Account Details option. Then click the pencil icon and enter the desired name (I used “Ganache # 1”). Click the checkmark and then the cross to complete the renaming process.

metamask ganatche

Also, since our goal is to learn how to build a Dapps on Ethereum, we also want to be able to test several transactions between different accounts. Therefore, be sure to repeat the “Import Account” procedure above for another test account provided by the Ganache workspace. Let’s name it “Ganache # 2”.

Send a test transaction

Now that you’ve imported two accounts into MetaMask, you’re ready to send some test transactions between the two accounts. For example, you can send ETH from Ganache # 2 to Ganache # 1. The exact steps you need to take to complete a test transaction are:

  1. Copy the address of Ganache # 1-just click on the name.
  2.  Switch to Ganache # 2-Click the icon in the upper right corner, then click Ganache # 2.
  3. Click the Submit button to start sending.
  4. Enter the Send Details-Paste the Ganache # 1 address at the top, then enter the amount you want to send (starting at 12.78ETH out of 100 ETH) and click Next.
  5. Confirm Transaction-Click the Confirm button.

Check the balances of both accounts to ensure that the transaction goes smoothly. If you use the same amount as us, it should be 112.78 ETH for Ganache # 1 and 87.22 ETH for Ganache # 2. The latter can be found in MetaMask and the Ganache workspace. You can also try sending ETH to another account in the Ganache workspace using one of the two accounts imported into MetaMask using the steps above (address accordingly). Just replace it. Similarly, the Ganache workspace should reflect all transactions by displaying the updated balance and the indicated number of transactions (“TX COUNT”).


Spread the love
Leave a Reply

Your email address will not be published.

You May Also Like