How the Blockchain works
Defining the blockchain in simple terms
Imagine you have a special notebook that you and your friends use to keep track of something important, like your favourite games. Instead of just one person taking care of the notebook, everyone in your group gets a copy.
Now, whenever someone wants to add a new game to the list, they write it down in their own notebook. But before it becomes official, everyone in the group needs to agree that it's a valid entry. They do this by checking each other's notebooks and making sure they all have the same information.
Once everyone agrees, the new game is added to everyone’s notebooks. This way, everyone has an up-to-date list of all the games owned by the group. If someone tries to cheat and change the information in their notebook, the other friends will notice because their notebooks won't match, and they won't accept the change.
That's a bit like how a blockchain works! Instead of a notebook, there is a special digital record-keeping system. Such a system keeps track of things like transactions (buying and selling), smart contracts, or any other important information. And just like in the notebook example, the information is stored in blocks.
But here's the exciting part: Each block is linked to the one before it, forming a chain. That's why it's called a blockchain! This trick makes it impossible for anyone to change the information in a block because it would affect all the other blocks in the chain.
The block structure
In a blockchain, a block consists of three key parts:
- The header: This contains important information like the time the block was created, a random number used in the mining process (nonce), and the hash of the previous block.
- The data section: Here, you'll find the actual juicy details! It includes things like transactions or smart contracts that are securely stored within the block.
- The hash: This is a special code that acts as a unique identifier for the entire block. It's crucial for verifying the integrity of the block.
Each block contains the hash of the previous block. If you try to change a transaction in a previous block, like for example stating that you received 10 BTC when that never happened, the other participants in the Bitcoin network will notice it right away, and will invalidate your copy of the blockchain. There is no way you can cheat. You should take control of at least 50% +1 computers that store the latest version of the Bitcoin blockchain, which is basically impossible.
A new Bitcoin block is created roughly every 10 minutes, and it is broadcast simultaneously across every computer that runs the Bitcoin machine. The computers are called “nodes”.
What is this hash? And why is it essential to make the blockchain work?
A hash is like a unique fingerprint for data. It takes any kind of information, whether it's a short message or a large file, and turns it into a 64-chatacters-long string of 32 bits. Just like every person has a unique fingerprint, every piece of data has a unique hash.
Let’s see an example of “hashing”.
We can take the word “SwissBorg” and turn it into an SHA-256 hash using a hash generator like:
Even the slightest change will generate a completely different hash. Let’s try to type “Swissborg” with the small ‘b’.
As you can see, even a tiny change in the data will produce a different hash. This property makes hashes very useful for verifying data integrity and detecting any attempts at tampering such data.
Hashes are widely used in various applications. For example, they are used for encrypting passwords. Each password has a corresponding hash, which allows any app to authenticate your login without knowing how your password actually looks like. It’s thanks to hashing that the system you register with cannot know your password, but can still authenticate you.
When it comes to a blockchain, each block has its own hash, which helps ensure that the block hasn't been tampered with. It acts as a digital seal of authenticity.
So, to summarise, a hash is a unique code generated from data that acts as a digital fingerprint. It helps ensure the integrity and security of information.
If you observe carefully, you can notice how the blockchain is a self-validating mechanism, which doesn’t need any external actor to seal the authenticity of the transactions or contracts registered upon it. This is why a currency like Bitcoin can be exchanged between parties without the intervention of any financial institution or intermediary party! And this is why Bitcoin is labelled as “decentralised”; it doesn’t need any central authority to work. Rather, it employs several nodes spread across the globe to run. None of these nodes is more important than others.
The blockchain is the ultimate, automatic, decentralised payment system, and the ultimate, automatic, decentralised notary!