Blockchain 101: Blockchains and Consensus Mechanisms

Cryptocurrencies are booming in 2021, with market capitalization moving from $750 to more than $3 trillion. Let's face it, this is mostly down to speculation. Many involved have no idea what is behind the tokens they invest in.

But if we put that aside and look at the technical fundamentals, we can admit that 2020-2021 will bring a lot of new blockchains with better, faster (viable?) consensus mechanisms, which Proof of effortand new widely used applications, such as decentralized finance (DeFi) and Non-Fungible Tokens (NFTs).

Before we get into these, we need to take a step back: What is a blockchain? A cryptocurrency? A Proof of work? A block? A wallet? A smart contract? The Ethereum Virtual Machine (EVM)? One The ERC-20 token? An NFT? Decentralized economy (DeFi)? Oracle?

This article is the first of a series of 3 focusing on the technical basics behind crypto:

Disclaimer: Not a financial advice.

What is a blockchain?

A blockchain is a decentralized trustless peer-to-peer database which stores a special type of data: blocks. Blocks are immutable and ordered in a chain, where a block has only one preceding and one succeeding block. Thus the term “blockchain”.

A block consists of:

  • A time stamp;
  • A gang tasks;
  • A the pointer to the previous block (its hash).

In most popular blockchains (e.g Bitcoin, Ethereum), also known as distributed ledgersare the records stored by blocks transactions. Examples of transactions: coin transfers or function calls (more on this later).


Consensus mechanisms

Most blockchains are without permission: anyone is free to add servers to the network and to interact with the blockchain, including malicious actors. Blockchains had to be invented consensus mechanisms which ensures that every block written to the database is valid.

These consensus mechanisms rely on cryptography and game theory: it must be more profitable to write legitimate transactions in blocks than to try to write fake transactions (eg create coins from nowhere).

Proof of work

Proof of Work (PoW) was the first consensus mechanism designed and implemented. Bitcoin and Ethereumthe most popular blockchains around, are based on PoW and have proven to be unbreakable: they have never been hacked.

Let's dive into the Bitcoin implementation of PoW. It will help us understand how cryptography and game theory are used together in blockchain. I guess you know what a hash can be found in the following section.


You have probably already heard the term “mining”, which means to participate in adding blocks to the blockchain.

To be added to the blockchain is a block linked to its hash (which will be referred to in the next block). The hash of the block is calculated on:

  • Block's time stamp;
  • Block's transactions (the number of transactions included in the block is limited by the maximum block size: 1 MB for Bitcoin);
  • The previous block's hash;
  • A nonce (a number chosen to match specific conditions).

The hash must meet the following conditions to be accepted by the network: be less than target hash. A target hash is a numeric value in hexadecimal used to set the difficulty of the mining process. It can be adjusted to raise or lower it, thus adjusting the mining speed. (E.g. for Bitcoin, the target hash is adjusted by the network so that a block is broken every ten minutes).

A typical target hash looks like this: 0000000000000000000633b91a8cd72235104935c9d3af0b0edae9ad6f89f4ef. The number of leading zeros is what makes the hash hard to find because it reduces the size of the target hash.

The modifiable part only of a block is nonce. So to find the right hash, miner (blockchain nodes) must iterate on all possible nonces until they find the right one.

block_nonce = 0
while block_hash > TARGET_HASH:
  block_hash = hash(
  block_nonce += 1


Take a look at how a Bitcoin block looks on an explorer: for example on Bitcoin Explorer!

Block rewards

The first miner to find a matching nonce is be rewarded with some Bitcoinsbut only if the block is is further validated by other peers.

This rule does everyone miners compete with each other and cause miner servers to become more and more powerful to win Bitcoins. Miner servers are therefore expensive to buy and power.

Game theory comes into play at this point: to have another chance win the race to break a block you have to spend a lot of money on materials and energy; and to win money (= Bitcoins) the transactions contained in the block must pass on validated by the network (comrades). If a miner tries to push fake transactions, the block will do so is not validated and the miner is not rewarded. Therefore he will do it lose the money put into the mining process!

Immutability is maintained by cryptography and game theory

Relying on hashes ensures that the blockchain is immutable: change a single transaction in a block would completely change the hash of the block. But since the next block the latter's hash, its hash would also change!

Application developers using Git are familiar with this concept: each change to a previous commit generates a divergent hash for all subsequent commits and the branch will then diverge from the remote.

Let's say someone wants to modify a transaction that occurred 4 blocks agohe must:

  1. Find the name of the changed block (only using the power of a few complicit miners);
  2. Find the name for each of the next four blocksbecause their hashes would all change;
  3. Get the network to validate the blocks.

We can imagine that this process will cost a enormous amount of energy with poor chances of success: it's not worth trying!

Evidence of work limitations

The PoW consensus mechanism is good at securing the Bitcoin blockchain but it is:

  • Slow: 1 block every 10 minutes;
  • Expensive and bad for the environment: a lot of material and power is needed;
  • Does not scale well: much of the work is done for nothing because the miners compete;
  • Reasonable for the 51% attack: if an organization owns more than 51% of the miners, it can choose which transactions are allowed to be written to the blockchain by invalidating blocks.

All these limitations led to the design of new consensus mechanisms.

Proof of effort

Proof of Stake (PoS) is the most widely used alternative to PoW. In PoS, nodes are not called miners but validator and must stake (= lock) a large number of tokens to participate in block validations.

For each block, a group of validators is selected for validation (that is, often quorum based). The number of blocks a validator is involved in is proportional to the size of its stake: if it has 1% of the blockchain coins, it will be picked for 1% of the validations.

As in PoW are nodes rewarded upon block validation and cryptography is used to ensure immutability.

There are many different implementations of PoS, here are some examples:

Other mechanisms?

There are consensus mechanisms other than PoW and PoS, but none of them have yet reached massive adoption.


In this article, we have scratched the surface of how blockchains and consensus mechanisms work. In the next we will talk more about how to interact with distributed ledgers and blockchain.

If you want to find out more, there is very good and detailed documentation around. Some examples:

#Blockchain #Blockchains #Consensus #Mechanisms

Source link

Leave a Reply