Blockchain, the name tells everything. I have already explained that a Blockchain is a chain of blocks. Today you will see what is inside a block in a Blockchain. A block contains a bunch of transactions added to the Blockchain. It is just like a page in a ledger. All the transactions that are not added to any of the existing blocks in the Blockchain are added to the current block. Transactions are validated and verified before adding to a block. Once a block is added to the Blockchain, no one can modify or delete transactions contained in the block. However, the information of a completed block is visible. This is how a Blockchain offers both transparency and immutability.
Structure of a Blockchain Block
There are two components of a block and there are further subcomponents of these two components.
- Block header
- Block body
This component of a block contains metadata about the block. Block header is used for identifying a particular block in that Blockchain. Here is the structure of this 80-byte long string.
|Software Version Number||4-Byte|
|Previous Block Hash||32-Byte|
|Difficulty Target For The Block||4-Byte|
|Nonce Used By Miners||4-Byte|
Software Version Number
This is a number used for tracking software/protocol upgrades. Computers use software version for reading the data inside the block correctly as the structure of data inside a block is described by this number.
Previous Block Hash
It is the hash that links the current block to the previous block and hence a Blockchain is made.
There is a hash associated with every transaction contained in a block. Hashes of all transactions are further hashed and what you get is the Merkle Root.
This timestamp marks the time of the creation of the block.
Difficulty Target for the Block
There is a size of every hash in bits. The goal of the current difficulty indicates how small the new hash must be in bits to be valid. A hash with no zeroes is bigger than a hash having zeroes at the beginning.
Nonce Used By Miners
The nonce is number used once. This is a random number a minor can manipulate.
All the confirmed transactions are contained in the body of the block. A miner validates all the transactions to construct a block. The miner reads information from the Blockchain to make sure that the sender has enough money to spend. Consider Bitcoin as an example. Someone wants to send 5 Bitcoins. The miner goes through the past blocks to make sure that the sender owns 5 Bitcoins. The transactions in a block are in Merkle Tree.
The Merkle name comes from the mathematician Ralph Merkle. This fundamental part of Blockchain is also known as a hash tree. The goal is to use a single hash for representing much information. First of all, each transaction is hashed. These hashes are further hashed and in the end, we get a single hash called Merkle root. Each leaf node represents a transaction and each non-leaf node represents a hash.
It is easy to create a root hash as long as leaves and hash function is known. A function hash works in one direction. However, it is impossible to break down the root hash in another direction. So, it is not possible to guess the transactions if only root hash is known. The rest of the block is also saved. The miner can easily and quickly hash transactions contained in the block and validate the root hash when the hash function remains the same.
What Is Mining?
While mining, the nonce is raised by one to get a special hash. The miner hashes the transactions and verifies if the hash value is less than the searched target value. In case this value is above the hash, the minor repeats this process and increments the nonce by one. If the miner still can’t find a hash below the target, he gets another block from some other networker having a hash below the target. The new hash is used as the “previous block hash”. The process of mining is repeated several times to find a special hash. The miner needs to do some guesswork to find the special hash. A lot of energy and computing power is required in this process. A special hash in Bitcoin Blockchain always begins with zeros.
Kuldeep Singh is a poet, lyricist, performer, a public speaker and a professional content writer from Chandigarh, the city Beautiful. Apart from writing, he also has a keen interest in programming, especially in Java. He uses Twitter & Facebook on very rare occasions.