No history yet

Mining Mechanics

The Great Hash Race

At the core of Bitcoin's security is a competition. Miners around the world race to be the first to validate a new block of transactions and add it to the blockchain. This process, known as Proof-of-Work, isn't about solving a complex math problem in the traditional sense. It's more like a brute-force guessing game on a colossal scale.

Lesson image

Miners take a collection of unconfirmed transactions, add a reference to the previous block's hash, and include a random number called a (number used once). They bundle all this data together and run it through a cryptographic hash function called . The goal is to find a nonce that produces a hash value starting with a specific number of leading zeros. Since the output of SHA-256 is unpredictable, the only way to find a suitable hash is to try different nonces over and over again, millions or even trillions of times per second.

To add a new block, miners must find a nonce that makes the block’s hash lower than the target difficulty.

The first miner to find a valid hash broadcasts their solution to the network. Other nodes quickly verify it, and if it's correct, the new block is added to the chain. The winning miner is rewarded with newly created bitcoin and all the transaction fees from the block.

Hitting a Moving Target

The requirement for a hash to start with a certain number of zeros is a simplified way of describing the 'target'. The network sets a specific numerical target. A block is considered valid only if its hash is numerically less than or equal to this target. A lower target means more leading zeros are required, making the puzzle harder to solve.

H("BlockData"+nonce)TargetH("Block Data" + \text{nonce}) \le \text{Target}

But what happens when more miners join the network, or when mining hardware becomes more powerful? With more computational power (hash rate) competing, blocks would be found much faster than the intended 10-minute average. This would cause the currency supply to inflate too quickly.

To prevent this, Bitcoin has a built-in mechanism called the Difficulty Adjustment Algorithm (DAA). Every 2,016 blocks, which is approximately every two weeks, the network automatically recalibrates the target based on the time it took to find the previous 2,016 blocks.

If blocks were found too fast (e.g., in 8 minutes on average), the difficulty increases (the target value gets smaller). If they were found too slowly (e.g., in 12 minutes), the difficulty decreases (the target value gets larger). This elegant solution ensures that no matter how much or how little hash rate is on the network, a new block is produced roughly every 10 minutes.

The Governor of the System

The discovery of a valid block is a random event. The probability of any given hash being successful is incredibly low, so mining is like buying lottery tickets. This randomness means that the time between blocks is not fixed at exactly 10 minutes. Instead, it follows what is known as a . Sometimes two blocks are found a minute apart; other times, it might take over an hour for the next block to appear. But over the long term, the average holds steady at 10 minutes.

The difficulty adjustment is arguably the most brilliant part of Bitcoin's design. It acts as the system's economic governor. By ensuring a predictable block issuance rate, it enforces a fixed, transparent, and unchangeable monetary policy. No matter how efficient mining technology becomes, it cannot accelerate the creation of new bitcoin. The total supply schedule is locked in, making the currency's inflation rate predictable and tapering over time.

Quiz Questions 1/5

What is the primary purpose of the Difficulty Adjustment Algorithm in Bitcoin?

Quiz Questions 2/5

In the context of Bitcoin mining, what is a "nonce"?

This combination of hashing, target difficulty, and automated adjustment creates a robust and secure decentralized system, all without a central authority.