Blocks, Hashes and Merkle trees.


A blockchain is made up of blocks.

But, it is what is inside these blocks that form the foundation of the entire technology behind blockchain.

We know that when a block is being generated by a miner, the details of a large set of up to 2020 transactions chosen by that miner, along with their Coinbase address ( the wallet address of the miner who has mined the block, so that their reward for mining the block may be paid there.)  are collectively used to create a single block. But how are all these transactions put into a single block? And how are they found later?

This is where the concept of Merkle trees comes into action.

To understand Merkle trees, let us first look at the concept of Hashing.

Hashing and hash values:

The concept of hashing basically involves taking a long word of length L, and representing it using a shorter word of Length S, (where L>S). The value stored into the S length word is termed as the hash value for the original word. Basically, it’s like creating a nickname for a person!

There exist several algorithms that are used to convert letters or numbers into hash values of fixed length. These hash values can be combined and run through the same algorithm again to get another hash value.

For example, if we have two names: Thomas And Benjamin. We can use a hash algorithm to create a hash value for both these values- Tom and Ben. Now, we combine these two values together to get TomBen. Passing this value through a hash value could give us a new hash value, that can represent both – TB.

Merkle Trees:

A Merkle Tree is essentially a hash tree which uses the hash values of the various child transactions and combines them to give the parent hash value.

This process is repeated multiple times until a single hash value that can represent the entire tree at the root node is generated.

The root node element formed by combining the hash values of all the child node hash values is called the Merkle Root.

The Merkle root can be used along with some values to generate the entire tree as and when necessary. This allows us to identify every transaction stored on the single block and to verify if any transaction is a part of the block with a certain Merkle root.

For example, let us consider a Merkle tree of colours.

We can say that if there are 4 leaf nodes- made up of the colours: Red, White, Yellow, and Blue.

Let us assume the hash algorithm gets hashes by mixing the colours up! So, we’d get Pink and Green as the next level nodes.

The Merkle root would be the combination of Pink and Green- Which gives us brown!



So, if we were asked to verify the existence of green in the system, and we were told about the existence of Blue, pink and Yellow- then all we need is the Merkle root- which is brown.

So how would we go about solving this?

We know that brown is made using Blue and Pink. We also know that to make Blue, we need to use Green Alongside Yellow (which we already know exists).

Thus, by looking back, we are able to acknowledge the existence of Green in the system.

In a similar manner, it is possible for us to check the existence of any transaction within a block using the Merkle root, and the details of a few other child nodes already in the system.

Let’s look at another case!

If we suddenly decide to change the colour from red to Purple.

This would change the colour of the node above since the hashing algorithm is mixing the two colours. So, this would also change the Merkle root! Thus, any passer-by would notice that the root value (or in this case, colour) has changed!

Thus, the Merkle root allows us to identify any changes that are attempted on any transaction on the block.

Now, if some attacker tries to change the values of any transaction, the hash value will also change. Thus, the of hashes of the nodes above will also change and a different, incorrect root will be produced- thus telling the external viewers of the blockchain, that somebody has attacked it.

And That’s how Merkle Trees work!

Blockchain 101 is a series of posts that aim to make the concepts of blockchain easy and understandable. 
Stay tuned for more! 

About Blockchain


Blockchain is a shared public ledger system where every user has the updated version of the entire past transaction history represented by the chain of blocks itself. It is the most secure and decentralized way to perform value-based services online.

How is this possible?

Blockchain uses traditional technologies like databases, hashing, and cryptography to replace trust with mathematical proof. Every node has the updated version of the current blockchain and they together verify the transactions in each block before adding them to the blockchain.


Why hashing?

The node needs to be updated with the current blockchain after every block creation.  It wouldn’t be feasible to download the blocks and thus the transactions within it as it is. The amount of memory used to store the blockchain would be staggering and would discourage nodes from participating. To solve this all the transactions of a given block are compressed using a form of hashing called Merkle hashing.

Hashing returns a unique fingerprint for each block hashed.

This also helps in securing a transaction as any tampering of the transaction can be easily detected.


Block, chain?

A miner in the system is a node that helps in verifying a block before the system can add it to the blockchain. All the miners in a system try to solve a complex mathematical puzzle to get the reward associated with it. This is called proof of work and helps in maintaining trust.

Once the block is verified, it is chained to the blockchain by adding the previous

block’s hash value to its block. This chaining prevents tampering of individual blocks as the chain will be broken.

The block is a container of the block header and the transactions.

The header contains the metadata information which is useful for both the mining and the chaining process. The transactions are stored in a Merkle tree structure and the Merkle root obtained is stored in the block header.


In this manner, Blockchain is a decentralized technology that allows for security and integrity of transaction information by eliminating trust between nodes and establishing consensus among through a secure validation mechanism.

Blockchain 101 is a series of posts that aim to make the concepts of blockchain easy and understandable. 
Stay tuned for more!