Blockchain 101: An Introduction to the Basics

Blockchain 101: An Introduction to the Basics

Unless you've been living under a rock for the past couple of years, chances are you have heard or read about blockchain technology, if not, I'm sure you're aware of the fad going on around cryptocurrencies. But have you ever wondered-

What EXACTLY is a blockchain?

A blockchain is a chain of blocks which contains information. Yeah, no kidding.

A blockchain is a distributed ledger (a digital record book sorta thing) that is open to anyone and everyone. An interesting trait of blockchains that makes them so very useful is that once some data has been recorded inside a blockchain, it becomes incalculably challenging to change it. But why?

A closer look at the blocks

Each block in a blockchain contains the following data:

  • Data

  • Hash

  • Hash of the previous block

The data stored inside the block depends on the type of blockchain. For example, the Bitcoin blockchain stores the details about a transaction such as the details of the sender, receiver and the number of coins.

The hash is a unique ID that identifies a block and all of its contents. You can compare it to a fingerprint. Once a block is created, it has a unique hash. An important thing to note here is, changing something inside the block causes the hash to change.

The third element inside each block is the hash of the previous block.

This effectively creates a chain of blocks and it's this technique that makes a blockchain so secure.

Understanding the blockchain

Consider the above blockchain as an example. As you can see each block has a hash and the hash of the previous block. So, block 3 points to block 2 and block 2 points to block 1 (by reference to the previous hash).

The first block is a bit different compared to the rest, it cannot point to the previous blocks because it's the first one. Hence, this block is called the genesis block.

Now, let's say you tamper with the second block which causes the hash of the block to change and in turn that will make block 3 and all the following blocks invalid because they no longer store the valid hash of the previous block.

So, changing a single block will make all the following blocks invalid.

But here's the catch, using hashes is not enough to prevent tampering as a system can calculate thousands of hashes per second which would then make the blockchain valid again even after a block is tampered with.

Then how do we deal with tampering?

To mitigate this problem, blockchains have two major mechanisms:

  • Proof of work

  • Smart contracts

Let's discuss these in layman's terms without getting caught into the technicalities.

PROOF OF WORK is a mechanism which slows down the creation of new blocks. In the case of blockchain, it takes around 10 minutes to add a new block (the one tampered with) to the blockchain. This makes tampering hard because if you tamper with one block, you will need to recalculate the proof of work for all the following blocks.

SMART CONTRACTS were tailored to exchange cryptocurrencies. These contracts are simple programs that are stored on the blockchain and can be used to automatically exchange coins based on certain conditions.

Another factor that plays a major role in the security of the blockchain is that it's decentralised. This simply means that instead of using a central entity to manage the chain, blockchains use P2P (peer-to-peer) network wherein anyone can join.
When someone joins the network, the person gets a full copy of the blockchain.

Now, whenever someone creates a new block, the new block is sent to everyone on the network, each node then verifies the block to make sure it hasn't been tampered with, hence, verification is based on the nodes' consensus.

So, to successfully tamper with a block in the blockchain, you'll need to tamper with all blocks on the chain, redo the proof of work for each block and take control over more than 50% of the peer-to-peer network and only then, will your tampered block be accepted by everyone else.

TLDR; it's almost impossible to tamper with the data within a blockchain.

I hope you close this tab with a clearer idea of the blockchain and how it works. If you have any questions, feel free to drop them in the comments below! :)