Notes on Bitcoin target representation

Bitcoin has a weired representation for the target encoded into field nBits of each block header


The target value is the limit that a miner need to find a lower block hash than in a PoW


  • The target is set so that a block is mined roughly every 10 minutes
  • The initial target was set as 00000000ffff0000000000000000000000000000000000000000000000000000 or 0x1d00ffff
    which can be checked from here

  • This original value is the highest a target value can have
  • As mining get faster the target adjusts before every 2016th block roughly 2 weeks
  • difficulty = original target / target
  • Based on the difficulty we can say it is now difficulty (value) times harder to mine bitcoin
  • The difficulty value is just a metric which is not used internally on the software
  • If the blocks have been mined in less than 10 mins. the difficult increases (target decreases)
  • If the blocks have been mined in more than 10 mins. the difficult decreases (target increases)
  • Why isn't ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff the maximum target ?

    Because it will essentially mean that every hash is lower than this value, very large number


The target is packed a custom floating point type with limited precision Mantissa Exponent number

The first 2 hex digits are the coefficients and the following 6 hex digits are the exponent


Assuming the packed target is 0x1b0404cb then the hexadecimal target can be derived as

target = coefficient * 2**(8*(exponent-3))

target = 0x0404cb * 2**(8*(0x1b - 3)) = 0x00000000000404CB000000000000000000000000000000000000000000000000


Each block stores the packed target into the block header nBits field for the actual hexadecimal target