Blockchain and Ethereum Certification Tr... (38 Blogs)
AWS Global Infrastructure

What is Blockchain Technology? How Blockchain Works

Last updated on Dec 14,2021 10.6K Views

Shashank
Shashank is a Research Analyst at Edureka. He is an expert in... Shashank is a Research Analyst at Edureka. He is an expert in Blockchain technology with profound knowledge in Ethereum, smart contracts, solidity, distributed networks...
1 / 4 Blog from Blockchain Basics

Is Blockchain The New Internet? Well, it certainly is!! 

Blockchain technology is the Internet 3.0 or the Internet of Protocols. What started as an evolution is gradually becoming a revolution. It has the potential to transform business as we currently know it, but understanding how is not so easy.  So Here’s a leaflet for you to perceive How Blockchain works. 

  1. What is Blockchain Technology?
  2. How Blockchain Works?
    2.1 Independent Verification of Transactions
    2.2 Aggregation of Verified Transactions
    2.3 Mining of a Block
  3. What if Someone Tries to Hack the System?

What is Blockchain Technology?

Blockchain is a decentralized distributed database of immutable records, where transactions are protected by strong cryptographic algorithms and the network status is maintained by the Consensus algorithm.

digital timestamp-how blockchain works-edureka
                Digital Timestamps

In simple words, Blockchain is a chain of blocks that contain information.

The technology was originally described in 1991 and was intended to timestamp digital documents to avoid backdate or tempering of any records.

However great the technology was, its true potential was not realized until Satoshi Nakamoto used it to create a digital cryptocurrency the Bitcoins“.

Blockchain Technology | Blockchain Tutorial for Beginners | Edureka

Now let’s see how Blockchain works.

 

How Blockchain Works?

Let’s try to understand how blockchain works with a simple transaction over a Blockchain network.Money send-how blockchain works-edureka

Suppose James wants to send 5 BTC to his friend Kevin. Now, this transaction is broadcasted in the form of a digital message.digital sign-how blockchain works-edureka

The digital message has a unique signature. Just like your signature provides the proof of ownership of the document, similarly, digital signature provides the proof that the transaction is genuine.

Now this generated transaction is broadcasted to the network where it propagates peer to peer.

txn propagates-how blockchain works-edureka
                   Transaction propagates peer to peer in the network

Suppose the above transaction is first received by node A in the network. 

Independent Verification of Transactions

Before sending transactions to its neighbors, each bitcoin node that gets the transaction will initially verify the transaction.Independent verification-how blockchain works-edurekaThis guarantees only valid transactions are propagated across the system while invalid transactions are disposed of at the first node which receives them. Every node confirms each transaction against a long agenda of criteria.

Aggregation of Verified Transactions

Independent aggregation of those transactions into new blocks by mining nodes combined with exhibited calculation through a proof-of-work algorithm.transaction aggregation-how blockchain works-edureka

  • By autonomously confirming every transaction as it is received and before propagating it, each node fabricates a pool of valid (however unconfirmed) transactions known as the transaction pool, memory pool or mempool
  • Transaction reaches Mining nodes it collects, validates, and relays new transactions just like other nodes
  • Unlike other nodes, miner node will then aggregate these transactions into a candidate block

Let’s understand this better with an example.

Let’s say Andy is a miner. (A mining node maintains a local copy of the blockchain, the list of all blocks created since the beginning of the bitcoin system in 2009)

aggregation of txn-how blockchain works-edureka

Now, after collecting all the transactions in a block, Andy needs to construct the block header. Now this step is important to understand how blockchain works

Constructing a Block Header

To construct the block header, the mining node needs to fill in six fields, as listed in the table:

SizeFieldDescription
4 bytesVersionTo construct the block header, the mining node needs to fill in six fields, as listed
32 bytesPrevious Block HashA reference to the hash of the previous (parent) block in the chain
32 bytesMerkle RootA hash of the root of the Merkle tree of this block’s transactions
4 bytesTimestampThe approximate creation time of this block (seconds from Unix Epoch)
4 bytesDifficulty TargetThe proof-of-work algorithm difficulty target for this block
4 bytesNonceA counter used for the proof-of-work algorithm

Once Andy’s node has all the fields filled in the block header, Andy started Mining the block.

Mining of a Block

  • With all the other fields filled, the block header is now complete and the process of mining can begin
  • The goal is now to find a value for the nonce that results in a block header hash that is less than the difficulty target
  • The mining node will need to test billions or trillions of nonce values before a nonce is found that satisfies the requirement

Now that a candidate block has been constructed by Andy’s node, it is time for Andy’s hardware mining rig to “mine” the block, to find a solution to the proof-of-work algorithm that makes the block valid.

Proof of work is a piece of data which is difficult(costly, time-consuming) to produce but easy for others to verify and which satisfies certain requirements.

Finding the Puzzle- Why is it hard?

  • The SHA-256 is a one-way function hence, brute force is the only way to a particular output value
  • On an average, it takes many random guesses to find a solution and thus the challenge is tough
  • It takes around 10 minutes on an average for someone to find the special key to the solution

To keep the coin distribution predictable, puzzles becoming increasingly difficult to solve when more people work on them.

Now, to validate the block according to the proof-of-work algorithm, Andy’s mining node has to reach the difficulty target. proof-of-work-how blockchain works-edureka

Let’s see how the difficulty is represented.

Difficulty Representation 

  • The block contains the difficulty target, in a notation called “difficulty bits” or just “bits“
  • Let’s say a block has 0x1903a30c as the difficulty bits. This notation expresses the difficulty target as a coefficient/exponent format, with the first two hexadecimal digits for the exponent and the next six hex digits as the coefficient

The formula to calculate the difficulty target from this representation is:difficultycoefficient-how blockchain works-edureka

So, such is the difficulty coefficient that Andy’s mining node has worked really hard to reach the difficulty target. Let’s see what happens next.

Successfully Mining the Block

  • Andy has several hardware mining rigs, each running the SHA256 algorithm in parallel at incredible speeds
  • The mining node running on Andy’s desktop transmits the block header to his mining hardware, which starts testing trillions of nonces per second
  • Almost 11 minutes after starting to mine block, one of the hardware mining machines finds a solution and sends it back to the mining node
  • Immediately, Andy’s mining node transmits the block to all its peers
  • They receive, validate, and then propagate the new block. As the block ripples out across the network

Now that that block is propagated in the network, each full nodes independently verifies the block

Independent Confirmation of Each Block

  • In bitcoin’s consensus mechanism, each new block is validated independently by every node on the network 
  • This ensures that only valid blocks are propagated on the network
  • Nodes validate the block by checking it against a long list of criteria that must all be met

Assembling and Selecting Chains of Blocks

Once a node has validated a new block, it will then attempt to assemble a chain by connecting the block to the existing blockchain

 

assembling block-how blockchain works-edureka
In the network shown above, once the node (in orange) validates the      block, it assembles the chain by connecting the block to the existing blockchain

Once the block is verified by the network, it becomes the part of the blockchain and for successfully solving the block puzzle the miner is rewarded.

Miners Reward

  • Since Miners use their valuable resources to validate the block, they are given a monetary award
  • In case of Bitcoin, they get some newly created Bitcoins as a reward

reward-how blockchain works-edureka

Now, the question arises, what happens in the case when more than one block gets solved at the same time?

Yes, this is possible indeed! In such case, several branches exist.

Several Branches

  • Although the problem is tough, however, there are chances that more than one block will be solved at the same time
  • Several branches in the blockchain are possible in such cases
  • Everyone should simply build the blocks on top of the first block that they receive
    Several branches-how blockchain works-edureka
  • Other Nodes may have received the blocks in a different order
  • They will be building on the block they first receive

Several branch-how blockchain works-edureka

  • The tie gets broken when someone solves the next block because it is very rare for this situation to happen multiple times in a row

The tie gets broken when someone solves the next block, because it is very rare for this situation to happen multiple times in a row

  • Blockchain quickly stabilizes in this situation
  • The general rule is to switch to the longest chain available

longest branches-how blockchain works-edureka

The Blockchain quickly Stabilizes. Every node is in agreement with the current state of the ledger.

longest chain-how blockchain works-edureka

Alright, so consensus rules save the blockchain network from such ambiguity.

Now, another question arises here, what if someone tries to alter any transaction or records in the system?

What if Someone tries to Hack the System?

Once a block is solved the cryptographic hash output becomes the identifier of that block.hack with system-how blockchain works-edureka

Since Blockchain is a back-linked distributed database of records. When a block is formed, the cryptographic hash output becomes the identifier of that block, which ties into the next block, creating a chain of blocks.previoushash-hoe blockchain works-edureka

Hence, the blockchain is secured by the strong cryptographic algorithm and there is no way to alter any record.

If someone tries to alter any transaction in any of the blocks, the hash of the block changes and consequently hash of all the previous blocks will change. The nodes will not arrive at the consensus and hence, the fraud can easily be detected

nutshell-how blockchain works-edureka

So, this is it. Take pride, for now you stand out of the crowd after knowing this handsome technology. 

I hope this How Blockchain Works blog was informative for you.

Got a question for us? Please mention it in the comments section and we will get back to you at the earliest.

If you wish to learn about Blockchain Technology and master the concepts of Cryptography, Blockchain Networks, Smart Contracts, Ethereum and the Hyperledger, check out our interactive, live-online Edureka Blockchain Course here, that comes with 24*7 support to guide you throughout your learning period.

Comments
2 Comments
  • Thanks for sharing this information. Nowadays blockchain technology is very popular and for the beginner, this information is very helpful. This blog explains the basic knowledge about blockchain like what is blockchain, how it works. Waiting for your next blog about blockchain technology in brief.

  • Hey, great write up this is exactly true. Thanks for sharing blog, I think most people unaware about blockchain and its use-cases but these blog going to help them for the leveraging their knowledge. This blog is very useful and important who are interested in the blockchain. And thanks for sharing this blog and waiting for your next blog.

Join the discussion

Browse Categories

Subscribe to our Newsletter, and get personalized recommendations.