Bitcoin Block Header format detailed explained with example
The Block Header are six attributes in each Bitcoin Block, starting at the ninth Byte nearby begin. Please read the Computer Basics, if you are not familiar with computers, to understand the whole Byte structure.
The Bitcoin Block Header has always a size of 80 Bytes, each field has a fixed length.
|Name||Size in Bytes||Description|
|Version||4||The version of the block structure.|
|hashPrevBlock||32||The hash of the header of the previous block in the Blockchain.|
|hashMerkleRoot||32||The Merkle Root of the Transactions of this Block. This field is detailed described in the post about the Merkle Tree.|
|Time||4||The time of creation in seconds since the 1970-01-01 00:00 UTC (Unix Time).|
|Bits||4||The as floating-point number decoded Difficulty.|
|Nonce||4||Miners increment this field while searching for a matching header hash.|
Versionis the field containing the block version. Stratum defines the pool extension version-rolling, which may allows the miner to change some Bits of this data field.
hashPrevBlockcontains the hash of SHA-256 twice times and the Bytes of the Header of the previous Block in the Blockchain.
- The field
hashMerkleRootcontains the hash of all transactions of the surrounding Block. Please read the article about Merkle Root and Tree, to learn, for what it is and how to generate this hash.
Timeis the count of all passed seconds since 1970-01-01 00:00. This is called the Unix timestamp and should be available in any modern programming language. Some methods return them as milliseconds (divide by one thousand) or nanoseconds (divide by one billion). Microseconds (divide by one million) are unusual. Don’t forget to make sure to use a timezone-neutral way or to correct it manual, respectively. This field doesn’t need to contain the exact time, the field content has to follow some rules.
- Miners increment the Nonce field to test the different hashes for a matching Header.
hashPrevBlock is on many sources described as the hash of the previous Block.
hashMerkleRoot ensure the integrity of the Transactions, so it is enough to chain only the Block Headers. That is why it is seen as independent object. That is for fair mining very important, cause the hashing time of a Block Header doesn’t increase with the count of transactions, just the build of the new Merkle Root, each time the unconfirmed Transactions changes.
That is the Block Header part from the Bytes of the first Block of the main Blockchain with the height 0:
Consulting the table above, the Bytes forms these groups:
|Name||Size in Bytes||Data||Hint|
|hashPrevBlock||32||00000000...||This is the header of the first Block, so it is zero.|
|hashMerkleRoot||32||3ba3edfd...||The Merkle Root from the Transactions. The field contains in this case the Hash of the Transaction, since the Block contains just one one.|
|Time||4||29ab5f49||As big endian 0x495fab29, decimal 1.231.006.505 and as time 2009-01-03 19:15.|
|Bits||4||ffff001d||The lowest possible Difficulty as Floating point number. As Difficulty notation 1.0, as Target 0x0000_0000_FFFF_0000_0000_0000_0000_0000_
|Nonce||4||1dac2b7c||As big endian 0x7c2bac1d and decimal 2.083.236.893. Any number, just to change the Header hash.|