Foundations · Bitcoin Knowledge Center
Proof of Work & Mining
Mining is the process by which Bitcoin blocks are created. Miners compete to find a hash below a target, and that costly search is called proof of work.
Why it matters
Bitcoin has no administrator to decide which transactions are valid and in what order they happened. Something has to do that job. Mining is the mechanism that does it, and proof of work is what makes the result hard to fake.
Mining is also the source of two of the most debated facts about Bitcoin: its electricity use and the way new coins are issued. Both are easier to judge once the mechanism is clear.
How it works
- CollectPick valid transactions from the mempool.
- BuildAssemble a candidate block that points to the latest block.
- GuessChange a number in the header and hash it with SHA-256.
- CompareIs the hash below the target? Almost always no. Guess again.
- PublishA winning block is broadcast and every node checks it.
A hash function takes any data and returns a fixed-length fingerprint. Bitcoin uses one called SHA-256. Its output looks random: change one character of the input and the fingerprint changes completely, with no way to predict how. See blocks and hashes.
A miner builds a candidate block and hashes its header. The network accepts the block only if that hash, read as a number, is below a value called the target. Because the output is unpredictable, the only method is trial and error. The miner changes a field in the header called the nonce, hashes again and repeats, many times every second.
When one miner finds a valid hash, it broadcasts the block. Every node verifies it with a single hash calculation and a check of each transaction inside. The other miners then start again on top of the new block.
In plain words
Imagine a lottery where a ticket wins only if its number starts with twenty zeros. Nobody can calculate a winning ticket. You can only keep printing tickets until one happens to qualify. Anyone can confirm a winner at a glance. Mining is that lottery, run with electricity instead of paper.
The key parameters
The reward
The miner of a block may include one special transaction that pays itself. This payment has two parts:
- the block subsidy, newly created bitcoin, which began at 50 and is cut in half every 210,000 blocks (see the halving);
- the transaction fees attached to the transactions in the block (see fees and block space).
This is the only way new bitcoin come into existence.
The difficulty adjustment
If more computing power joins the network, blocks would be found faster. To prevent this, the software recalculates the target every 2,016 blocks so that the average interval returns to about ten minutes.
new difficulty = old difficulty x (20,160 minutes / minutes actually taken by the last 2,016 blocks)20,160 minutes is two weeks: 2,016 blocks at ten minutes each. A single adjustment is limited to a factor of four in either direction.A hypothetical difficulty adjustmentHypothetical illustration
Suppose the last 2,016 blocks arrived in 12 days instead of 14, because miners switched on new machines.
- Ratio: 14 / 12 = 1.167.
- The difficulty rises by about 16.7%, so the same hardware now needs about ten minutes per block again.
Now suppose a later period takes 16 days, because some miners switched off.
- Ratio: 14 / 16 = 0.875.
- The difficulty falls by 12.5%.
In both cases the schedule of new coins stays close to plan. Adding machines does not create bitcoin faster for long. It only raises the difficulty.
Ten minutes is an average. Individual blocks can arrive seconds apart or more than an hour apart, because each guess is independent.
Going deeper
Why the work provides security
Each block contains the hash of the block before it. To alter an old transaction, an attacker would have to redo the proof of work for that block and for every block after it, and then overtake the honest miners who keep extending the real chain. Nodes follow the valid chain with the most accumulated work.
An attacker with more than half of the network’s computing power could, in principle, rewrite recent blocks or refuse to include certain transactions. This is often called a 51% attack. Even then the attacker could not spend coins without the owner’s key or create coins beyond the schedule, because nodes reject blocks that break those rules.
Hardware and pools
Mining began on home computers. Today it is done with specialised chips built only for SHA-256, usually in large facilities where electricity is cheap. Because a single miner might wait years to find a block, most miners join pools that combine their effort and share rewards. A few large pools account for much of the network’s computing power, which is a recurring concern about centralisation.
Proof of work and proof of stake
PROOF OF WORK
Miners spend energy to earn the right to add a block.
- Security comes from computing power
- Attack cost: hardware and electricity
- Used by Bitcoin
PROOF OF STAKE
Validators lock up coins to earn the right to add a block.
- Security comes from capital at stake
- Attack cost: coins that can be slashed
- Used by Ethereum since 2022
Other networks use proof of stake, which replaces spent energy with locked-up capital. The comparison page on proof of work vs proof of stake sets out the differences.
What it does NOT mean
- Miners are not solving useful maths problems. They are making random guesses. The only output is evidence that work was done.
- Miners do not set the rules. A block that breaks the rules is rejected by nodes however much work went into it.
- More miners does not mean faster blocks. The difficulty adjustment brings the average back to about ten minutes.
- High computing power does not make Bitcoin “unhackable”. It makes rewriting confirmed history very expensive. It offers no protection for a stolen key, a careless user or a faulty exchange.
- Mining is not a dependable source of income. Revenue depends on hardware, electricity cost, difficulty and a volatile market price, and many mining operations have failed.
Common misunderstandings
- Picturing mining as digging up coins that already exist. Coins are created by the reward transaction when a block is accepted.
- Thinking energy use grows with the number of transactions. Energy depends on how much hardware competes, not on how full the blocks are.
- Confusing miners with nodes. Miners propose blocks. Nodes check them. Most nodes do not mine.
- Assuming a 51% attacker could do anything. The damage would be serious but limited to reordering or censoring recent transactions.
Limits and open questions
- Energy consumption. Proof of work uses a large amount of electricity by design. Estimates of the total vary, and so do views on the energy sources involved and on whether the use is worthwhile. This is a live debate, not a settled matter.
- Concentration. Hardware manufacturing, pools and cheap power are unevenly distributed.
- Declining subsidy. As the subsidy shrinks, miner revenue depends more on fees. Whether fees will sustain enough mining is unknown.
- Probabilistic finality. A confirmed transaction becomes harder to reverse with each block, but the protocol never declares it final.
Key takeaway
Mining orders transactions into blocks by making block creation costly and verification cheap. The difficulty adjustment keeps blocks about ten minutes apart, and the cost of redoing the work is what protects confirmed history.
Sources and further reading
- Bitcoin: A Peer-to-Peer Electronic Cash System (opens in a new tab), Satoshi Nakamoto (2008). Sections 4 to 6 and 11 cover proof of work, the network, incentives and attack probabilities
- Mastering Bitcoin, Andreas M. Antonopoulos. Chapter on mining and consensus
- Block Chain (Bitcoin Developer Reference) (opens in a new tab), Bitcoin Project. Block header fields: nBits encodes the target the header hash must not exceed, and the nonce is changed by miners
- Bitcoin Core source: pow.cpp (opens in a new tab), Bitcoin Core developers. Difficulty retarget code, including the limit on each adjustment step to a factor of four