Now, we will look into the structure of the Bitcoin block header, in which the header consists of a block and each block holds the following three sets of block metadata:
- A reference to a previous block hash
- The difficulty, timestamp, and nonce parts of the header
- The Merkle root
Let's look at the various terms represented in the following diagram:
The following is an elaboration of the terms mentioned in the preceding diagram:
- Version: The first part of the header is the 4 bytes of version. A version number tracks software protocol upgrades. It is really important to capture that data as part of the block itself because, if there are any changes made in subsequent versions of the program, it becomes necessary to capture which program or node is running each program to send the transactions and blocks across the internet.
- Previous Hash Block: The second part of the header is the 32 bytes previous hash block or previous hash block code. It's a reference to the hash of the previous block in the chain. It's not just a link to the previous block, it's a hashed pointer to the previous block, which makes sure that the new block added maintains the sequence of the blocks or the chain.
- Merkle Root: The third part of the header is the 32 bytes of the Merkle root. We just looked at the Merkle root, which is a hash root of the Merkle tree. It is a final hash code of all the transactions that were captured as part of the block.
- Timestamp: The fourth part of the header is the 4 bytes of timestamp. It is the approximate time taken for the creation of this block. We use the term approximate because once the block is created, it takes a few milliseconds to get added to the actual blockchain as the transactions are verified by different nodes.
- Difficulty target: The fifth part of the header is the 4 bytes that capture the difficulty target. It's the proof of work algorithm of the blocks. It is given for a particular node that is running the Bitcoin blockchain program.
- Nonce: The sixth part of the header is 4 bytes of the nonce. It is the counter used for the Proof of Work (PoW) algorithm. Whichever node is first in calculating and solving the mathematical problem actually yields the result of the problem-solving solution and the result contains this nonce, which is used to capture the transaction and verifies that the PoW being carried by the node is correct.
Thus, we can see that this is the typical structure of a Bitcoin block header, which is roughly 80 bytes of information that is captured in each of the blocks.