How Blockchain Works?

In this tutorial, we will learn what is blockchain technology and how it works. Let’s start!!!

What is blockchain

Blockchain Technology has been creating waves in the tech world for quite some time now. It has become popular thanks to Bitcoin, and all the subsequent cryptocurrencies that work on this technology. However, not a lot of people actually quite understand what it is and how it exactly works.

Let’s start with the basics, blockchain technology can be defined as a distributed database of transactions maintained by a network of computers that makes it very difficult to hack.

Distributed ledger technology

Blockchain technology is often also referred to as Distributed ledger technology (DLTs), but they are not quite the same. DLT is a decentralised database managed by multiple participants. Blockchain is a form of DLT, the only difference is the addition of an extra layer of security in blockchain because of the cryptographic signature called hash. Hence, blockchains are a more secure variety of DLTs.

How does Blockchain work?

To understand the process of how blckchain works, we need to start by familiarising ourselves with some basic terms that are quite important when it comes to Blockchain technology.

1. Blocks

Blocks are the fundamental units of a blockchain, they contain data or information. The purpose of a block is to store data but It also contains 2 very important numbers:

a. Nonce: This is a 32-bit random whole number generated whenever a block is created, it further generates a block header dash.

b. Hash: This is a 256-bit number that is directly dependent on the nonce. It always starts with a large number of zeroes (and hence, has a small value).

The nonce and the hash are important as they create a block’s digital signature. Digital Signatures are a security layer that relies on cryptography. Following the generation of a block, the nonce creates a cryptographic hash, which is used to verify the authenticity of the data inside the block.

Digital signatures are unique, just like fingerprints and a valid digital signature is proof that data has not been altered. Once the data stored in a block is considered signed, it becomes associated with its nonce and hash unless mined.

2. Mining

Mining is the process through which miners create new blocks. A very crucial component of a blockchain is not that every block has its own nonce and hash, but also that it has reference to the hash of the previous block in the chain. This is why mining is a formidable task, especially on long chains.

What happens in mining?

Since, the nonce generates the hash for a block, miners use a variety of special softwares to solve complicated maths problems to find that nonce. Using the nonce they try to generate the hash.

When they find the right nonce-hash combination, that block is mined and added to the chain, and the miner is rewarded for the same.

Understanding re-mining

The reason why blockchain is considered a pinnacle of security, is primarily because to alter the data in ONE block, that block will have to be re-mined, which will cause the chain to break. Lets try to understand this using a small chain of 5 blocks – A, B, C,D, and E.

Every block in our blockchain contains a nonce, a hash, some data, and the hash of the previous block connected to it. Hence, block B contains the hash of A, C has the hash of B, D has the hash of C and so on.

Now, if I want to make some change in the data of block B, I will have to re-mine it, so technically now B occupies the fifth position in my chain. But, as soon as I make this change, the blockchain algorithm will realise that the “previous hash” mentioned in block C (now at the second position) does not match the hash of block A (which is at the first position) as a result of which, the chain will break.

Hence, if we want to make change to even a single data block, we will have to re-mine it and all the subsequent blocks in that chain.

3. Nodes

Blockchain Technology is quite popular because of its decentralisation. Here, decision making power does not rest with a single entity and thereby, no individual or organisation can actually own it.

Blockchain: A distributed Network

The blockchain database is distributed over a network via the nodes connected to the chain. A node can be any electronic device capable of maintaining a copy of the blockchain. For any change in the chain to occur, it has to be algorithmically approved by all the nodes.

Hence, at any given moment we will need the approval of all the nodes connected to the chain for a newly mined block to be updated, trusted and verified.

This peer to peer network promotes transparency, and through this every action or decision in the database can be checked, viewed and tracked.

Blockchain Transaction Process

Now that we have understood the basic terminologies related to blockchain. We can try and understand how blockchain (including cryptocurrency) transactions occur!

1. A new transaction is entered.
2. This transaction is transmitted to the peer to peer network.
3. The network of computers solve the equations in order to validate the transaction.
4. Once the transaction is verified, they are clustered together into blocks.
5. These blocks are then chained together, making the history of transactions permanent.
6. The transaction is complete.

Understanding using an example

Imagine 2 friends, Aman and Aditya who decide to bet $100 each to check which one of them is a better runner. They place a box in front of them and deposit $100 each in it, whoever wins will take $200 home. To make sure that the judgement is fair, they call 5 of their friends to witness the race and decide the winner, let’s call them the jury. At the end of the race the jury decides that Aman was the winner and he is handed $200.To keep a record of the entire adventure the jury also records it on their phones!

This is kind of how blockchain works, lets understand the analogy :

1. By the end of the bet, a transaction of $200 is to be from the box to Aman. This is a representation of a block.

2. When all (or a majority of ) members of the jury agree that Aman was the winner, we can say that the transaction has been verified by the participant nodes.

3. The video recording makes the process indelible and transparent. This is equivalent to the addition of the block on the chain, because it is a record of the transaction that proves that Aman was paid the full amount.

4. Aman receiving the money is analogous to the transaction being completed!

Cryptocurrency Attributes

Since blockchains are most popularly used in cryptocurrencies, let us try and learn cryptocurrency attributes :

1. Intrinsic value: Cryptocurrencies are a secure, reliable and fast way of value transfer with little to no cost.

2. No physical form: A valuable attribute of cryptocurrencies is that they do not need a physical form, they exist solely on the immutable blockchain.

3. Decentralised: All attributes of a cryptocurrency are decided upon by the majority of the members in the peer-to-peer network instead of a central bank.

Summary

In this article, we have learnt the basic terminology involved when it comes to blockchain technology like mining, nodes, peer-to-peer network and decentralisation. We discussed what a block is, what information it contains, how the blocks are chained, and how a blockchain works.