Blockchain 101: Blockchains and Consensus Mechanisms

Cryptocurrencies are booming in 2021, with a market cap shifting from 750 to greater than 3,000 billion {dollars}. Let’s face it, that is primarily as a result of hypothesis. Lots of people concerned wouldn’t have a clue of what’s behind the tokens they spend money on.

But when we put that apart and take a look at the technical fundamentals, we will acknowledge that 2020-2021 are bringing alongside a bunch of recent blockchains with higher, quicker (viable?) consensus mechanisms, like Proof of Stake, and new broadly used functions, like decentralized finance (DeFi) and Non-fungible tokens (NFTs).

Earlier than going into these, we have to take a step again: What’s a blockchain? A cryptocurrency? A Proof of Work? A block? A pockets? A sensible contract? The Ethereum Digital Machine (EVM)? An ERC-20 token? An NFT? Decentralized Finance (DeFi)? Oracles?

This text is the primary of a sequence of three that focuses on the technical fundamentals behind crypto:

Disclaimer: Not a monetary recommendation.

What’s a blockchain?

A blockchain is a decentralized trustless peer-to-peer database that shops a particular sort of information: blocks. Blocks are immutable and ordered into a series, one block having just one previous and one following block. Thus the time period “blockchain”.

One block consists of:

  • A timestamp;
  • A bunch of data;
  • A pointer to the earlier block (its hash).

In hottest blockchains (e.g. Bitcoin, Ethereum), additionally known as distributed ledgers, the data saved by blocks are transactions. Instance of transactions: coin transfers or operate calls (extra on this later).


Consensus mechanisms

Most blockchains are permissionless: everyone seems to be free so as to add servers to the community and to work together with the blockchain, together with malicious actors. Blockchains needed to provide you with consensus mechanisms that make sure that each block written to the database is legitimate.

These consensus mechanisms depend on cryptography and recreation concept: it must be extra worthwhile to jot down authentic transactions in blocks than to attempt to write false transactions (e.g. create cash out of nowhere).

Proof of Work

Proof of Work (PoW) was the primary consensus mechanism to be designed and carried out. Bitcoin and Ethereum, the preferred blockchains round, are based mostly on PoW and have confirmed to be unbreakable: they’ve by no means been hacked.

Let’s dive into the Bitcoin implementation of PoW. It can assist us perceive how cryptography and recreation concept are used collectively in blockchain. I assume that you recognize what a hash is within the following part.


You will have in all probability already heard the time period “mining”, which suggests taking part in including blocks to the blockchain.

To be added to the blockchain, a block is related to its hash (that will likely be referenced by the following block). The block’s hash is computed on:

  • The block’s timestamp;
  • The block’s transactions (the variety of transactions contained within the block is proscribed by the utmost block dimension: 1 MB for Bitcoin);
  • The earlier block’s hash;
  • A nonce (a quantity that’s chosen to match particular situations).

The hash has to fulfill the next situation to be accepted by the community: be smaller than the goal hash. A goal hash is a numerical worth in hexadecimal used to set the problem of the mining course of. It may be adjusted to boost it or decrease it, therefore adapting the mining fee. (E.g. for Bitcoin, the goal hash is adjusted by the community in order that one block is mined each 10 minutes).

A typical goal hash seems to be like this: 0000000000000000000633b91a8cd72235104935c9d3af0b0edae9ad6f89f4ef. The variety of main zeros is what makes the hash troublesome to seek out as a result of it decreases the scale of the goal hash.

The solely modifiable piece of a block is the nonce. So to seek out the best hash, miners (blockchain nodes) must iterate on all of the potential nonces till they discover the best one.

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


Check out what a Bitcoin block seems to be like on an explorer: for instance on Bitcoin Explorer!

Block rewards

The primary miner to discover a matching nonce is rewarded with some Bitcoins, however provided that the block is additional validated by different friends.

This rule makes all of the miners compete with one another and result in miner servers being an increasing number of highly effective to win Bitcoins. Miner servers are due to this fact costly to purchase and energy.

Recreation concept enters into play at this level: to have an opportunity of successful the race to mine a block, one has to spend some huge cash on materials and vitality; and to win cash (= Bitcoins) the transactions which are within the block must additional be validated by the community (friends). If a miner tries to push false transactions, the block will not be validated and the miner not rewarded. Due to this fact, he’ll lose the cash put into the mining course of!

Immutability enforced by cryptography and recreation concept

Counting on hashes ensures that the blockchain is immutable: altering a single transaction in a block would completely change the block’s hash. However as a result of the following block the latter’s hash, its hash would additionally change!

Utility builders utilizing Git are accustomed to this idea: any change to a earlier commit generates a divergent hash for all of the later commits and the department will then diverge from distant.

Let’s say that somebody desires to alter a transaction that occurred 4 blocks in the past, he should:

  1. Discover the nounce for the altered block (utilizing solely the facility of some confederate miners);
  2. Discover the nounce for every of the 4 subsequent blocks, as a result of their hashes would all be modified;
  3. Make the community validate the blocks.

We will think about that this course of will value a large quantity of vitality with poor probabilities of success: it isn’t value attempting!

Proof of Work limitations

The PoW consensus mechanism is nice at securing the Bitcoin blockchain however it’s:

  • Sluggish: 1 block each 10 minutes;
  • Expensive and unhealthy for the setting: lots of materials and energy are wanted;
  • Doesn’t scale properly: lots of the work is completed for nothing as a result of the miners are competing;
  • Smart to the 51% assault: if a corporation owns greater than 51% of the miners, it will possibly select 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 Stake

Proof of Stake (PoS) is essentially the most broadly adopted various to PoW. In PoS, nodes are usually not known as miners however validators and must stake (= lock) a giant variety of tokens to take part in block validations.

For each block, a bunch of validators is picked for validation (that’s typically quorum-based). The variety of blocks {that a} validator is concerned with is proportional to the scale of its stake: if it has 1% of the blockchain cash, will probably be picked for 1% of the validations.

Like in PoW, nodes are rewarded when validating blocks and cryptography is used to make sure immutability.

There are lots of totally different implementations of PoS, listed below are some examples:

Different mechanisms?

Different consensus mechanisms than PoW and PoS exist, however none of them has but reached large adoption.


On this article, we have now scratched the floor of the functioning of blockchains and consensus mechanisms. Within the subsequent one, we are going to speak extra about the way to work together with distributed ledgers and blockchain.

If you wish to discover out extra, there’s lots of nice detailed documentation round. Some examples: