ExploreRabbit Hole · How It Works · 13 min
Mining
Hash, nonce, target. The simplest hard problem in the world, and why it secures more than a trillion dollars.
Where you're going: Mining is often described as "Bitcoin's energy problem" or "Bitcoin's lottery." Both are misleading. You'll learn what mining actually is (a cryptographic race with a clock), why it secures the network, and what the long-term economics look like as the subsidy approaches zero.
1. The Lottery No One Cheats At
A Bitcoin block contains transactions and a header. The header includes a 32-bit number called the nonce.
To "mine" a block, a computer assembles a candidate header, then tries values of the nonce, one after another, looking for a header whose SHA-256 hash starts with enough zero bits to be below the current target.
There is no shortcut. There is no algebra that gets you the right nonce. You guess, you hash, you check, you increment, you hash again. A modern mining machine, packed with many ASIC chips, does this hundreds of trillions of times per second.
When a miner finds a valid nonce, they broadcast the block. Every other node verifies in milliseconds (hashing the header once is cheap; finding the nonce in the first place is the work). The block is added to the chain. Everyone moves on to mining the next one.
This is the entire mining loop. Everything else is engineering and accounting.
2. SHA-256, in One Page
Mining depends on a cryptographic property of the SHA-256 hash function: for any given output, there is no known way to find an input that produces it except by trying inputs.
This is called preimage resistance, and it's the foundation of every proof-of-work system.
A few facts about SHA-256:
- Input: any binary data
- Output: exactly 256 bits (a 64-character hex string)
- Deterministic: same input always produces same output
- One-way: computationally infeasible to reverse (see the Key Space rabbit hole on why 2^256 is unbreachable)
- Avalanche effect: changing one bit of input changes ~half the bits of output, unpredictably
To "mine," you compute SHA-256(SHA-256(header)) and check whether the resulting 256-bit number is below the current target. The target is what gets adjusted to control how often blocks come out.
That's it. The entire security model rests on this one function and its one property.
3. The Race
Mining is competitive. Thousands of mining operations worldwide are all trying to find a valid nonce for the same height block at the same time. Whoever finds one first gets the reward.
A few practical consequences:
You can't "cheat" by working from someone else's progress. Each miner picks slightly different transactions for their candidate block (and thus different merkle roots), so their candidate headers are different. Finding a nonce for your candidate doesn't help anyone else.
You can't predict who will win. Hashing is uniformly random in expectation. A miner with 1% of global hash rate finds, on average, 1% of blocks. But which specific block, and when, is genuinely random.
The clock is hash rate, not wall time. Bitcoin doesn't care what time it is; it cares how much computation has happened. Blocks appear "every 10 minutes on average," but only because difficulty adjusts to make that average hold.
The combination of cryptographic randomness, global competition, and difficulty adjustment gives Bitcoin its most important property: finality through computational expense. Once a block is buried under a few more, undoing it would require re-doing all the work, faster than the rest of the world is doing the new work.
4. Difficulty (and How It Adjusts)
Bitcoin's target block time is 10 minutes. But hash rate goes up and down all the time. So Bitcoin uses an automatic, deterministic mechanism to keep blocks coming on schedule: difficulty adjustment.
The rule:
- Every 2016 blocks (about every two weeks), the network looks at how long the last 2016 blocks took.
- If they took less than two weeks, difficulty goes up (making future blocks harder).
- If they took more than two weeks, difficulty goes down (making future blocks easier).
- The adjustment is precisely proportional, capped at a factor of four either way: at most 4x up (+300%) or down to a quarter (-75%) in one step.
This is the most consequential single piece of mechanism design in Bitcoin. There is no committee. There is no Federal Reserve raising rates. The network observes its own conditions and corrects, on a fixed schedule, forever. The timing it observes comes from timestamps that miners write themselves; The Time Warp shows how a miner with most of the hash rate could exploit that, and why nobody has.
Difficulty has gone up roughly 10^14 times since the genesis block - mining is now astronomically harder than it was in 2009, by design, because hash power has scaled up by that much.
Difficulty epoch
Connecting to node…Estimate assumes the rest of the epoch matches the current pace. Positive % means blocks have been faster than 10 minutes; difficulty will go up to slow them down.
5. What Miners Are Paid
A miner who finds a valid block gets paid in two parts:
- Block subsidy - the freshly-issued bitcoin per the supply schedule. 3.125 BTC as of October 2026. Halves every 210,000 blocks (see the Halvings rabbit hole).
- Transaction fees - the sum of fees from every transaction included in the block. Variable; depends on mempool conditions.
The miner constructs the "coinbase transaction" - a special transaction that pays themselves both amounts. This is the only place new bitcoin enters circulation.
The economic logic is plain: producing valid blocks earns the reward; producing invalid blocks (wrong PoW, invalid transactions, exceeding the block weight limit) gets rejected and wastes the electricity. This is what cryptographers call incentive compatibility - the property that makes rule-following more profitable than rule-breaking for rational, self-interested participants. Bitcoin's security depends on it, and the evidence since 2009 says it holds.
In Bitcoin's early years, subsidy was essentially all of the revenue (transactions were free). In the year to October 2026, fees were about 0.6% of miner revenue, with occasional spikes much higher during congestion events. By 2140, when the subsidy reaches zero, fees will be 100% of miner revenue.
The transition from subsidy-dominated to fee-dominated revenue is one of the central long-term economic questions in Bitcoin. We covered it briefly in the Halvings rabbit hole; the short version is that nobody knows yet whether fees alone will pay for enough security. The energy chapter calls it a real open question, and so do we.
6. The Mempool, From the Miner's Side
Miners don't just include transactions randomly. They pick the ones that maximize their fee revenue per block.
The process:
- Take the mempool (the pool of unconfirmed transactions).
- Sort by fee rate (sat/vB, not total fee - block space is the scarce resource).
- Greedily pack transactions starting from the highest fee rate, until the block is full (~4 million weight units).
- Add the coinbase transaction.
- Compute the merkle root, hash the header with various nonces, find one below target.
- Broadcast.
This is why your transaction's fee rate matters more than its amount. A transaction with 1 BTC and a 1 sat/vB fee sits at the bottom of the mempool. A transaction with 0.001 BTC and a 100 sat/vB fee gets mined immediately.
Live mempool
Connecting to node…Miners pack the highest-fee-rate transactions first. The bands above are unconfirmed transactions in your node's mempool right now, grouped by fee rate.
7. Energy as Security Budget
Bitcoin mining uses electricity. A lot of it. Mining draws about 140 to 160 TWh a year depending on Cambridge's method (as of October 2026), roughly half of one percent of the world's electricity, and the figure moves with price and hash rate. The energy chapter has the full numbers.
This is often presented as a problem. It is, more accurately, a feature. Here's why:
The energy is what makes the security real. To attack Bitcoin's consensus, an attacker would need to outpace the global mining network. That means matching its hash rate - which means matching its hardware investment and electricity consumption. The energy isn't waste; it's the cost of forging the security.
The alternative isn't "no energy used." The alternative is "less security." Proof-of-stake systems use less energy but achieve security through different means (capital deposits, slashing). Those mechanisms have their own trade-offs, and you can have legitimate debates about which is better, but "uses less energy" alone isn't an argument that something is more secure.
Mining incentivizes finding cheapest energy. Miners aren't bidding on premium power. They're bidding on whatever is cheapest globally - stranded renewables, flared natural gas that would otherwise be wasted, geothermal in Iceland, hydro in Sichuan during the wet season. The marginal Bitcoin mining operation runs on energy that has no other buyer.
Mining can be switched off in seconds and back on in under a minute. That makes it unusually well suited to the role of flexible load, or "buyer of last resort," for a grid. When demand spikes (heat wave, sudden outage), a miner can drop its load in seconds; when there is surplus (a sunny, windy afternoon with little industrial demand), it can soak it up. NERC, which writes the reliability standards for the North American grid, recorded one mining facility shedding 298 megawatts in 25 seconds on instruction. It also notes the catch: a grid can only count on that flexibility from loads that have signed up for a curtailment or demand-response program. Texas's grid operator, ERCOT, runs such programs, names bitcoin mining facilities as the kind of customer they are for, and its demand-response programs pay enrolled loads to cut back when the grid is tight. Riot reported $31.7 million in power and demand-response credits in August 2023, most of it from selling its contracted power back to the grid while it stood down. Whether that is a public service or a subsidy is argued out in the energy chapter.
None of this means Bitcoin's energy use is irrelevant. It means it's not the simple "waste" story the headlines use.
8. Mining Pools, ASICs, and Centralization Risks
A few realities of the mining industry:
ASICs dominate. Application-Specific Integrated Circuits designed to do SHA-256 and nothing else. They are vastly more efficient than CPUs or GPUs and have been the only economically viable mining hardware since around 2014. There are a small number of ASIC manufacturers; this is a centralization vector worth watching.
Mining pools dominate. Most miners don't solo-mine; they join a pool that aggregates hash rate, smooths out variance, and pays members proportionally. A small number of pools control most of the network's hash rate. In the year to October 9, 2026, Foundry USA, AntPool, F2Pool and ViaBTC together mined more than two-thirds of all blocks. This is a structural concern.
But pools aren't miners. The hash rate in a pool comes from individual miners, who can switch pools at will if one starts misbehaving. The "Stratum V2" protocol enables miners (not pools) to choose which transactions go into blocks, even if the pool is coordinating the hashing. This shifts power back to individual miners over time.
Geography has shifted. China dominated mining until 2021, when a government crackdown pushed operations to the US, Kazakhstan, and elsewhere. In Cambridge's April 2025 survey of 49 mining firms, the US accounted for about 75% of reported mining activity.
Solo mining is alive. Several individuals have found blocks solo-mining on lottery hardware in the past few years. The odds are astronomically low, but not zero.
The state of mining centralization is a real conversation in the Bitcoin community. None of the failure modes here are immediate; all of them are worth attention.
For the broader picture of how Bitcoin's decentralization actually holds up - mining concentration, client diversity, the 2017 governance stress test - see the Decentralization rabbit hole.
9. The Long-Term Picture
Mining's role in Bitcoin's economic model evolves over time. Three phases:
Subsidy era (2009-2030s): Most miner revenue comes from the block subsidy. Fee revenue exists but is secondary. As of October 2026, Bitcoin is still in this era.
Transition era (2030s-2100s): As halvings continue, the subsidy shrinks. The hope is that fee revenue grows to take its place as more people use Bitcoin and layer-2 systems keep block space in demand. Whether that happens is the open question below.
Fee-only era (~2140+): The last satoshi has been issued. Miners earn revenue exclusively from fees. The network's security is funded entirely by the demand to transact.
The transition between these phases is the central long-term question in Bitcoin's design, and it is still open. Fees were about 0.6% of miner revenue in the year to October 2026, so the subsidy is doing nearly all the work for now.
10. What This Buys Us
A Bitcoin block, with its 80-byte header and the right nonce, is the proof that someone spent enormous computational effort to produce it. Stack hundreds of thousands of those together, and you have a chain whose history cannot be plausibly rewritten by anyone, including all the miners on Earth combined.
That's what mining is for. It's not a coincidence; it's not a side effect; it's the core mechanism that makes the entire system trustless.
The energy spent isn't paying for transactions to confirm. It's paying for the immutability of the entire chain, retroactively, every ten minutes, forever.
Pro tip: When someone tells you "Bitcoin mining is wasteful," ask them what they think it's producing. The answer is: a globally-shared, censorship-resistant, irreversible record of every transaction, secured against attackers wealthy enough to outspend nation-states. That's not nothing.
More in How It Works
On the mailing list
The topic timeline: Mining and pools (224 threads).
Corrected
-
Was: The chapter said mining is "uniquely well-suited" as a buyer of last resort, stated as fact that miners switching on and off "stabilizes grids and improves renewables economics", and said Riot earned $31.7 million in August 2023 by switching off for ERCOT, when most of that money came from reselling its contracted power.
Now: Mining can be switched off in seconds and back on in under a minute, which NERC's 2025 review of large loads documents with one facility shedding 298 megawatts in 25 seconds, and a grid can only count on that from miners enrolled in a curtailment or demand-response program. Riot's $31.7 million in August 2023 was $24.2 million from selling its contracted power back to the grid and $7.4 million in demand-response credits; whether such payments are a public service or a subsidy is left to the energy chapter. Details
-
Was: The chapter said, as plain fact, that fee revenue will grow to take the subsidy's place in the 2030s and beyond, and that the US is the largest mining country, without a source or date.
Now: It calls fees replacing the subsidy a hope and an open question. The US accounted for about 75% of the mining activity reported in Cambridge's April 2025 survey of 49 firms. Details
-
Was: The chapter put mining at about 173 TWh a year, roughly three quarters of one percent of global electricity, cited "two decades of empirical evidence" for a system launched in 2009, and said geographic dispersion had roughly doubled, without a source.
Now: By Cambridge's methods mining draws about 140 to 175 TWh a year, half to two-thirds of one percent of the world's electricity, a range that was itself updated on 10 October 2026 to about 140 to 160 TWh, roughly half of one percent. The evidence is dated from 2009, and the unsourced dispersion claim was removed. Details
-
Was: The chapter said that as long as Bitcoin is used, fees "will be sufficient" to pay for its security, and that fees were "growing faster than the network needs them to".
Now: Fees were about 0.6% of miner revenue in the year to October 2026. The chapter says nobody knows yet whether fees alone will pay for enough security, which matches the energy chapter. Details
-
Was: The chapter said each difficulty adjustment is clamped at +/-300% and that difficulty had grown about 10^13 times since 2009. It also put fees at 3 to 10% of miner revenue and mining at 0.5% of global electricity.
Now: Bitcoin Core caps each adjustment at a factor of four, so at most +300% up or -75% down, and difficulty has grown about 10^14 times. Fees were about 0.6% of miner revenue in the year to October 2026, and the energy share was changed to about 0.75%, a figure that was itself corrected on 5 October 2026. Details
Sources
- Bitmain support - S21 Pro specification (234 TH/s typical, 3,510 W, 15 J/TH)
- SHA-256 spec (NIST FIPS 180-4)
- Bitcoin Core - GetNextWorkRequired (difficulty calc)
- Cambridge Bitcoin Electricity Consumption Index
- Cambridge CBECI data feed - annualised estimate at the index's default 5 cents per kWh (read 10 October 2026: 162.04 TWh)
- Ember - Global Electricity Review 2026 (world electricity demand 31,779 TWh in 2025; April 2026)
- Cambridge Judge Business School - Cambridge study: sustainable energy rising in Bitcoin mining (April 2025; 138 TWh, about 0.5% of global electricity; US 75.4% of reported mining activity among 49 surveyed firms)
- mempool.space - block fees vs subsidy chart (fee share of miner revenue)
- mempool.space API - mining pool shares over the last year (live; on 9 October 2026: Foundry USA 28.2%, AntPool 18.1%, F2Pool 12.5%, ViaBTC 9.7% of 52,331 blocks)
- Riot Platforms August 2023 production report (SEC filing - the $31.7M month: $24.2 million from selling power back to ERCOT under its long-term power contracts and $7.4 million in demand response credits; power use curtailed by more than 95% during peak demand)
- Riot Platforms - Form 10-K for 2023 (bitcoin mining presents a stable demand for energy and can be quickly curtailed; Riot takes part in ERCOT demand response programs that pay it to power down and offset foregone mining revenue)
- NERC Large Loads Task Force - Characteristics and Risks of Emerging Large Loads, white paper (July 2025; cryptocurrency mining and AI facilities can cycle their consumption on and off in less than a minute; one North American mining facility ramped down 298 MW within 25 seconds on instruction; such loads are not controllable by the grid operator unless they volunteer for a curtailment or demand-response program)
- ERCOT - news release: ERCOT Creates Voluntary Curtailment Program for Large Flexible Customers During Peak Demand (December 6, 2022; names bitcoin mining facilities among large flexible customers that can reduce their energy use quickly)
- Mining glossary entry
Published . Revised . Five corrections logged for this page.
Edit this page on GitHub