Bitcoin is the leading cryptocurrency globally, with a market capitalization of just below $200 billion. The entire blockchain-based digital currency network is decentralized, with miners working across the globe supporting the blocks of data lying underneath. The consensus algorithm at the core of Bitcoin is named proof-of-work, and it ensures all bitcoin transactions happening in the network are recorded permanently and transparently in blocks.
Within Bitcoin, there are many concepts to learn: mining, hashrate, halvings, running a node, 51% attacks, etc. Here we look at the parameter that keeps the average time between blocks mined steadily at an average of 10 minutes as the network hashrate fluctuates, network difficulty.
What is Bitcoin Network Difficulty?
The Bitcoin blockchain is a series of transaction data stored in the form of blocks across various nodes around the globe. The blockchain is designed to add a new block of transaction data after an average time of 10 minutes. This addition of new data takes place through a process called mining. In this process, the miners across the world running the bitcoin node try to solve a puzzle. The puzzle involves a race to find a hash number less than a target value set by the bitcoin algorithm.
The respective hash number is generated by a function that takes a number input called the nonce for each miner. Miners repeatedly iterate to find the right nonce so that their unique hash numbers fall below the target value. Whoever finds the correct nonce first, and therefore a compatible hash number, is eligible for a block reward. This reward stands at 6.25 newly-minted bitcoins since the halving that took place in May 2020.
If the Target Hash value is high, the iterations required by the miners to find a correct hash number are generally low, and hence, less time is taken to mine the block. If the Target Hash value is low, more iterations are required to find a hash smaller than the new target. Meaning more time is consumed to find the correct hash and mine the block.
This Target Hash value determines what the current Bitcoin Difficulty is. There is an inverse relationship between the Target Hash value and the Bitcoin Difficulty.
What is Bitcoin Mining?
The Bitcoin blockchain is maintained by miners worldwide that choose to run a bitcoin node and mining software. The incentive to run mining software is the "block reward" that these miners get in the form of newly-minted bitcoins when they decode the hash puzzle and mine a block.
Mining requires sophisticated hardware capabilities to function. The electricity costs associated with these mining machines are now on the higher end. Often, when Bitcoin's price is high, more miners are attracted to join the network to get a reward. In times of lower prices, miners' incentive is lower since the electricity costs to run the machines struggle to meet the block reward. In such times, miners usually leave the network, and hence the overall network hashrate decreases.
Bitcoin miners use application-specific integrated circuits (ASIC) to go through as many iterations as possible to find the correct hash number before others do. While some miners run a Bitcoin node on a small desktop, many have developed large mining farms to mine as many blocks as possible. The collective computing power of all the miners across the Bitcoin network is known as the Network Hashrate. A higher hashrate correlates to a higher difficulty, and a lower hashrate correlates with a lower difficulty. Again, Bitcoin Difficulty's purpose is to keep the average block time steady at 10 minutes.
How is Bitcoin Difficulty Calculated?
The Bitcoin Difficulty adjusts every 2016 blocks based on the time it took to discover the previous 2016 blocks. If a block is mined every 10 minutes (as intended initially for a steady emission), mining 2016 blocks will take exactly two weeks. If it took longer than two weeks to mine the previous 2016 blocks, the Bitcoin Difficulty would decrease. And if it took longer than two weeks, the Bitcoin Difficulty would increase.
The new Bitcoin Difficulty is calculated based on the following formula:
The Purpose Behind Bitcoin Difficulty
The Bitcoin Difficulty keeps the addition of blocks in the Bitcoin blockchain steady. The Difficulty parameter maintains the 10-minutes average. Satoshi Nakamoto likely designed this 10-minute block target window deliberately. It was a trade-off between the first confirmation time and the amount of work wasted due to chain splits.
It is estimated that around 10 minutes are required to propagate information about the latest block from one node to all the nodes across the globe so that the whole blockchain remains synchronized. If blocks are mined faster, it will result in wastage of mining efforts for miners as only one blockchain record is kept. The remaining forks will be discarded. Difficulty plays its ultimate goal here in maintaining this 10-minute window and saving computational wastage.
Bitcoin Difficulty and its impact on the mining market
The Bitcoin Difficulty has a positive correlation with the Bitcoin price and the Bitcoin Hashrate.
As the Bitcoin price increases, the value of mining rewards increase, and the mining revenue per H/s or TH/s also increase. More miners are incentivized to turn on their mining machines that were previously unprofitable or buy more machines to start mining; with more machines mining on the Bitcoin network, the overall network hashrate increases. With a higher network hashrate, Bitcoin blocks are mined more quickly, eventually leading to a Bitcoin Difficulty increase.
The opposite is also true. If the Bitcoin price has a sudden drop, mining revenue decreases, and some miners will be forced to turn off their machines when the mining rewards cannot make up for the ongoing electricity costs to run the machines. The network hashrate starts to drop, and eventually, the Bitcoin Difficulty will adjust downward.
Calculating the current Bitcoin Difficulty
Monitoring the Bitcoin Difficulty and Bitcoin Hashrate is a quick method to gauge the Bitcoin network's current state. Higher values indicate the network security is strong, and there is a considerable demand to spend capital on building mining facilities, purchasing mining hardware, and paying for electricity bills.
There are plenty of resources out there that help find the current Difficulty level in the Bitcoin network. Two of the most popular are Bitcoin Difficulty Estimator and BitInfoCharts. These tools offer interesting tools to view all-time historical Difficulty values and estimate the next difficulty adjustment.
Those that run a Bitcoin node may be interested in viewing the Bitcoin difficulty on their own. If you have installed Bitcoin Core already, you can follow this guide to interact with the Bitcoin Core RPC console.
It's relatively straightforward to get the Bitcoin Difficulty, enter bitcoin-cli getdifficulty on Bitcoin Core to get the Difficulty value right away.