Lessons 1/4 · 20 min
A block header, byte by byte
An identity card of 80 bytes
A block is made of a header (small, fixed size in Bitcoin) and a body (the list of transactions). The header summarises the block and links it to the chain. Let us start with Bitcoin, whose format is the simplest: the header is exactly 80 bytes.
| Bytes | Size | Field | Role |
|---|---|---|---|
| 0–3 | 4 | version | Rule set the miner announces following |
| 4–35 | 32 | previous block hash | Link to the parent (workshop 104) |
| 36–67 | 32 | Merkle root | Summary of all transactions (workshop 106) |
| 68–71 | 4 | timestamp | Seconds since 1 January 1970 UTC, claimed by the miner |
| 72–75 | 4 | bits | Difficulty target in compact form |
| 76–79 | 4 | nonce | Counter changed by the miner (workshop 109) |
The 4-byte integers are little-endian: the least significant byte comes first. The block hash is SHA-256 applied twice to those 80 bytes. In Bitcoin, explorers display this result with the bytes in reversed order; the "internal" order is the one used in the computation.
Reading fields by hand
Version: the bytes 00 00 00 20 read little-endian give the integer 0x20000000, which is 536,870,912 in decimal.
Timestamp: the bytes 00 3c 9a 65 give 0x659a3c00 = 1,704,606,720 seconds, that is 7 January 2024 at 05:52:00 UTC. (An example value chosen for the exercise, unrelated to any specific block.)
Nonce: the bytes 2a 00 00 00 give 0x2a = 42.
The bytes tool below does these readings for you: paste hexadecimal, slice ranges, read little- or big-endian, reverse the order.
The "bits" field: the target in compact form
The 4 bytes ff ff 00 1d read 0x1d00ffff. The most significant byte, 0x1d = 29, is the exponent; the next three, 0x00ffff, are the mantissa. The target is mantissa × 256^(exponent − 3), here 0xffff × 256^26. A block hash, read as a big number, must be less than or equal to the target. A smaller target requires more leading zeros in the displayed hash: that is the difficulty.
And elsewhere?
Not every network has this header. An Ethereum header contains, among others, the parent hash, a state root, a transactions root, a receipts root, a block number, a timestamp and fee-related fields. A CometBFT header contains, among others, the previous block's identifier, the hash of the validator set and an app_hash field that commits to the application state. Names and sizes change; the idea stays the same: a small object that commits to everything else.
What this does NOT guarantee
- The timestamp is claimed by the miner: it is constrained by tolerance rules, but it is not an exact clock.
- The version field does not prove a miner really applies the rules it announces.
- A low block hash proves work was done, not that the body's transactions are valid.
Recap
The header is a commitment of 80 bytes (in Bitcoin): parent, summary of the transactions, difficulty, nonce. Its double SHA-256 is the block's identity.
Interactive tool
Byte inspector
Paste hex, cut out a slice and read it as a little-endian or big-endian integer.
Length: 14 bytes
| 0000 | 02 | 00 | 00 | 00 | 0a | 00 | 6c | 1f |
|---|---|---|---|---|---|---|---|---|
| 0008 | 4d | 5e | 1d | 00 | ff | ff |
Slice as hex
02000000Little-endian unsigned integer
2Little-endian signed integer (two's complement)
2Big-endian unsigned integer
33,554,432Big-endian signed integer (two's complement)
33,554,432Bytes reversed (hex)
00000002UTC date of the slice (little-endian): 1970-01-01T00:00:02Z
For example a block header timestamp. It can be read from the slice above.
2009-01-03T18:15:05ZInteractive tool
SHA-256 of hex bytes
Paste bytes as hex: the hash covers the bytes, not the text of the digits. A second field is concatenated after the first.
Digest
…Spaces, newlines and 0x prefixes are ignored.
