Solidity is a programming language used to create smart contracts in Ethereum blockchain network. As blockchain is an emerging technology and I have an idea to build a decentralized application (DApp), I have decided to learn solidity by myself. I am sharing what I learned on daily basis so that it will be easier for you to learn this language and join the blockchain community.


Basic structure of a smart contract

  • In a DApp instead of using a database we will be using ethereum blockchain.
  • We write a smart contract which will allow us to store the information in ethereum blockchain.
  • All solidity files will have an extension of .sol
  • Frontend will be written using basic HTML, CSS and JavaScript or frontend frameworks.

Let us start

I have used Remix IDE for coding this dapp. Remix is a powerful, open source tool that helps you write Solidity contracts straight from the browser. Written in JavaScript, Remix supports both usage in the browser and locally.

As solidity is evolving fast, we have to declare the versions of solidity so as to avoid future breaking changes.


pragma solidity >=0.5.0 <0.6.6 ; (A range of versions supported)

pragma solidity ^0.5.0 ; (A range of versions supported)

Hello World!

As I have already said, we are writing a contract. So let us write our first contract:


contract HelloWorld {


State Variables & Integers

State variables are permanently written to Ethereum network (like we store in database)

Solidity is a statically typed language – this means that a variables type must be known at compile time, thus it differs from javascript whose loose typing allows more flexibility in the typing of variables. Explicit type conversion is typically only allowed when converting between signed and unsigned integers, or when converting an address or an integer to a hash.

Unsigned Integers: uint

uint is unsigned integer of 256 bits. It should always be positive.


contract HelloWorld {

uint a=12;

uint b=10;


Mathematical Operators


contract HelloWorld {

uint a= 12; uint b = 10;

uint c = a + b;

uint d = a – b;

uint e = a * b;

uint f = a/b;

uint g= a % b; (Modulus operator will return the remainder of a divided by b, in this case 2)

uint h =a ** b; (Exponential Operator. Answer will be 12^10 = 61917364224