Network and blocks
Block header
The block header is the 80-byte summary of a block that miners hash repeatedly.
- Size
- 80 bytes
- Fields
- Six
- Hashed
- Twice with SHA-256
- Links to
- The previous block’s header
- Headers per year
- About 52,560 on Bitcoin
What it means in practice
It holds the version, the previous block's hash, the Merkle root of the block's transactions, a timestamp, the encoded difficulty target and the nonce. Changing any field, including one transaction through the Merkle root, changes the hash completely. Only the header is hashed, which is why mining speed does not depend on how many transactions a block contains.
Why the work is smaller than 80 bytes
SHA-256 reads its input in pieces of 64 bytes. The header fills one piece and a quarter of a second one. The first piece holds the version, the previous hash and most of the Merkle root, none of which depend on the nonce, so its result can be kept and used again.
That kept result is called the midstate. A chip computes it once per job and then repeats only the second piece and the final hash for each nonce. Mining software has done this since the early days.
Rolling bits of the version field gives several first pieces that share the same second piece. Chips can then reuse part of that work as well, a method known as AsicBoost.
What each field lets a checker prove
The previous hash ties the block to its parent, so changing an old block would break every block after it. The Merkle root ties in each transaction. The bits field states the target, and the hash of the header shows whether it was met. The time puts the block in order. The version signals support for rule changes.
With headers alone, a light wallet can check the work of the whole chain. Given a short list of hashes, it can also check that one transaction is inside a block.
How small the chain of headers is
Example figures: 52,560 headers of 80 bytes are 4.2 MB a year. All the headers to block 900,000 are 72 MB, which fits on a phone. The blocks behind them take hundreds of gigabytes.
New nodes use this. They fetch every header first, check the work, and then download the blocks in parallel from many peers.
Where it appears on a miner
A stratum job is a header in kit form: previous hash, version, bits and time, plus the parts needed to build the Merkle root. When a share goes back, it names only the values the machine chose. The pool rebuilds the header and hashes it once.
Bytes are stored in reverse order in several fields, so a raw header looks different from the hashes in an explorer. Comparing the two without turning the bytes around is a classic puzzle for anyone writing mining code.
The timestamp has to be later than the median of the last eleven blocks and at most two hours ahead. Within that span miners may move it, which gives them a little more room to search.
Worked example
The header fields sum to 4 + 32 + 32 + 4 + 4 + 4 = 80 bytes, so a 200 TH/s machine processes about 80 × 2 × 10^14 = 1.6 × 10^16 bytes of header data per second (before SHA-256 optimisations).
Example figures, not live data.
Common mistakes
- Thinking that bigger blocks are harder to mine; the header has the same 80 bytes.
- Reading the bits field as the difficulty number.
- Expecting the block’s own hash inside the header; it is calculated from it.
Common questions
What is a Merkle root?
One hash that stands for all transactions in the block, built by hashing them in pairs until one is left.
Do all coins use 80-byte headers?
Litecoin, Dogecoin and Bitcoin Cash do. Zcash and Kaspa have longer ones with other fields.
Can a header be changed after mining?
Any change gives a different hash, which would almost certainly miss the target.