The text reads "What is a blockchain and how does it actually work?" The image has a black background, and shows depictions of Bitcoin and Ethereum. On the right hand side a smartphone screen can be seen showing a graphic describing the fluctuation of various cryptocurrencies

What is a blockchain and how does it actually work?

Blockchain may be the most talked about and least understood topic on the internet. Wherever you look at, from LinkedIn to Instagram to Twitter, everyone’s talking about crypto and blockchain. People are trying to use this technology for everything from securing IoT devices to storing medical records. So what exactly is blockchain? How does it work? Let’s have a look. 

What exactly is blockchain?

Imagine a group of people who lends and borrows money from each other. One among this group of people keeps a record of all of these transactions, to track how much everyone owes each other. As you can imagine, this creates a huge trust problem. There’s just one record of all of these transactions possessed by just one person. This one person can alter the records as they please, clearing their debts or giving themselves a lot of money. 

It doesn’t even have to be this person themselves. Since there’s only one record, anyone who gains access to this can make changes as they please. 

This is what blockchain solves. 

Instead of a single person maintaining a single record of all transactions, blockchain is a system that gives a record of transactions to everyone involved(in very simple terms). Every single transaction is updated in all the records, and more than one person has to verify a transaction. And a person who is verifying the transaction will get a reward. 

What this means is that no single person can alter the transactions. And since there are multiple records, an intruder will have to make changes in all of them.

This is how a blockchain is distributed and decentralized. Everyone has a copy, and there’s no single authority or third party that has authority over the network. Every node (the people or computers) have a copy of the transactions (the ledger). 

What is a block?

As the name suggests, blockchain is literally, a chain of blocks. 

Every block consists of four things

  • The transactions in the block
  • The cryptographic hash of the previous block
  • Nonce
  • The hash of the block

(We’ll explore what these are in the next section)

In a blockchain, every block is linked to the blocks before it. 

When you do a transaction over a blockchain, a given number of nodes will validate it. A number of these transactions are then clustered into a block. And the block is added to the chain. 

Based on the process of adding a block there are two types of blockchains: proof of work and proof of stake. Proof of work is commonly known as mining. Bitcoin used proof of work. Proof of stake is relatively new. Ethereum began as a proof of work blockchain, but it is now adopting proof of work. 

What is proof of work or mining?

In proof of work blockchains, the nodes in the network have to solve a difficult mathematical puzzle to add a block to the chain. 

To understand mining, you have to learn about an interesting function called the hash function is. 

As you may know, when you give a value to a function, it returns a corresponding value(f(x) =y). With a hash function, when you input a value of any size, you’ll get an output of fixed size. 

For example, for a hash algorithm named SH 256, if you give an input of 

Hello World 

You’ll get an output of 

64ec88ca00b268e5ba1a35678a1b5316d212f4f366b2477232534a8aeca37f3c

For an input of 

How are you doing world

You’ll get an output of 

5ca65d3c1162b5f00a98d4ddd5454e2dd7e0bdc99827a26ee7da409a180d2039

As you can see, even when the size of the input varied, the size of output remained constant. 

Another peculiar feature of a hash function is that it is one-way. That is, you can get 

5ca65d3c1162b5f00a98d4ddd5454e2dd7e0bdc99827a26ee7da409a180d2039 (cipher text)

From 

How are you doing world (plain text)

But you can’t find the plain text if you have the cypher text. The algorithm is designed in such a way that finding the plain text from the cypher text would take a lot of computing power and time. 

Mining

If you recall from the previous section, every block in the blockchain has a hash of the previous block. The contents of the previous block are run through a hash function and stored in the new block. This is how the blocks are linked to each other. 

To add a block to the chain, the miners have to find the hash of the block. For this, the transactions, the hash of the previous block and the nonce value are entered into a formula. I know I haven’t explained what nonce is, but stick with me. 

The formula will produce a hash. But the resulting hash must be equal to or less than the target hash. The target hash is changed after every 2016 blocks. 

If the hash produced is not less than or equal to the target hash, the formula will be applied again for a different nonce value. The process is repeated until a miner finds the golden nonce or the nonce that fits the conditions. Once the nonce value is found, it is verified by other miners and then the block is accepted to the chain. The node that found the golden nonce is rewarded in cryptocurrency. 

How does Proof of Stake blockchain work?

The problem with proof of work blockchains like Bitcoin is that the energy consumptions are through the roof. It was easier to mine bitcoins when there were only a few miners. But now you need some serious hardware and energy to mine a single bitcoin. 

Proof of work, which was thought to be previously unhackable was found to have a vulnerability from what’s called a 51% attack. If a person or a group has more than 51% of the computational power in the network, they could validate fraudulent transactions. 

Here’s where proof of stake comes up. The idea is that only people who own a certain amount of cryptocurrency could validate the transaction. For example, if someone has 10% of the coins available, they can mine only up to 10% of the blocks.  

Since there’s not a lot of computational power involved here, so the energy consumption would be low. The 51% attack is still possible, but for this, the attacker would need to own 51% of the coins. And someone who owns 51% coins in a network will gain almost nothing by attacking the same network. 

In the case of Ethereum, you need 32 Ether to take part. A validator will be assigned at random from the group of people taking part. Once the validator validates a transaction, it is sent to a group of attestors. At least 128 attestors need to attest to the work of the validator for a block to be accepted into the chain. Once accepted, the network rewards both the attestors and the validators with cryptocurrency. 

Posts created 98

Related Posts

Begin typing your search term above and press enter to search. Press ESC to cancel.

Back To Top