Learning about smart contracts needs us to learn about the functionality of the blockchain. So what is a blockchain? The answer lies in the word itself ‘block’ describes the handler or the parent node and this node helps to connect to all the sub-ordinate nodes and forms a ‘chain’. The most important thing which we need to understand is anything changed in the daughter nodes needs to get updated in the respective parent node, this process helps to maintain a structural placement of the system without being adulterated by the intruders who try to blend into the system and leech the data from the main network.

Then let us come to our topic i.e, a smart contract. A smart contract involves a set of functions that are defined by the developer to run a certain level of agreement with the nodes and when these test cases are passed the main network accept these changes and per each change, there is a check of data through a particular token which verifies and records the transaction.

In a general online IDE, while learning a development language or a programming language we try to build a basic program like a “Hello World!” program, in the same way, we are going to build a smart contract that greets a user.


To start building, let us make a directory named “welcome_user”.

Step-1: Using mkdir we make a directory and using the cd command we go into the directory. Next, we go install Truffle which is a testing framework and asset pipeline for blockchains using EVM(Ethereum Virtual Machine).

First, we run the command

Then we initialize Truffle after successful installation of Truffle.

This creates an organization of folders and files.

Step-2: Now we go into the test configuration folder and add a ‘welcome_test.js’ file and write down the contract as below which defines greetings as a constant and to greet the user it uses the package module ‘Greeter’ and defines a contract using the package name and assert an async function to define when the contract is deployed to the test network.

const GreeterContract = artifacts.require(“Greeter”);contract(“Greeter”, () => {it(“has been deployed successfully”, async () => {const greeter = await GreeterContract.deployed();assert(greeter, “contract has been deployed”);});});

Step-3: Now run the test file using the command truffle test

This tells us that there is an error because YES! you got it right, we don't have the Greeter artifact being defined anywhere so we create a ‘Greeter.sol’ file inside the contracts folder.

Step-4: Add this code to the Greeter.sol file. Now run the test again.

pragma solidity >= 0.4.0 < 0.7.0;contract Greeter {}

We pass one of the tests but the other one gets failed oops!. So yes we got the error, the migration folder only has the initial contract but does not have the Greeter contract so let us create a migrations contract i.e, 2_deploy_greeter.js file in the migrations folder add the below code and again run the tests.


constGreeterContract=artifacts.require("Greeter");module.exports = function(deployer) {deployer.deploy(GreeterContract);}

Hurray! We created our first-ever smart contract using Solidity, Truffle, and most importantly don’t forget your IDE, for me it was VSCode.