Cryptocurrencies and Non Fungible Token (NFT) have become the daily bread for everyone. The thing these resources have in common is the Blockchain technology, that supports them.

But what is really a Blockchain and what is it for?

A Blockchain is a huge public digital database, decentralized and immutable, a sort of archive that contains accounting registers, where every time a cryptocurrency transaction is performed and indelibly recorded on the Blockchain thanks to a smart contract, with the characteristic that anyone can consult this archive and check the transaction log.

However, there is not a single large Blockchain, but more Blockchain platforms, more databases.

One of the main things in which a Blockchain differs from the other is the so-called consent algorithm, that is the mode with which the transactions are validated.

Starting from a Blockchain, it can also be created when a part of the community of knots are voluntarily separated by updating the software, that is creating a hard fork. If the update does not lead to a split, but is compatible with the old Blockchain, this is called soft fork.

In addition to this there are the sidechain, namely chains that work in parallel to a "mainchain", that is a mother Blockchain, in order to solve problems related to scalability, for example.

What is a Blockchain and why a Hard Fork occurs

A Blockchain is a digital database that you can't destroy by shutting down a central server because it is based on a decentralization mechanism where the computers that validate transactions and maintain the network are called nodes.

A hard fork is by definition a software update that is not compatible with previous versions. It occurs when the knots modify the platform and update the software with new rules so that they can communicate only with each other and no longer with the part of the network whose nodes are left to the old rules.

In other words, a part of the nodes by mutual agreement modifies the network and separates from the nodes that do not use the new version.

With a hard fork the Blockchain is practically doubled and two networks that operate in parallel are created, but also independently because they no longer communicate between them. Practically a second network is born which is precisely a hard fork of the Blockchain mother.

From a transaction history point of view all nodes have a common history until the fork was created, that is the Blockchain is split, from this point onwards to even the history of transactions and in fact they are now independent Blockchains.

One of the most known examples of hard fork of a Blockchain: Bitcoin Cash

A hard fork is therefore an update of the software that regulates the consensus protocol of a Blockchain and which in fact does that starting from one Blockchain you create another that becomes completely independent from the first.

When the two Blockchains separate for an update of the consensus algorithm they also become incompatible, and they stop communicating with each other.

Therefore if a native cryptocurrency operates on the main Blockchain, this too will be created a second version able to operate on the hard fork instead.

Taking a practical example that makes more clear everything, Bitcoin is a cryptocurrency born in 2009 that operates on its Blockchain. 

The two Blockchains, Bitcoin and Bitcoin Cash, are now incompatible and do not communicate, where each has its own native cryptocurrency. Yet, the two Blockchains share the history of the nodes and the transaction log prior to the occurrence of the fork, that is of the software update that led to the division of the network in all respects.

When does a Blockchain soft fork occur and how does it differ from the hard fork

In summary, a hard fork is an update of the consensus protocol of the Blockchain leading to the birth of a second independent Blockchain.

This is because the update of the hard fork is incompatible with previous versions of the Blockchain.

Otherwise a soft fork occurs when there is an update of the consent protocol, but this is compatible with previous versions of the Blockchain.

In other words, the nodes update themselves, but they continue to operate on the same Blockchain with which they have no communication problems.

Read also: Using blockchain: top features to help you!

A practical example: Bitcoin SegWit

Let's take another example concerning Bitcoins, this is because also in order to increase the block size of the network, an update was created called Bitcoin Segregated Witness (SegWit) which increased the size from 1 MB to 4 MB.

In practice, a soft fork does not lead to the birth of a second Blockchain independent of the first, but it is an update of the consensus protocol that involves only a part of the nodes of the same Blockchain, which continue to interact with nodes that use the old version with which they communicate perfectly.

Blockchain: what are mainchain and sidechain

Having clarified what hard forks and soft forks are in Blockchain technology, let's see what a sidechain is.

A sidechain is a parallel network that works alongside and linked to the mother Blockchain (mainchain), but not a hard fork, it is not born from a split and does not share a past history of transaction records with it.

A sidechain in practice is a Blockchain network, but linked to the main chain through what is called a two-way peg.

That is, the sidechain does not arise from a split and a disagreement within the parent Blockchain but as something from scratch, which for remains dependent on it.

In fact, if a hard fork generates a new and independent Blockchain, the sidechains are always anchored to the parent Blockchain on which they depend. The hard forks by separating become in turn mainchain that is main blockchains. The sidechains, on the other hand, continue to work together with the parent Blockchain.

How Polygon, the sidechain of Ethereum Blockchain was born 

Hard forks are born as opposed to a mainchain from which they completely separate, while a sidechain is born on the contrary in order to improve some aspects of a Blockchain itself.

An example of Ethereum sidechain is Polygon, also in this case the sidechain differs from the mother Blockchain for the consensus protocol in order to offer a solution that solves scalability problems of the mainchain.

Polygon in short, contrary to popular belief, it is not a mainchain, but an Ethereum sidechain.

How hard fork, sidechain and soft fork differ

In summary, hard forks, sidechains and soft forks are all evolutions of a Blockchain, but of a different nature.

The hard fork starting from a Blockchain creates an independent platform that becomes mainchain, does not communicate with the old network and is completely independent.

The sidechain is a chain parallel to a mother Blockchain that does not arise from a disagreement of the nodes, but from the will to offer innovative solutions to the problems of the mainchain itself. Sidechains such as Polygon therefore, while working independently and enjoying autonomy from the mother Blockchain, remain bound to it and aim to work with the mainchain to achieve a high level of interoperability. 

The soft forks are instead updates of the consensus protocol of a Blockchain which do not create an independent network and communicate perfectly with stale nodes.