How bitcoin mining works: proof of work, difficulty and costs
What miners actually do, how the difficulty adjustment keeps blocks near ten minutes, where miner revenue comes from, and a worked electricity cost example.
Bitcoin has no central server that decides which transactions are valid and in what order. That job is done by miners, who compete to add the next block to the chain. The competition is called proof of work: the right to add a block is won by spending real computing effort, and anyone can check cheaply that the effort was spent. That cost is what makes rewriting Bitcoin's history impractical.
What a miner does
A miner collects unconfirmed transactions from the network's waiting area, the mempool, and assembles a candidate block. The block's header contains, among other things:
- A reference to the previous block's hash, which chains the blocks together
- A summary (Merkle root) of all the transactions in the block, including the miner's own reward transaction
- A timestamp
- The current difficulty target
- A number called the nonce
The miner then repeatedly hashes the header with the SHA-256 function, applied twice, changing the nonce and other fields each time. A hash is a fixed-length output that looks random; even a tiny change to the input gives a completely different result. The goal is to find a header whose hash, read as a number, is below the target. There is no shortcut: the only way is to try enormous numbers of variations.
When a miner finds a valid hash, it broadcasts the block. Other nodes verify it in a fraction of a second: one hash to check the work, plus checks that every transaction is valid and the reward follows the rules. If everything is correct, they add it to their copy of the chain and start working on the next block.
Why it is secure
To change a transaction in an old block, an attacker would have to redo the work for that block and every block after it, and then catch up with and overtake the honest chain, which keeps growing. Nodes follow the valid chain with the most accumulated work. Without control of a majority of the network's hashing power, this is effectively impossible, and the further back the block, the harder it gets. That is why recipients wait for several confirmations before treating large payments as final.
The difficulty adjustment
The more machines join, the faster blocks would be found. Bitcoin prevents that with a built-in rule: every 2,016 blocks, each node compares how long those blocks actually took with the intended two weeks (2,016 × 10 minutes) and adjusts the target.
Worked example. If the last 2,016 blocks took 12 days instead of 14, blocks came 14 ÷ 12 ≈ 1.17 times too fast. Difficulty rises by about 17%, so the next period should average ten minutes again. If they took 16 days, difficulty falls by about 12.5%. A single adjustment is limited to a factor of four in either direction.
This adjustment is why block times stay close to ten minutes on average whether the network has a few computers or millions of specialised machines, and why miners leaving after a halving or a price drop does not stop the network.
Hash rate
Hash rate is the number of hashes per second the network performs. Nobody measures it directly; it is estimated from the difficulty and how fast blocks arrive. Today's network is measured in exahashes per second (10^18 hashes per second), produced almost entirely by ASICs, chips designed only for Bitcoin's hashing. Ordinary computers and graphics cards have been uncompetitive for Bitcoin mining for many years.
Because any one miner's chance of finding the next block is tiny, most miners join pools that combine their hash rate and share rewards in proportion to the work each contributes. Pools coordinate which block template to work on, which is why pool concentration is watched as a decentralisation concern.
Where miner revenue comes from
Each block pays its miner:
- The block subsidy: newly created bitcoin, currently 3.125 BTC per block since the April 2024 halving, halving again every 210,000 blocks.
- Transaction fees: the total fees of the transactions in the block.
The miner claims both in the first transaction of the block, the coinbase transaction. These coins cannot be spent until 100 more blocks have been added, which protects against rewards from blocks that are later abandoned.
A worked example: electricity cost
Electricity is usually a miner's largest running cost. Our mining cost calculator uses these default inputs: a machine drawing 3,500 watts, running for 30 days, at $0.10 per kWh.
- Energy used = 3,500 W × 24 hours × 30 days = 2,520,000 Wh = 2,520 kWh.
- Electricity cost = 2,520 × $0.10 = $252 for the month.
At $0.05 per kWh, the same machine costs $126 a month; at $0.20, $504. That spread is why large mining operations seek out the cheapest power they can find, including stranded or surplus energy, and why a machine profitable in one country can lose money in another.
Whether the machine is profitable depends on what it earns, which depends on its share of the network's hash rate, the bitcoin price and fees. All three change constantly, and difficulty adjusts upward as more machines join. Hardware cost, cooling, maintenance and hosting come on top of electricity.
Mining and the halving
Every 210,000 blocks the subsidy halves, and miners' income in bitcoin from new issuance halves with it, while their costs do not. Older, less efficient machines become unprofitable first. The halving guide explains the schedule and its effects, and the halving table lists each step.
Energy use and the debate around it
Bitcoin mining uses a lot of electricity, comparable to that of a mid-sized country according to several academic estimates. Supporters point to the use of surplus or otherwise wasted energy, flexible demand that can switch off when grids are stressed, and the security the spending buys. Critics point to emissions, local grid strain and noise. Estimates vary widely because nobody has a complete list of mining sites and machines. When reading numbers in this debate, check the method behind them.
Reading mining statistics
Explorers and data sites show hash rate, difficulty and the next adjustment estimate. Remember that hash rate is estimated from block times, so daily figures are noisy; a seven-day average is more meaningful.
Frequently asked questions
Can I mine bitcoin on my laptop?
Technically yes, practically no. Your chance of finding a block would be effectively zero, and joining a pool would earn less than the electricity cost. Bitcoin mining is now done with specialised ASIC machines.
What happens when all bitcoin has been mined?
Around 2140 the subsidy reaches zero. Miners will then be paid only through transaction fees, and the same proof-of-work rules will continue to secure the chain.
Is the ten-minute block time guaranteed?
No, it is an average. Individual blocks can come seconds or more than an hour apart, because finding a valid hash is a random process. The difficulty adjustment keeps the long-run average close to ten minutes.
What is a 51% attack?
If one party controlled a majority of the network's hash rate, it could create a longer chain that excludes or reverses its own recent transactions. It could not steal coins from other people's addresses or create coins beyond the rules. On a network as large as Bitcoin's, the cost of such an attack is very high.
Do other cryptocurrencies use mining?
Some do, with different hash functions, such as Litecoin and Dogecoin. Ethereum stopped mining in 2022 when it moved to proof of stake.
Related on this site
Sources
- Satoshi Nakamoto, Bitcoin: A Peer-to-Peer Electronic Cash System
- Bitcoin developer documentation, Block chain guide (proof of work)
- Bitcoin Core source code, difficulty adjustment (pow.cpp)
- Bitcoin Core source code, block subsidy (validation.cpp)
- US Energy Information Administration, Electric Power Monthly
This guide explains how things work. It is general information, not financial, tax or legal advice, and it does not recommend any investment. Rules, rates and figures change; check the source before you act. Found an error? See the corrections policy.