What is a consensus mechanism?

What is a consensus mechanism?

Cryptocurrencies and blockchain technology rely on consensus mechanisms to function and gain user trust.

The blockchain is a distributed database that records data and allows users to exchange and store value in the form of cryptocurrencies. To coordinate and maintain such a decentralized system, participants must agree on the correct state of the system and who owns what at what time.

A consensus mechanism is the standardized way that blockchain nodes - the computers that run the blockchain and keep records of all transactions - reliably reach this agreement.

Why consensus is important

The goal of a consensus mechanism in the cryptocurrency world is to prevent bad actors from intentionally committing fraud. The classic example of fraud in the cryptocurrency world is "double spending."

Suppose Anthony, the bad guy in this scenario, tries to cheat by transferring 10 tokens to Bethany and then tries to transfer the exact same 10 tokens to Chris. The challenge is to make sure that everyone always knows and can agree on who owns which tokens. With this agreement or consensus, Chris would already know that Anthony no longer owns the tokens he proposes to send.

To engage in "double spending," a bad actor would have to get the nodes to accept a false transaction history, a history in which the bad actor did not spend the tokens and gave them to Bethany.

The consensus mechanisms solve the double-spending problem by making it expensive and difficult to propose a new block of validated transactions, which discourages bad actors from trying to do so.

At the same time, the mechanisms incentivize "good" nodes to propose blocks that they truly believe will be accepted in order to gain valuable rewards. As long as there are more good actors than bad actors, Anthony will not be able to alter the records on the blockchain to fake his transaction with Bethany.

Types of consensus mechanisms

The large number of crypto projects have explored a variety of different consensus mechanisms.

The two most widely used consensus mechanisms are:

  • Proof-of-Work, which Bitcoin and Dogecoin, among others, use for their currencies BTC and DOGE.
  • Proof-of-Stake, which Cardano, Solana, and Avalanche, for example, use for ADA, SOL, and AVAX, respectively.

A fundamental factor in the design of both currencies is that it is extremely expensive to subvert the existing consensus mechanism. The difference between them is how they accomplish this.

How consensus works

In proof-of-work blockchains like Bitcoin, consensus requires a significant amount of energy, hardware, and computing power to propose a new set of transactions - called a block - to the ledger.

The nodes that validate transactions and propose new blocks are called miners. Miners compete to generate a random number that unlocks the next block in the chain. The miner who reaches that number the fastest adds the next block and receives a block reward in return for his efforts. The only way to win is to generate random numbers as fast as possible (the "work" in the name) and get lucky. This is a competition of computing power, which in turn requires hardware and power.

In proof-of-stake blockchains, the nodes - often called validators - that verify transactions and propose new blocks must deposit a certain value in the form of the blockchain's token - that's their stake in the system. The more value a validator deposits, the greater its chance of proposing a new block and receiving the block reward. If a validator makes a mistake, he has to pay a fee or can be excluded from the validation.