Difference between revisions of "Difficulty"

From Bitcoin Wiki
Jump to: navigation, search
(How soon might I expect to generate a block?: show maths for estimating time to find a block)
(What is the current difficulty?)
Line 32: Line 32:
[http://nullvoid.org/bitcoin/difficultiez.php Difficulty History]
[http://bitcoin.sipa.be Graphs]
=== What is the maximum difficulty? ===
=== What is the maximum difficulty? ===

Revision as of 16:10, 6 March 2011

See also: target

What is "difficulty"?


How often does the difficulty change?

Every 2016 blocks.

What is the formula for difficulty?

difficulty = maximum_target / current_target

(target is a 256 bit number)

How is difficulty stored in blocks?

Difficulty is stored in blocks as a 4 byte integer, and the actual hexadecimal target is derived from it via a predefined formula. For example, if the difficulty in the block is 0x1b0404cb, the hexadecimal target is


The highest possible target (difficulty 1) is defined as 0x1d00ffff, which gives us a hex target of


So the difficulty at 0x1b0404cb is therefore:

0x00000000FFFF0000000000000000000000000000000000000000000000000000 /
= 16307.420938523983

What is the current difficulty?

Current difficulty, as output by BitCoin's getDifficulty.

Difficulty History


What is the maximum difficulty?

The maximum difficulty is roughly: maximum_target / 1, which is a ridiculously huge number (about 2^224).

The actual maximum difficulty is when current_target=0, but we would not be able to calculate the difficulty if that happened. (fortunately it never will, so we're ok.)

Can the difficulty go down?

Yes it can. See discussion in target.

What is the minimum difficulty?


What network hash rate results in a given difficulty?


To find a block, the hash must be less than the target. The hash is effectively a random number between 0 and 2**256-1. The offset for difficulty 1 is

0xffff * 2**208

and for difficulty D is

0xffff * 2**208)/D


D * 2**256 / (0xffff * 2**208)

or just

D * 2**48 / 0xffff

The difficulty is set such that the previous 2016 blocks would have been found at the rate of one every 10 minutes, so we were calculating (D * 2**48 / 0xffff) hashes in 600 seconds. That means the hash rate of the network was

D * 2**48 / 0xffff / 600

over the previous 2016 blocks. Can be further simplified to

D * 2**32 / 600

without much loss of accuracy.

At difficulty 1, that is around 7 Mhashes per second.

At the time of writing, the difficulty is 22012.4941572, which means that over the previous set of 2016 blocks found the average network hash rate was

22012.4941572 * 2**32 / 600 = around 157 Ghashes per second.

How soon might I expect to generate a block?

(The eternal question.)

The average time to find a block can be approximated by calculating:

time = difficulty * 2**32 / hashrate



$ python -c "print 20000 * 2**32 / 10**9 / 60 / 60.0"

and find that it takes just under 24 hours on average.

  • Any one grinding of the hash stands the same chance of "winning" as any other. The numbers game is how many attempts your hardware can make per second.
  • You need to know the difficulty (above) and your khash/sec rate (reported by the client).
  • Visit a calculator or perform the maths yourself,
  • Remember it's just probability! There are no guarantees you will win every N days.
