In crypto, Difficulty refers to how hard is it to find the nonce value of a transaction. If the difficulty is high, it would mean that finding the hash requires more computing. The parameter is used to prevent too many miners clogging the network.

Also difficulty ensures that the space between production of two blocks remain consistent. This brings stability into the blockchain as all blocks will now be equally sized.

## Table of Contents

## What is Difficulty?

Difficulty is the computational effort required to find the nonce value of a transaction in a blockchain. Nonce values are those unique numbers which are added to every transaction and are a result of hashing the following values:

- Hash of the previous block
- Transaction amount
- Sender and Receiver addresses

During the calculation of nonce value, one must increment a value and keep repeatedly hashing the data till the resulting hash value is equal to the network’s hash difficulty.

## Difficulty is used to Control Miner/Validator Population

Difficulty of a blockchain increases with the number of miners or validators because there is a limit on the number of new blocks that can be produced in a given time.

Mining difficulty is adjusted after a certain period. For Bitcoin, the mining difficulty is adjusted once every 2016 blocks.

If the number of new blocks is not controlled than an increased number of new miners will produce a high number of blocks. Since each block in a blockchain gets you some rewards (newly minted coins), therefore increased rewards will be accompanied with more coin supply. This will ultimately lead to a collapse in token price.

Therefore to limit the number of blocks that can be produced at any given time, the difficulty of a blockchain is adjusted automatically.

## How is Mining Difficulty Calculated and Adjusted?

Difficulty is calculated in terms of hash power of all the validators. If the hash rate is high, it means there are more miners. Therefore, the mining difficulty has to be increased.

The mining difficulty could be calculated using a variety of formulas.

Here’s a simplified explanation of how mining difficulty is calculated in Bitcoin:

**Target Block Time:**The Bitcoin protocol aims to have a new block added to the blockchain approximately every 10 minutes.**Previous Difficulty:**The difficulty at which the last 2016 blocks were mined.**Time Taken(Block Time):**Calculate the time it took to mine the last 2016 blocks.**Adjustment Calculation:**If it took less than two weeks to mine the previous 2016 blocks, the difficulty increases. If it took more than two weeks, the difficulty decreases.**New Difficulty:**The difficulty is adjusted by changing the target value that miners must meet when solving the proof-of-work puzzle. A higher difficulty requires more computational power to find a valid block.

The formula for calculating the new difficulty is:

This formula ensures that if the network is finding blocks too quickly, the difficulty increases, making it harder to find the next block. Conversely, if blocks are taking too long to mine, the difficulty decreases, making it easier.

## Mining Difficulty Chart

The mining difficulty chart shows how mining difficulty has changed over a given time. The mining difficulty chart for Bitcoin is shown below for the year of 2023.

## What Miners do when Difficulty Increases?

When Bitcoin mining got popular, the number of miners increased and this led to an increase in difficulty. To combat this, Bitcoin miners created **mining pools **where miners use to pool their computational resources and start mining as a team. With increased resources, they would now have a greater chance at discovering new blocks.

#NOTE: Block discovery works in a way where the fastest one to verify and add transactions to finish a block is the only one to be rewarded. Other blocks which could not be included in the blockchain are called** orphan blocks**.

## Impact of Mining Difficulty

### Resource Consumption

If the mining difficulty is not periodically regulated, the number of miners would rise disproportionately. This would cause an increased usage of power and computational resources (CPU, GPU). This could lead to power shortages.

An increased mining difficulty discourages new miners after a certain level.

### Token Price Stability

Token prices remain relatively stable because their supply is well regulated. If there would be uncontrolled mining, then token price would also come crashing down as each miner would produce several blocks and get mining rewards.