VOOZH about

URL: https://www.geeksforgeeks.org/installation-guide/how-to-set-up-ganche-with-metamask/

⇱ How to Set up Ganche with Metamask? - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

How to Set up Ganche with Metamask?

Last Updated : 8 Sep, 2025

Ganache is a development tool in the Truffle Suite and is used for setting up a personal Ethereum Blockchain to deploy contracts, develop your applications, and run tests.

MetaMask is a software cryptocurrency wallet used to interact with the Ethereum blockchain.

Installing MetaMask:

1. Click on url and install the MetaMask extension. As of now, Metamask supports Chrome, Firefox, and other popular Chromium-based browsers(Brave, Edge).

👁 Install MetaMask

2. Add the MetaMask extension to Google Chrome.

👁 Add MetaMask to chrome

3. Then proceed to create a new wallet, accept terms and conditions and finish the installation process by setting up a password for your account.

👁 Get Started
👁 Create wallet
👁 Accept terms of Metamask
👁 Create password

4. Verify the installation by opening MetaMask from the toolbar.

👁 Verify MetaMask installation
👁 Open MetaMask Interface

Installing Ganache: Follow the steps below to install ganache.

1. Download the Executable Package File by visiting this link.

👁 Download exe

2. Alternatively, you can also install ganache-cli by executing the following command in the terminal. Omit sudo, if you are on a Windows platform and open the cmd in administrator mode.

sudo npm install -g ganache-cli

Import Ganache Account to Your Metamask Wallet:

Follow the steps below to import the ganache account to your MetaMask wallet.

Start the ganache blockchain and copy the private key of the desired account.

Ganache GUI

Ganache CLI

👁 Ganache CLI
👁 Ganache CLI
👁 Ganache CLI

Add the local blockchain network in MetaMask by entering the RPC URL and Chain ID (Default Value: HTTP://127.0.0.1:8545 and 1337 respectively).

👁 Add local blockchain network
👁 Add network details

Create a new account by entering the copied private key.

👁 Create a new account
👁 Import account
👁 Account created

MetaMask is now connected to the required node on the ganache blockchain successfully. Now, we will deploy a smart contract written in solidity and will use truffle to deploy it. This will consume some gas from our account and check whether the changes are reflected in our MetaMask wallet or not.

Steps to Deploy the Smart Contract

Installing truffle.

sudo npm install -g truffle

Verify the installation by executing.

👁 verify the installation

Creating our smart contract.

mkdir folder_name
cd folder_name
truffle init
truffle create contract TestContract

👁 Creating smart contract

Now, open the TestContract.sol in any code editor of your choice and update its content to-

In the above code, we have created a smart contract TestContract that has a variable counter and a method IncrementCounter that increments the value of our variable by one.

Now, create a new file 2_deploy_contracts.js in the migration subfolder and import our smart contact.

At last, compile the smart contract by executing :

truffle compile

👁 truffle compile

Note: If experiencing any difficulties/errors in following the above steps, please have a look at the source code of the compiled contract.

Deploying the smart contract

👁 Deploying smart contract
👁 Deploying smart contract

After transaction.

👁 Result after transaction
👁 Result after transaction

Check the ethers left after the transaction.

👁 Check ethers left after transaction

Comment