Academy School · Chapter 3 of 14
Bitcoin Consensus & Mining
How Bitcoin secures transactions and why proof of work matters.
Chapter locked
Complete the previous chapter first.
Academy School builds each concept on the one before it. Return to the course overview to continue from your current chapter.
Return to Academy SchoolProof of Work Basics
Proof of work secures Bitcoin by requiring real computational cost to produce each block. A miner gathers waiting transactions into a candidate block and builds an 80-byte block header. The header holds the hash of the previous block, a fingerprint (the Merkle root) of every transaction in the block, a timestamp, the current target and a 32-bit number called the nonce. The miner runs the header through SHA-256 twice. If the result, read as a number, is below the target, the block is valid. If not, the miner changes the nonce and tries again.
There is no shortcut. The only way to find a valid hash is to guess, and checking a winning guess takes any node a single hash. That asymmetry is the point: expensive to produce, cheap to verify. The nonce allows about 4.3 billion guesses, which a machine doing 100 terahashes per second (100 trillion hashes a second) exhausts in roughly 43 microseconds, so miners also vary the timestamp and a field inside the block's first transaction to get fresh headers.
Because every header commits to the previous block's hash, changing one old transaction changes that block's hash and breaks the link to every block after it. To rewrite history, an attacker must redo the work for that block and all its successors, then overtake the honest network, which keeps adding blocks meanwhile. The cost of attack is therefore the cost of acquiring more hashing power than everyone else.
Smaller proof of work networks show what happens when that cost is low. In May 2018 an attacker gained majority hashpower on Bitcoin Gold, a separate coin with its own mining algorithm, and reversed deposits worth about $18 million at exchanges. The proof of work versus proof of stake entry compares this cost model with staking.
A block is valid only if its header hash is below the target. Rewriting a block means redoing its work and the work of every later block, faster than the honest network extends the chain.
Difficulty and Hashrate
Hashrate is the total number of guesses the network makes per second, usually quoted in exahashes per second (one exahash is a billion billion hashes). Difficulty is how hard the target is to hit. No node measures hashrate directly; it is estimated from how quickly blocks arrive at a known difficulty, which is why published hashrate charts are noisy.
The difficulty adjustment keeps block timing roughly stable at an average of 10 minutes. Every 2,016 blocks, each node compares how long those blocks actually took with the intended 20,160 minutes (14 days) and scales the target in proportion. The change is capped at a factor of four in either direction per period. Nothing is voted on: every node runs the same calculation on the same timestamps and reaches the same answer.
Worked example: a 10 percent hashrate drop
- Suppose 10 percent of miners switch off just after an adjustment. The remaining 90 percent need 10 ÷ 0.9 = 11.1 minutes per block on average.
- The 2,016 blocks of that period now take about 14 ÷ 0.9 = 15.6 days instead of 14.
- At the next adjustment the new difficulty is the old one multiplied by 14 ÷ 15.6, which is 0.9, a 10 percent cut.
- With the remaining hashrate and the easier target, blocks return to about 10 minutes.
The lag is the cost: for up to two weeks, confirmations arrive more slowly. The largest real cut came on 3 July 2021 at block 689,472, when difficulty fell 27.94 percent after China's crackdown on mining took a large share of hashrate offline. Blocks slowed, the adjustment followed, and the chain carried on without any coordination.
Difficulty targets time, not security. Blocks average about 10 minutes at any hashrate, so judge security by hashrate (the cost of competing), not by how often blocks appear.
Transactions, Blocks, and Finality
Your wallet signs a transaction that spends earlier outputs (see UTXO accounting) and broadcasts it. Each node checks the signatures and that the coins are unspent, then holds it in its mempool, the waiting area for unconfirmed transactions. Miners usually pick transactions by fee rate, measured in satoshis per virtual byte. Once a block includes yours, it has one confirmation; every block built on top adds another.
Bitcoin finality is probabilistic rather than instant. Confirmations matter because each one improves confidence that the transaction is permanent, but the risk never reaches zero. Section 11 of the Bitcoin whitepaper calculates the chance that an attacker with a share of total hashrate ever catches up from a given number of blocks behind:
| Confirmations | Attacker with 10% of hashrate | Attacker with 30% of hashrate |
|---|---|---|
| 1 | 20.5% | 62.8% |
| 3 | 1.3% | 32.5% |
| 6 | 0.024% (about 1 in 4,100) | 13.2% |
Six confirmations, about an hour, is a widely used convention, not a protocol rule. The table shows why the right number depends on the amount at stake and on how much hashrate an attacker could plausibly rent. The protocol itself makes newly mined coins wait 100 blocks before they can be spent, because they vanish if their block is replaced.
Replacement has happened. In March 2013 a database limit in older Bitcoin software split the network into two chains. Mining pools downgraded so the older chain would win, and blocks on the abandoned branch, with their confirmations, disappeared; BIP 50 records at least one large double spend during the split. The transaction finality entry compares this with chains that finalise blocks outright.
Match confirmations to what is at stake. Under the whitepaper model, six confirmations leave a 10 percent attacker about a 1 in 4,100 chance, but a 30 percent attacker still about 13 percent.
Why Mining Economics Matter
Miners are paid by two things only: the block reward (the subsidy of newly created bitcoin) and the transaction fees of everything in the block. The miner claims both in the block's first transaction, called the coinbase. Since block 840,000 on 20 April 2024 the subsidy has been 3.125 BTC. It halves every 210,000 blocks, so it falls to 1.5625 BTC at block 1,050,000, expected around 2028. The halving cycle entry covers the full schedule.
Worked example: what the network pays for security
At about 144 blocks a day, the subsidy alone creates 144 × 3.125 = 450 BTC daily. A miner with 1 percent of total hashrate expects 1.44 blocks a day on average, about 4.5 BTC of subsidy plus fees. Luck makes actual results lumpy (some days nothing, some days three blocks), which is why most miners join pools that share rewards. Electricity is paid every hour whether a block is found or not.
Fees vary enormously. Block 840,000 itself paid about 37.6 BTC in fees, roughly 12 times its subsidy, because users rushed to be first in the halving block and the Runes token protocol launched at that height. Many ordinary blocks pay well under one BTC in fees.
Mining economics matter because the hashrate the network can attract is bounded by what miners earn. If the subsidy halves and fees and the bitcoin price do not rise to compensate, some machines stop being worth running, hashrate falls, and the cost of attack falls with it. That is why the long-run fee market is a real research question, not a detail. The mining economics guide shows how to build an operating estimate.
Miner revenue is subsidy plus fees, nothing else. The hashrate that revenue can pay for sets the cost of attacking the chain, so a smaller subsidy has to be offset by fees or price to keep security level.
Further reading
On Ledgers Academy
- Bitcoin mining, hashrate and consensus economics
- Bitcoin genesis block: where the chain of headers starts
- UTXO: how Bitcoin represents spendable outputs
- Bitcoin halving cycle: the subsidy schedule
Primary sources
- Bitcoin: A Peer-to-Peer Electronic Cash System (Satoshi Nakamoto, 2008), especially sections 4 and 11
- Bitcoin Core difficulty retarget code (pow.cpp)
- BIP 50: the March 2013 chain fork post-mortem