Blockchain has proven to be a revolutionary technology, transforming various industries. In its literal sense, it means a chain of blocks. With blockchain, digital information, such as financial transactions, are stored in separate blocks in a chain. Robust cryptographic methods protect the transactions, and a consensus algorithm maintains the network status, enabling transparency. This blog provides a detailed look at how blockchain works.
Understanding How Blockchain Works
For this blog and a simplified explanation of how blockchain works, here is an example of a transaction over a blockchain network. Suppose a user, say, John, wants to send a few bitcoins to his friend Amy. This transaction is broadcasted as a digital message. It has a digital signature assigned to it. This digital signature validates the transaction as genuine.
Next, this transaction is broadcast to a peer to peer network. The network’s first node receives it. The transaction is then verified and passed on to the next bitcoin node on the network. Every node carries out the verification process on the network before the transaction is completed. This ensures that only valid transactions pass through the system.
Each node creates a confirmed (mempool) pool and non-confirmed transactions (transactional) pool and propagates the transaction forward. The transaction then reaches a mining node. This node collects, validates, and propagates a new transaction. The miner node, then, aggregates the transactions into a candidate block.
Blockchain and Mining Nodes
To better understand how blockchain works concerning mining/miner nodes, suppose another user, Michael, works as a miner(mining node) in this transaction. Michael first collects all the transactions in a block and then constructs a block header. The mining node fills in six fields: Version, Previous Block Hash, Merkel Root, Timestamp, Difficult Target, and Nonce, to construct a block header. Once all these fields are filled, block mining can be started. Here is a look at each field:
- Version: Size 4 bytes – Displays the version of the block.
- Previous Block Hash: Size 32 bytes – It references a hash of the chain’s last block.
- Merkel Root: Size 32 bytes – It is a hash of the Merkel Tree’s root of the block transaction.
- Timestamp: Size 4 bytes – It shows the approximate time taken to create the block.
- Difficult Target: Size 4 bytes – The proof of work algorithm difficulty target of the block.
- Nonce: Size 4 bytes – It is used as a counter for the proof of work algorithm.
With the block header now complete, the block mining process starts. Mining aims to find a value for the nonce. Billions and trillions of nonce values need to be tested before a nonce that satisfies the requirement is found.
The next step is to find a solution to the proof of work algorithm that makes the block valid. Proof of work is a piece of data that satisfies the transaction requirements and is easily verifiable by others. Michael’s mining node has to reach the difficulty target to validate the block. The block contains difficulty targets in a notation called ‘difficulty bits.’
Successfully Mining a Block
Next in the line of how blockchain works are the successful mining of a block. Michael has various computing devices that rapidly run the SHA-256 algorithm parallel to each other. The hardware receives the block header, and testing is started at trillions of nonces per second.
Once a mining machine finds a solution, it is sent back to the mining node, and the block is transferred to the peers immediately. A new block is validated and propagated, and it is verified by each full node independently. Once the new block is validated, it is assembled into a chain by connecting the block to the existing blockchain. After verification, it becomes a part of the blockchain. The process is carried out until the entire transaction is complete. Amy then receives the bitcoins from John.
This blog has hopefully helped you understand how blockchain works. To know more about the technology and take on a career path as a blockchain developer, you can enroll for upGrad’s PG Certificate in Blockchain Technology. It provides one-on-one mentorship and 200+ hours of learning content with zero-percent EMI options.