Sign in

The economics of proof of work

Suggest an edit

The previous lesson explained what miners do. This one explains why they do it, and what their work gets the rest of the network.

Mining is a market

A miner is in the business of turning electricity into bitcoin. There are two costs: the upfront cost of buying specialized hardware called ASICs (small machines built to do one thing, compute SHA-256 hashes as fast as possible) and the ongoing cost of the electricity to run them. The reward, when a miner wins a block, is the block subsidy plus the fees from every transaction in that block. A miner who does not win the block gets nothing for the work spent on it.

Mining is competitive in two ways.

First, every miner is fighting every other miner for the same fixed prize. The network produces one block every ten minutes, no matter how many people are mining. If you control 1% of the global hashing power, you'll win about 1% of the blocks over time. Doubling your hashing power doubles your expected revenue, but it creates no new reward. You're taking a bigger share of the same fixed prize, leaving less for everyone else.

Second, electricity is the biggest cost, and electricity prices vary a lot. A miner running in a region with cheap hydroelectric power pays a fraction of what a miner running on retail grid power pays. So the miners who survive long-term are the ones with cheap electricity. Everyone else gets squeezed out when the bitcoin price dips.

Over time, this competition produces a predictable pattern. When the bitcoin price goes up or transaction fees rise, mining becomes more profitable, and more miners turn on their machines. The network's total hashing power, called hashrate, grows. The difficulty adjustment from the previous lesson happens every two weeks and tightens the puzzle so blocks still take ten minutes. When the price falls or fees shrink, less-efficient miners switch off, hashrate falls, and the difficulty loosens again.

At every point in time, there is a miner just barely breaking even, one who would shut down tomorrow if their electricity bill went up by 5%. So the total amount of electricity being spent on mining is always close to the total reward being paid out, because anyone whose costs were much lower than their reward would attract competitors until prices equalised again.

So the block reward is also the sum the network pays for protecting each block. At 3.125 BTC per block and six blocks an hour, that is about 19 BTC an hour plus fees. The subsidy halves every four years, so over time fees have to cover a growing part of this sum.

Mining as a market: a miner's costs and revenue, and network hashrate vs difficultyFor one miner, hardware and electricity costs feed a mining loop that pays out block subsidy plus fees. Across all miners, total hashrate expands and contracts with miner economics, and difficulty retargets every 2,016 blocks to hold about a 10 minute block time. Mining as a market For one miner: Costs (in) hardware + electricity A miner runs the mining loop Revenue (out) block subsidy + fees Across all miners on the network: Total hashrate expands and contracts with miner economics retargets Difficulty tunes every 2,016 blocks to hold ~10 min Cheap electricity wins. Total mining spending tracks total mining reward over time.

Where Bitcoin's security comes from

Why is a transaction that's been confirmed in a Bitcoin block hard to reverse?

When a transaction is included in block N, its security against being reversed depends on how many blocks have been built on top of it. Each of those later blocks required a successful proof-of-work search, which required on average the entire network's effort for ten minutes. To erase the transaction in N, an attacker has to publish an alternative chain that starts from block N's predecessor, doesn't include the transaction, and ends up longer than the chain everyone else is following.

This means two things have to happen at once. The attacker has to redo all the proof-of-work from the fork point forward. And while they're doing that, the honest network is still extending the current chain. So the attacker has to outpace the honest network's ongoing work while also catching up to it.

Honest chain N to N+k versus attacker's alternative chain racing to catch upThe diagram shows the honest chain growing block by block from N through N+1, N+2, N+3, up to N+k. Below it, an attacker's alternative chain from N' onward must reach N+k+1' before the honest chain reaches N+k+1, since each extra block adds another full network's worth of work to redo, so cost grows linearly with depth while the attacker's chance of success drops exponentially. Why deeper blocks are harder to reverse The honest chain: N N+1 N+2 N+3 ... N+k An attacker's alternative chain (must outpace the honest one): N' N+1' N+2' ...must reach N+k+1' before the honest chain reaches N+k+1 Each block deeper means another full network's worth of work to redo, on top of the work still being added to the honest chain. Cost grows linearly with depth, and probability of success drops exponentially as the attacker falls behind.

Concretely: to credibly reverse a transaction that's six blocks deep, an attacker would have to redo about an hour of the entire global network's effort, while matching the rest of the network's pace going forward. That takes more hashing power than all honest miners have together. Honest miners spend on electricity and hardware about what they earn in that hour, 19 BTC plus fees, so running the attack for the hour costs at least as much. A double-spend larger than that would repay the running cost, but the attacker first has to own the hardware. At Bitcoin's current scale that is a fleet of ASICs comparable to the entire honest network. The hardware alone costs in the billions of dollars, and much of it is already concentrated in the hands of large public mining companies.

Each extra block on top of the transaction adds another ten minutes of the whole network's work to redo, so the cost grows with depth. For an attacker with less than half of the hashrate, the chance of ever catching up also drops with every block, as the forks lesson showed.

This is what people mean when they say "Bitcoin is secured by energy." The security comes from cost rather than from cryptography being unbreakable. The cost of rewriting history is enormous, and that cost is paid in real-world resources an attacker would have to go out and buy. Forging the chain remains theoretically possible but practically unprofitable, and Bitcoin's whole security model rests on that.

What a 51% attack can and cannot do

The textbook attack on a proof-of-work chain is the 51% attack. The name comes from the idea that an attacker who controls more than half of the network's hashrate can, in expectation, produce blocks faster than the rest of the network, and therefore can win every fork-choice contest.

What this enables is narrower than the name suggests.

Two-column list of what a 51% attacker can and cannot doThe left column lists three things a 51% attacker can do: double-spend their own recent coins, censor transactions, and reorganise the recent chain. The right column lists four things it cannot do: steal coins from other addresses, create new BTC, cheaply rewrite ancient history, or change the protocol rules, each with a short reason. What a 51% attacker can and cannot do Can do Double-spend their own coins in recent transactions, by reorganising the chain to exclude them Censor transactions by refusing to include them in blocks the attacker mines Reorganise the recent chain replace the last few blocks with a longer alternative they built All of the above degrades quickly as the target transactions get older. Cannot do Steal coins from arbitrary addresses that would require forging signatures, which is a separate cryptographic problem Create BTC out of thin air the coinbase subsidy is fixed by protocol and rejected by every honest node Rewrite ancient history cheaply cost grows linearly with chain depth redoing years of work is prohibitive Change the protocol rules block size, halving, etc. enforced by nodes

An attacker who succeeds at a 51% attack can double-spend: deposit BTC at an exchange, wait for the deposit to be credited, withdraw that value, then rewrite history so the deposit transaction never happened. This is the most lucrative thing a 51% attacker can do, and it has happened on smaller proof-of-work chains where the cost of acquiring majority hashrate is low. It has not happened against Bitcoin itself, because acquiring majority Bitcoin hashrate would cost, depending on the moment, several billion dollars of hardware. Buying that much hardware would immediately drive prices up and signal to the entire industry that something was happening.

A 51% attack does not let the attacker steal coins from addresses they don't control, because moving coins requires a valid signature from the coin's owner. A 51% attack also doesn't change the protocol's economic rules. If the attacker mines a block with a coinbase reward of 100 BTC instead of the current 3.125, every other node on the network rejects that block as invalid. Hashrate doesn't override protocol rules. It decides which valid blocks make it into the canonical chain.

The attack would also destroy what the attacker paid for. An attacker who acquires majority Bitcoin hashrate has invested billions in specialized hardware whose value depends entirely on Bitcoin's continued credibility. Successfully attacking Bitcoin would crash its price, devaluing the attacker's own hardware below scrap value. The attacker would have spent more on the attack than they could plausibly extract from it. For the same reason the largest miners are typically the most invested in Bitcoin's health: they are the ones with the most to lose if the system fails.

The energy spent is what makes an attack unprofitable

The consensus lesson said that participation has to cost something real. In proof of work the cost is electricity and the vote is hashrate, so the energy use is the security mechanism, and a chain that spent less on mining would be cheaper to rewrite. The price is that the bill is paid for every block, whether anyone attacks or not. The lesson on what Bitcoin gave up comes back to this price.

You can check any proof-of-work chain this way. Estimate what it costs to hold a majority of its hashrate for as long as it takes to rewrite a payment, and compare that with the size of the payment. If the payment is bigger, wait for more blocks on top of it before treating it as final, because every extra block adds to what the attacker has to redo.