Current Scenario in Everyday Life:

“Blockchain is the only remedy to our problem. It provides transparency and is secure in nature.

I was on my way to Mr. Bala’s place when I came across a chaotic group of people quarrelling amongst themselves. When I went up to them to intervene, one of them told me that it was nothing new at all and that this was a matter of every day that such fights happen.

“This is not for the first time that we’re not receiving the medicines as we should. It’s the middlemen who actually don’t let us receive medical benefits. There’s corruption everywhere in the system. When one goes to the CMO, all he says is that the medicines have been dispatched; on the contrary, if one approaches the Drug Distributors to receive them, they tell us that they don’t have any medicines.”, remarked somebody else from the crowd.

Resented to a great extent,

I went to Mr. Bala’s place and narrated him what I came across on the way.

To this, he almost immediately replied,

“Blockchain is the solution to all such issues.”

Upon asking him to tell me more about “Blockchain”, he told me it is the best remedy to prevent and detect acts of pilferage and counterfeit carried out by third parties.

I reached back home from Mr. Bala’s, the memories of the incident still etched deep in my head, I researched “Blockchain” and even devised a curative scheme to curb pilferages and eliminate inefficiency.

Having made up my mind to bring about reforms in the system, I pay a visit to the CMO of our region to talk to him about the inefficiency of the system and propose the scheme I devised to put an end to such malpractices.

Having listened to me with utmost consideration, the CMO asked me to explain the very concept of “Blockchain”.

Can you tell me what Blockchain is?


You can consider it as a common ledger which is visible to everyone within your organization, but you can restrict the visibility of sections as per your choice. Apart from that, it’s almost tamperproof and irreversible in nature.

Let us take a practical example of the current scenario. (fig. 1.1)

In our current model, there are three entities –

1)Chief Medical Officer

2)Drug Distributor

3)Drug Retailer

Initially, you used to allot some fund to the drug distributor in order to provide the drug retailers with drugs so that it can be distributed among the needy ones.

In spite of your such great efforts, the results were not satisfactory i.e. the needy ones were still deprived of the necessary drugs.

Reasons behind this may include:

1.) Illegitimate addition or removal of a transaction either from the drug retailer or the drug distributor.

2.) Insufficient fund sanctioned to the drug distributor via CMO.

3.) Drug retailer sold those medicines and added counterfeited transactions to their own ledger.

Let me introduce you to its Blockchain model: (fig 1.2)

Blockchain provides you with four indispensable features:

1) Consensus — It replicates everything and updates everyone about what is going on within the network.

2) Provenance — It keeps track for “point of origin for a transaction”.

3) Finality — Guarantee on maintaining the original state of history.

4) Immutability — It’s almost impossible to change the details of any transaction.

So, it’s almost impossible to modify previous transactions and due to the property of consensus, everyone will be aware of what is happening within the network. Thus, those vulnerable cases aren’t available in it.

That sounds good!

Can you prepare a prototype of it? So that we can further take an action on it.

Sure! I’ll be back with a live prototype soon.



Before we dive in the depth of development we first need to recall the definition of Blockchain.

Blockchains heart contains a peer to peer distributed ledger that is immutable, append-only and is cryptographically secure and it pumps out only when a consensus was well established among the peers.

This gives us an idea of “How a block must be implemented so that all the properties to maintain the integrity of a blockchain is satisfied”.

But wait! What a block is?

A Block is a primordial piece of a blockchain which reserves the information of transactions and are connected to its previous neighbour (Exception: Genesis Block, which is an initial one) by the means of a hash pointer.

This is how a standard block looks like:


Hash / Addresses: are unique combination of numbers and alphabets known as identifiers which identifies who is a sender or receiver in a blockchain.

Transactions: Which represents a transfer of some value from one end to another end.

Nonce: It’s the total transaction count within a blockchain.

But wait! Before we prove out immutability of a the blockchain. There is one more question which needs our attention?

How those Hashes were generated?

They are generated by a sophisticated hash function.

Hash function: is a mathematical function which transforms input data into a fingerprint which is known as a hash.

The speciality of a hash function is its ability to mutate any length of data (may include a large byte from a stream or just a single character) into a fixed length one.

For an eg:

A SHA256 hash calculator returns 15fb58aa8b535408c1156a1f51ebbaaddef2f5c0563560cd4d5a5f6afefc9731

for a string “CSIR”

While a lorem ipsum dummy text returns 7321348c8894678447b54c888fdbc4e4b825bf4d1eb0cfb27874286a23ea9fd2

Which is same in length.

Two inevitable properties of it include:

1) Abrupt variations with minor changes.

2) Hard to retrieve original data back from the hash.

Since all the blocks were interconnected. A trial to mutate the data of a block may result out in the recalculation of all those hashes to which it was connected. Thus a byzantine node results in the destruction of the chain.

Eg: If the chain includes 40000 blocks and the targeted block is 1900. Then all the hashes of blocks from 1901 to 40000 are recalculated. Apart from that, it’s not the only measure used by ablockchain to protect itself from the data infringement. It requires some proof of work (a specific amount of computational power required to mine a block) (All thanks to merkele patricia tree).

It proves that data is almost immutable in blockchains.

Let us head back to the scenario of drug distribution counterfeiting

The government has been added to provide better consensus.

Try to replace all the nodes with the blocks. Transactions are now being stored within them. L1 represents a genesis block. L2, L3 and L4 contain a specific nonce counter and each one contains a hash pointer which points to its ancestor.

One thing is still missing? Try to guess that?

Right! We are talking about logic. To be more precise it’s called as a business logic.

A Business logic maintains communication between a database and its end user. Main components of it includes business rules and workflows. Business rules, as the name suggests are specific procedures, while a workflow contains those procedural steps that are needed to implement our business logic.

In the world of blockchain those business logics were replaced by independent programs called as Smart contracts.

Let us get more into it.


Smart contracts were first came into the existence by Nick Szabo in late 90s. According to him:

“A Smart contract can be defined as a computerized transaction protocol that executes the terms of a contract. While the goal is to satisfy common contract environments (such as payment terms), minimize exceptions both malicious and accidental, and the need for trusted intermediaries. Related economic goals include minimizing fraud, arbitrations, enforcement costs and other transaction costs.”



Smart contract provide us with the power of maintaining distributed consensus mechanism. While Ethereum provides us necessary support to deploy smart contracts.

Features of it include:

Trust — Information is encrypted within a shared ledger. Thus, no way to either manipulate the same or to lose them. It also forms the basis of backup as each node contains a replica of data.

Savings — It helps to eliminate additional intermediaries within your business network.

Accuracy and Security — As it contains the business rules. It enforces every node on the business network to pass through the same. If anyone fails to do so, then he has treated accordingly to the rules. Accuracy is inherited, as the management becomes entirely autonomous.

Thus, we need a Smart contract in our chain to maintain the flow as well as security.

Okay! Now it’s your turn!

Try to think some rules from your own and write up everything On a piece of paper.

Keep this paper in a safe place.

Do remember that these rules are equally applicable to every participant within the chain!

Some rules were already WRITTEN FOR SAMPLE.


Ethereum is a distributed public blockchain network and was first conceptualized by Vitalik Buterin in November 2013. He abstracted the Ethereum as a Turing-complete language that enables the development of smart contracts for blockchain and decentralized applications.

While Ethereum clients have been developed with many languages. But, the most popular one is geth (go-Ethereum). Geth is a multiutility command line interface for running full Ethereum nodes.

Releases at a glance :

Frontier phase: Represents network in its simplest and unsecured form.

Homestead phase: The current phase of Ethereum.

Metropolis phase: The upcoming phase, which focuses on protocol simplification and performance improvement.

Serenity phase: The final phase, which is supposed to have Proof of Stake as an algorithm.

Understanding Transactions:

Let us now try to encapsulate all the core concepts including Transactions and Gas through an analogy.


A Hypothetical Transportation app

You surely be wondering about “What a red car with an ether mascot is doing on the front cover”?

Everything, which is included in this module has a definite meaning.

Let me introduce you to “Etherbuggy”.

The only transportation network in our blockchain world (Just like Ola). Etherbuggy helps you to transfer data, message and money from one end to another end. All you need to do is to download their application on your mobile and deploy it.

When you first launch the application, it pops open a tab named Transactions.

Jargon: Here Etherbuggy is known as an Ethereum client.

This tab includes a form which has:

1.)Nonce: This includes a counter which increments every time when a booking (Transaction) is performed. If it’s the first time then it simply shows 0 as you haven’t used this app before.

2) To: It’s the field where you need to put the address of the second party

3) Value: It’s the amount which you want to transfer.

4) Gaslimit: This is an awesome feature in this app. It allows you to set a restriction to the amount of fuel.

5) Init: It’s an optional field which gives you the ability to upload a set of rules.

6) Data: If you want to pass a message then leave it here.

Jargon: Init: it’s used to create contracts.

After that. Application prompts up a form which shows all the fields which we filled here with two more additions:

7) Gasprice: It represents the amount (wei) which is need to execute this transaction.

8) Signature: When you click it. It generates a digital signature for you. It required to authenticate the transaction.

It also generates a hyperlink for advanced users. Clicking on it will reveal additional details about signature.

The page shows:

Our Signatures are based on ECDSA and internally uses SECP256k1 curve.

Signatures are made of three fields: (However cryptography is almost out of scope for this article)

V — A single byte value that shows size and sign of elliptic curve point. It is used as a recovery key to extract out transaction.

R — It’s derived by a point on the curve. A Random number is selected and multiplied with the curve generator. X coordinate of it will produce R. R is a 32 byte sequence here.

S — Calculated by the multiplication of R with the private key and appending it with the hash of the message. Finally divide it with the same random number by which R is generated.

ECDSASIGN (Message, Private Key) = (V, R, S)

Last column shows a summarized bill in the format –

Total cost = gasUsed (amount of gas which is estimated for the transaction) * gasPrice(Your decided gas price)

After clicking on confirm it shows you the payment options.

Wait? What — It only has one option which is ether?

Right! Our blockchain network only excepts ether. Because it’s the only currency on this planet which is excepted.

Ether is extracted by miners. Miners are just like path finders. If they found any problem within the network, they immediately report the authority (EVM) to take further actions. Thus, They help to secure the network. In reality, they are used to verify the validity of transactions and blocks. It is required as the payment for execution of contracts and every operation in our chain. It is used to purchase gas for the cars running in etherbuggy.

Is it means that I must be a miner first to complete the transaction?

Yes. It’s partly true. But there is a posibility of currency exchange. You can exchange your real currency through some specialized portals and they convert your money into ether.

Okay! Let us now click on Deploy.

Now the app waits for some drivers to pick your escrow.


After the deployment. There are exactly two cases:

1) Someone pick your order and ready to perform your work.

2) No one accept your offer.

Why? Maybe drivers doesn’t lured by your offer.Reasons may include low monetary gain from your deal. Do you remember the total cost? Higher the value of total cost the higher the chance a driver may pick it up.

Jargon: Here drivers are miners. Miners are responsible for your transactions.

Let us now investigate some conditions:

1) When car reaches the destination successfully:

In this case, Transaction will complete and the value equal to the remaining gas will be refunded to the originator of transaction.

2) The Car stops in the middle of a route.

It’s possible that the car will stop in the middle of transaction may due to a shortage of gas fuel or the path to which the driver was enforced to travel on is too long that it consumed the entire fuel.

Jargon: Here the enforced route shows the use of the smart contract. Smart contract bends the workflow accordingly to the conditions

3) Driver accepts the escrow , but doesn’t reach the destination because of the complexity of rules.

Yes! Sometimes your contract may confuse the entire evm (Ethereum virtual machine) which results in the out of gas on the same spot.

Now we got enough information for implementation and we’ll cover additional details in the next section. Let us prepare our weapons to begin a war.

Setting UP


  • Facebook
  • Twitter
  • Google+
  • Pinterest

Finally, we are in the development section.

To join the race of Ethereum development. We first need to create an Ethereum node.

Ethereum node in its primordial form is a device that is connected to Ethereum network.

To declare a device as an Ethereum node. We need to use Ethereum clients.

Here is a list of popular ones:

  • eth — is suitable for c++ and object oriented coders
  • geth — handy for web developers as it’s implementation and writing techniques is pretty similar to javascript
  • pyethapp — pythonistas can use it

We are going to stick with geth.

What is Geth?

As explained previously, It is a command line tool which runs an Ethereum node. It provides three interfaces.

  1. The Command line subcommands with options
  2. A Json-rpc server
  3. An Interactive console

We are using a Linux distro — Ubuntu to show the installation of geth. You can find the extended article here to install it on another platform.

As geth is not endorsed or certified with official repository of ubuntu. We need to import its personal package archive with apt.

sudo apt-get install software-properties-common sudo add-apt-repository -y ppa:ethereum/ethereum sudo apt-get update

  • Facebook
  • Twitter
  • Google+
  • Pinterest

Now to install Ethereum. sudo apt-get install ethereum

  • Facebook
  • Twitter
  • Google+
  • Pinterest

Good! So, we got ethereum command line geth in our machine. All we need to do now is to type geth on the command line to sync and update peers. It takes a lot of time to sync the entire blockchain. Sit back and utilize your time somewhere else.

Ethereum involves three kind of setup which includes Test-net, Private Net and Parity. Test-net or Rospsten is used by

developers as a test platform to debug or test smart contracts. While the private net in Ethereum allows the deployment of private network that can be used as a distributed ledger.

Parity is out of scope right now.

As our case involves a private organisation.

It’s better to deploy a private network here.

Deploying a Private NetWORK

  • Facebook
  • Twitter
  • Google+
  • Pinterest

Private net provides you with the power to deploy a brand new blockchain of your own. Under the hood, It uses three components:

  1. Genesis File
  2. Network Identifier — represents a positive integer
  3. Data directory

Alert: Disable node discovery. It’s really essential to disable the discovery of your blockchain to make it entirely private. Let us unfold above terms now:

Genesis file:

Private blockchain doesn’t contain any block on its own. It’s our responsibility to initiate the first block (Genesis block). To generate it, you need to create a json file which is known as genesis file. This file contains custom fields which are required to transform the nature of our first block. It provides protection against other nodes on the internet which can take part in the consensus mechanism by comparing the genesis block.

Here is how it looks:

Here is the explaination of each term:

  1. “config”: it defines the blockchain configuration
  2. “chainId” : it provides protection against several cyber attacks including replay attack and identity theft.
  3. “homesteadBlock”: it shows that we are using homestead release of Ethereum
  4. “epi155Block”: epi — Ethereum improvement proposal provides an indication that this file is used to contribute in Ethereum project.
  5. “nonce”: it’s a 64 bit hash which shows that the block has been mined through sufficient computational work.
  6. “Timestamp”: a value which is equal to the time function of respective os. Smaller the value between two blocks the larger the difficulty is to find the next one.
  7. “Parenthash”: it’s a 256 bit hash (keccak) and includes both mixhash and nonce. It points to the parent block. Since genesis block doesn’t have any parent thus its value is 0.
  8. “gasLimit”: as explained previously. It’s the value which corresponds to the threshold on expenditure of gas in our network. Keep it high. Because we don’t want our car to become out of gas.
  9. “Difficulty”: Higher the value of difficulty. The higher is the calculations required to extract out next block. Its calculated from previous blocks difficulty and the time stamp.
  10. “mixhash”: a 256-bit hash which is produced by the combination of nonce and is necessary to establish proof of work.
  11. “coinbase”: it is the sum of the mining reward and the Contract transaction execution refunds and is known as etherbase.
  12. “alloc”: It defines pre-established wallet.

Data Directory:

This is the directory where all the blockchain data for Ethereum network is stored.

There are many flags available out of which:

— rpc -> used to enable remote procedure calls in geth — port -> used to define other port for listening.

— nodiscover -> This flag stops the discovery of nodes automatically.

— datadir -> used to allocate data directory.


Let us now create our own initial block.

  1. Create a new folder and name it as Blockchain.
  1. In the current directory ,

You need to manual create a data directory.

Initialize a directory by mkdir and name it as blockdata

  1. Create an empty file and name it as genesisdata.json and paste the genesis file in it..
  1. To initialize genesis block in our data directory which is blockdata. But we need to tell geth about where they are right now.

geth — datadir=./<address of data directory>/ init ./<address of genesisdata. json>

  1. Lets fire up geth and connect to our private chain. We used a networkid 1995 for isolation. Make sure that port 30303 is not in use. Use ps aux and grep to identify the process which is currently using 30303.

geth — datadir=./chaindata/ — networkid 1995 geth — datadir=./chaindata/ — port “<anyportnumber>”

  • Facebook
  • Twitter
  • Google+
  • Pinterest
  1. After the completion of the command you can now clearly see an ipc has been generated on the port 30303.

This signifies that the private network has been established successfully.

There are two ways to interact with our blockchain:

1) Via Console.

Let us attach a console with our previously deployed blockchain using ipc (interprocess communication).

geth attach ipc:.address_of_datadir/geth.ipc

As it is still a brand new blockchain. It doesn’t have any accounts in it. To show the list of the accounts.


To create a new account personal.newAccount(“Yourpasswordhere”)

I’m going to set my account as my main beneficiary which is known as etherbase:


Okay! Now we have our etherbase. Let us check if there is any balance in it. miner.getBalance(eth.coinbase)

Huh? A zero as usual. Let us mine some currency for business. miner.start(no_of_threads)

It’s the right time to explain the mining:

A miner performs the foll-owing operations at root level

  1. Listens out transactions which were broadcasted on network and identify the transactions to be processed.
  2. Determines additional state blocks — Uncles — Ommers, and adds them into the main one.
  3. Updates balance with the earned reward from mining.
  4. At last, return a valid state and block is finalized, which defines the entire result of all state transitions.

Uncles ,Ommers, Stale blocks? What’s going on?

An Ommer is a block whose parent is equal to the current block’s grandparent. They are used to increase decentralization of the chain as well as distributing rewards to miners.

As Ethereum is built to provide lower block times than other blockchains. There is a possibility that two miners can discover the same block at an instant.

This discovery generates the uncles or “orphaned blocks”. They increase the difficulty of blockchain and rewards the miners.

However, the reward is quite small than the full block.

One more question? Ask.

If Difficulty increases with time, then why don’t miners just startup their own chain within the network? After all it will reward them much faster?

Wow! Nice question! To answer this thing, let me introduce you the black ops team of Ethereum. The “GHOST” (Greedy heaviest observed subtree). Now consider a blockchain, in which somehow your miners started their own branch.

Let the red node shows the current progression point of miners. Such branching in the blockchain is called “fork”. It is injuries for the health of blockchain. To defeat such uneven forking GHOST applies a rule on the entire chain which says –


To determine that path we will use the block number of the leaf block that clearly shows the total number of blocks. Longer the path, greater the mining effort , higher the value of computation.

Ohh! I almost forgot to stop the miner,


To check out current balance,


That’s enough with the console. Let us introduce our second phase of interactivity.



Mist is an integrated electron app which is a hybrid of desktop and web app. It gives us the power of faster development by making the interaction user friendly with a GUI.

You can download the mist from their official repository Extract the mist archive into blockdata folder

  • Facebook
  • Twitter
  • Google+
  • Pinterest

To launch a mist instance. You need to give a remote procedure call to a private chain

./<directory of mist>/mist –rpc ./<path of the ipc file>/geth.ipc Man! It worked.

Wait for it to sync the node and launch the app.

Welcome to the mist dashboard.

Can you see the ether balance of our mining?

Do you remember our problem?

Let us create four accounts and name them accordingly.

  • Facebook
  • Twitter
  • Google+
  • Pinterest

Make sure to name etherbase as Government.

Now we can easily transfer our balance from one end to another.

I think we forgot something?:

Ohh! Smart contracts! Yes! Be ready with that page!

  • Facebook
  • Twitter
  • Google+
  • Pinterest

Let’s jump right into them.



Solidity is a statically typed high level language used to write smart contracts. It’s meant to target the Ethereum Virtual Machine. There are many platforms on which Solidity can be compiled and here we are going to use “Remix — A browser based IDE for Solidity”.

Let’s get started with an example.

  • Facebook
  • Twitter
  • Google+
  • Pinterest

The first line of code says it is written to run on version 0.4.0 or superior of solidity. It confirms that the smart contract is going to act same in all the versions of solidity newer than 0.4.0.

The keyword pragma is used to give instructions to the compiler. A contract with reference to Solidity is a collection of code (its functions) and data (its state) that is present at a specific address on the Ethereum blockchain. Above a contract named ‘Test’ has been created with data as a state of uint type. There are both setter and getter methods present in the contract namely set() and get() respectively.

Smart Contracts:

Contracts in Solidity are analogous to the classes in object-oriented languages. Any contract can contain declarations of the type variables of state, events, functions, modifiers of function, enums and structs, although it is designed around the syntax of ES(ECMAScript) so that it is familiar to the existing web developers; unlike ES it has static typing and different return types. Complex member variables are supported for contracts that may contain arbitrary-hierarchical structures and mappings. There are variables that can be accessed from anywhere in the contract. They are :-

block.timestamp (uint): current block timestamp as seconds since unix epoch

block.coinbase (address): current block miner’s address block.gaslimit (uint): current block gaslimit

  • Facebook
  • Twitter
  • Google+
  • Pinterest

now (uint): current block timestamp (alias for block.timestamp) msg.gas (uint): remaining gas

msg.sender (address): sender of the message (current call)

block.difficulty (uint): current block difficulty

msg.sig (bytes4): first four bytes of the calldata (i.e. function identifier) msg.value (uint): number of wei sent with the message tx.origin (address): sender of the transaction (full call chain)

tx.gasprice (uint): gas price of the transaction block.number (uint): current block number (bytes): complete calldata

Let’s code out the conditions according to that page which we have created before.

Then we will deploy the contract.


Ethereum is a gateway to deploy both public and private blockchain.

Decentralization stratergies of

ethereum opened a new dimension of web apps which were more secure yet faster in speed. A new era has began with web 3.0 and Dapps is the next future of development.




Animation Rights – htm#term=contract&page=1&position=1 age=1&position=17#term=hospital&page=1&position=17 age=1&position=17#term=hospital&page=1&position=17 and the rest of freepik community including me :-).

— — —

Ashish Bairwa is an exceptional blockchain enthusiast and can be reached on his linkedin.

— — -

Dr. Sukant Khurana runs an academic research lab and several tech companies. He is also a known artist, author, and speaker. You can learn more about Sukant at or and if you wish to work on blockchain, biomedical research, neuroscience, sustainable development, artificial intelligence or data science projects for public good, you can contact him at or by reaching out to him on linkedin

Here are two small documentaries on Sukant and a TEDx video on his citizen science effort.


Please enter your comment!
Please enter your name here