## What is bitcoin difficulty?

Bitcoin difficulty is an estimate about how difficult it is to mine (find) a new bitcoin block. Bitcoin mining has two main purposes. One is adding transactions to the bitcoin block chain. The other purpose is to create new bitcoins.

The total number of bitcoins that will ever be mined is limited to 21 million. Moreover, the bitcoin protocol determines a time horizon over which the bitcoins will be created.
This is done to limit the supply of bitcoins.
**A new block is mined every 10 minutes**. The number of bitcoins in one block is currently BTC 25 and
is halved every 210,000 blocks or approximately every four years.

If everybody could easily mine new bitcoins, inflation would be the result. **Bitcoin difficulty exists to ensure a limited bitcoin supply.**
This does not mean there could be no inflation for bitcoin. Activities like
bitcoin lending can increase the bitcoin money supply. But the main underlying driver of
money supply remains the monetary base which is represented by the number of mined bitcoins. Therefore bitcoin difficulty is important to maintain the
bitcoin purchasing power.

Bitcoin mining gets more difficult with an increasing computing power in the network. The protocol always makes sure the pre-defined trajectory of bitcoin creation is kept. The computing power is measured in hashes per second. To understand what that means, the process of mining needs to be explained in further detail.

## Bitcoin mining overview

When a computer mines bitcoins, it tries to calculate a hash which is the block's header. The hash starts with a certain number of zeros. The number of zeros is defined by the **target**.
The target is a 256-bit number and is therefore extremely long. All bitcoin clients know the target.

It gets more difficult to mine bitcoins, the more leading zeros the hash has got. At the same time the computer is more likely to find a block at a given bitcoin difficulty when it has more computing power.

This makes it crucial to optimize mining hardware.
At today's high bitcoin difficulty levels, almost all miners use so called **ASICs** (application-specific integrated circuits). These are more efficient in their energy
consumption and have a higher chance to find a bitcoin block.

#### Mining is like playing a game of probabilities

Mining resembles a game where you **roll a dice** which returns a hash. If the hash starts with a number of zeros that is smaller or equal to the number of
zeros as defined by the target, you have won a bitcoin block. If the number of zeros is larger, you have to roll the dice again.

The more dices are rolled at the same time, i.e. the more computers are mining, the higher is the probability to find a new block. The probability also increases if the computing power of a single machine is increased. It simply resembles throwing more dices at the same time.

#### Bitcoin mining pools are the way to go

Since mining difficulty is really high today, single miners are very rare. Most individuals join their computing power in so called mining pools.

To make sure that on average a new block is created every 10 minutes only, **the target needs to be adjusted frequently**.
This is because every second new mining rigs can be added to the network.

## Bitcoin difficulty explained

The bitcoin protocol determines the recalculation frequency of the target. This means the protocol also determines the bitcoin difficulty.
A new recalculation takes place every time the number of 2,016 blocks have been mined. If the targetted interval of 10 minutes per
block was realized, this takes two weeks. Every bitcoin client does the reacalculation on its own by simply comparing the actual time it took to mine
2,016 blocks with the two weeks it was *supposed* to take. **The target is modified by the percentage deviation from the
targetted time**.

Two weeks are the equivalent of 336 hours. So if for instance 2,016 blocks were mined in 13 days instead of 14 days, this is a deviation of 7%.

The concrete value for the bitcoin difficulty is derived from the target.

This means that bitcoin difficulty can also go down should the mining of blocks take longer than 2 weeks. In December 2014 this actually happened for the first time. Bitcoin is live since January 2009, so it took quite a while.

Since the bitcoin difficulty went down in 2014 for the first time, this didn't happen very often again. Most of the time a decline in bitcoin difficulty is driven by a decreasing bitcoin price. A lower price makes bitcoin mining less profitable. This causes miners to turn their machines off which decreases the hash rate. A lower hash rate means on average it takes longer to mine new bitcoin blocks, hence the bitcoin difficulty needs to decrease.

## What is the bitcoin hash rate?

The formula to calculate the amount of time it takes on average to win a block is

`average time in hours = difficulty * 2^32 / (3,600 * hash rate per second)`

We can solve this equation for the bitcoin difficulty, it returns

`difficulty = average time in hours * (3,600 * hash rate per second) / 2^32`

We can plug in 10/60 for the average time in hours for an exemplary calculation. This is because 10 minutes is the time it should take until a new block is found by a miner. Let's say the hash rate is at 1 tera hash per second (it was like that a long time ago). Then this is what our bitcoin difficulty calculation looks like:

`difficulty = 10/60 * (3,600 * 1 tera hash)`

`difficulty = 600,000`

So this example calculation gives us a bitcoin difficulty of 600,000. The real difficulty has been at this value approximately
in mid 2011.

## How is the bitcoin difficulty prediction calculated?

To predict the next difficulty, the bitcoin client

next retarget in days is an estimate when the current 2016 blocks will be mined

## Embed bitcoin difficulty data

You can easily embed this data no your website. You can use these iframes.