TECHNICAL_DOC // BLOCK / BITS
BITS
The bits field is a 4-byte compact encoding of the current proof-of-work
difficulty target stored in every block-header/">block header. It encodes a 256-bit target number
in floating-point style: 1 byte exponent and 3 bytes mantissa. A valid block hash must be
numerically less than or equal to the target. Lower target = higher difficulty.
BITS_DECODING
COMPACT TARGET FORMAT (nBits)
nBits = 4 bytes in block header (stored little-endian)
Format: [exponent 1 byte] [mantissa 3 bytes]
Example: nBits = 0x1903a30c
exponent = 0x19 = 25
mantissa = 0x03a30c
Target = mantissa × 2^(8 × (exponent − 3))
= 0x03a30c × 2^(8 × (25 − 3))
= 0x03a30c × 2^176
= 0x0000000000000003a30c000000...0000
Block hash must be ≤ this target to be valid.
Genesis block nBits: 0x1d00ffff
→ target = 0x00ffff × 2^(8×26)
→ first 4 bytes: 00 00 ff ff ... (very easy)
RETARGETING — EVERY 2016 BLOCKS
Retarget period: 2016 blocks (≈ 2 weeks at 10 min/block)
new_target = old_target × (actual_time / 1,209,600 seconds)
↑ 2 weeks in seconds
Clamped to: max 4× increase or 4× decrease per period
If blocks found in 1 week (too fast):
new_target = old_target × 0.5 → harder
If blocks found in 4 weeks (too slow):
new_target = old_target × 2.0 → easier (capped at 4×)
nBits is recalculated and written into the first block
of each new 2016-block period.
Difficulty vs Target
RELATIONSHIP
Difficulty is a human-readable number inversely proportional to the target. Higher difficulty = smaller target = harder to find a valid hash.
difficulty = difficulty_1_target / current_target
difficulty_1_target (genesis difficulty):
0x00000000FFFF0000...0000 (nBits = 0x1d00ffff)
Example (2024):
current nBits ≈ 0x17034219
difficulty ≈ 86 trillion
Meaning: a miner must try ~86 trillion hashes on average
to find one hash below the target.
Hashrate estimate from difficulty:
hashrate ≈ difficulty × 2^32 / 600 seconds
TERMINOLOGY_INDEX
nBits
The 4-byte compact representation of the proof-of-work target stored in each block header.
Target
A 256-bit number. A valid block header hash must be numerically ≤ target. Decoded from nBits.
Difficulty
Human-readable measure: difficulty_1_target / current_target. Proportional to expected hashes needed.
Retarget
Difficulty adjustment every 2016 blocks (~2 weeks) to maintain 10-minute average time-10-minutes/">block time.