Skip to content
Related Articles

Related Articles

How to use GANACHE Truffle Suite to Deploy a Smart Contract in Solidity (Blockchain)?

View Discussion
Improve Article
Save Article
  • Difficulty Level : Hard
  • Last Updated : 21 Jul, 2022

Smart contracts are programs stored on a blockchain. The term ‘smart contract’ was first coined by Nick Szabo in 1994. It’s a collection of code (its functions) and data (its state) that resides at a specific address on the Ethereum blockchain. One of the main features is that they are immutable once deployed on the blockchain. Solidity and Vyper are the two most active programming languages used to write smart contracts on the Ethereum blockchain with Solidity being the top choice for most developers as it is an object-oriented, statically-typed language and is strongly influenced by more popular OOP languages like JavaScript and C++. 


To write and execute solidity codes, the most common IDE used is an online IDE known as REMIX. You can either open it online on or install it in your system from You can also use Mist (the Ethereum Dapp browser).  

After you write the code and compile it you can deploy it in 3 ways –

  1. JavaScriptVM 
  2. Injected Web3
  3. Web3 Provider

This article explains how to deploy your contract by using Ganache as a web3 provider.


Ganache is a personalized blockchain for Ethereum development. It can be used to run tests, execute commands, and inspect states while controlling how the chain operates. It is provided by Truffle Suite and can be downloaded from

Step 1: Open Remix IDE in your browser. After opening click on “ + ” and write the filename as follows –

Open Remix IDE

Step 2: Write the following sample code for testing and compile by clicking on the Compile button as shown –   


// Solidity program to demonstrate
pragma solidity ^0.4.26;
// Creating a contract
contract shreyansh_05 
    // Defining a function
    function get_output() public pure returns (string)
       return ("Hi, your contract ran successfully");

Solidity program

Step 3: After compilation open GANACHE on your desktop which you have downloaded from the link given above. The screen will look like below. Click on QUICKSTART Ethereum

Ganache Window

Step 4: Now you will get 10 default accounts for your blockchain at a local RPC server HTTP:// as below-

Default Accounts

Step 5: Go back to the browser and move to Deploy section just below the compilation and select Web3 Provider in place JavascriptVM as shown below-

Deploy section

Step 6: Enter the server HTTP:// as Web3 Provider. The screen will look like below –

Enter Server

Step 7: Now your contract is ready to be deployed. Click on the Deploy button and the deployed contract will look as follows- 

Deployed contract

Step 8: Expand the deployed contract as below and get the output using the get_output() function-


Step 9: Now, to verify whether your transaction (process) was reflected on the server or not, open GANACHE and move to TRANSACTIONS. Here you will get the details as below –

View Transaction in Ganache

Now your contract is completely ready to function. Make sure the compiler version matches the version of your solidity code. This is the basic implementation of GANACHE with solidity. 

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!