The economics of proof of work
Suggest an editThe 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.
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.
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.
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.