Lesson 4: Mining & Proof-of-Work - The Engine of Bitcoin
โ๏ธ Intermediate โข โฑ๏ธ 90-120 min โข โ๏ธ 400 Quarks
The Most Misunderstood Part of Bitcoin
Everyone's heard of Bitcoin mining. But most people think it's about "creating new coins" or "solving complex math problems." Both are wrong.
Bitcoin mining is actually about security. Miners are the guardians of the network, using massive amounts of energy to make Bitcoin virtually impossible to attack. The new coins? That's just the incentive to keep them honest.
In this lesson, you'll learn:
- What Bitcoin mining actually does (it's not what you think)
- How Proof-of-Work creates security through energy
- Why mining difficulty adjusts every 2 weeks
- The halving cycle and Bitcoin's fixed supply
- Mining pools, ASICs, and the arms race
- Environmental concerns and the truth about Bitcoin's energy use
Ready to understand the engine that powers Bitcoin? Let's dig in! โ๏ธ
๐บ WATCH FIRST: How Bitcoin Mining Actually Works
๐บ 3Blue1Brown: But how does bitcoin actually work? (26 min - best explanation ever)
The Big Idea: Proof-of-Work
Bitcoin's security comes from Proof-of-Work (PoW)โa system where miners compete to solve a computational puzzle. The winner gets to add the next block and earn the reward.
What Problem Are Miners Solving?
Miners are trying to find a nonce (number used once) that, when combined with the block data and hashed, produces a hash with a certain number of leading zeros.
Example:
Block Data: "Block #820000, Previous Hash: 0000000000..., Transactions: [...]"
Nonce: 1234567890
Hash: 7a8f3e2d1c... โ (no leading zeros)
Nonce: 1234567891
Hash: 9f2e8d7c3a... โ (no leading zeros)
Nonce: 1234567892
Hash: 0000001a2b... โ (4 leading zeros! Valid!)
Block Data: "Block #820000, Previous Hash: 0000000000..., Transactions: [...]"
Nonce: 1234567890
Hash: 7a8f3e2d1c... โ (no leading zeros)
Nonce: 1234567891
Hash: 9f2e8d7c3a... โ (no leading zeros)
Nonce: 1234567892
Hash: 0000001a2b... โ (4 leading zeros! Valid!)
2
3
4
5
6
7
8
9
The only way to find a valid nonce is brute forceโtrying billions of combinations until you get lucky.
Why This Creates Security
- It's expensive: Mining requires specialized hardware and massive electricity
- It's competitive: Thousands of miners compete for each block
- It's verifiable: Anyone can instantly check if a hash is valid
- It's irreversible: To change history, you'd need to redo all that work
Analogy: Imagine a lottery where tickets cost $1,000 each, but you can verify winning tickets instantly for free. That's Proof-of-Work.
How Mining Actually Works: Step-by-Step
Step 1: Collect Transactions
Miners listen to the network and collect unconfirmed transactions from the mempool.
Selection criteria:
- Valid signatures (not forged)
- Sufficient funds (no double-spending)
- Highest fee rates (more profit)
Miners build a candidate block with ~2,500 transactions.
Step 2: Create the Block Header
The block header contains:
- Version: Protocol version number
- Previous Block Hash: Links to the last block (creates the chain)
- Merkle Root: Hash of all transactions (proves they're included)
- Timestamp: When the block was created
- Difficulty Target: How many leading zeros required
- Nonce: The number miners are trying to find
Step 3: Hash the Block Header
Miners take the block header and run it through SHA-256 twice:
SHA-256(SHA-256(Block Header)) = Block Hash
SHA-256(SHA-256(Block Header)) = Block Hash
If the hash has enough leading zeros โ Valid block! If not โ Change the nonce and try again.
Step 4: Broadcast the Block
The winning miner broadcasts the block to the network.
Other nodes verify:
- โ All transactions are valid
- โ Hash meets difficulty target
- โ Block reward is correct
- โ Previous block hash is correct
If everything checks out, nodes add the block to their blockchain and start mining the next one.
Step 5: Collect the Reward
The winning miner receives:
- Block subsidy: Currently 6.25 BTC (halves every 4 years)
- Transaction fees: All fees from included transactions
Total reward: ~6.25 BTC + 0.1-0.5 BTC in fees = ~$250,000 USD ๐ฐ
๐ฐ DOWN THE RABBIT HOLE: The First Bitcoin Miner
Satoshi Nakamoto mined the very first Bitcoin block (Genesis Block) on January 3, 2009.
Block #0 Details:
- Reward: 50 BTC (first block ever!)
- Timestamp: 2009-01-03 18:15:05
- Nonce: 2,083,236,893
- Embedded message: "The Times 03/Jan/2009 Chancellor on brink of second bailout for banks"
Satoshi embedded a newspaper headline in the Genesis Block to:
- Prove Bitcoin didn't exist before that date
- Make a statement about the 2008 financial crisis
- Show Bitcoin as an alternative to the failing banking system
The 50 BTC reward from this block has never been spentโmany believe Satoshi intentionally made it unspendable as a symbolic gesture.
Mining Difficulty: The Self-Adjusting System
Bitcoin has a target block time of 10 minutes. But as more miners join (or leave), blocks would be found faster (or slower). So Bitcoin automatically adjusts difficulty.
How Difficulty Adjustment Works
Every 2,016 blocks (~2 weeks), Bitcoin recalculates difficulty:
New Difficulty = Old Difficulty ร (2 weeks / Actual Time)
New Difficulty = Old Difficulty ร (2 weeks / Actual Time)
Examples:
- Blocks took 1 week โ Difficulty doubles (too fast)
- Blocks took 2 weeks โ Difficulty stays same (perfect)
- Blocks took 4 weeks โ Difficulty halves (too slow)
Why This Matters
Without difficulty adjustment:
- More miners join โ Blocks found in 1 second โ All 21M Bitcoin mined in a day โ Game over
With difficulty adjustment:
- More miners join โ Difficulty increases โ Blocks still take ~10 min โ Bitcoin supply stays predictable
This is genius. No matter how much computing power joins the network, Bitcoin maintains its 10-minute block time and 4-year halving schedule.
Current Difficulty Stats
- Current Difficulty: ~60 trillion (60,000,000,000,000)
- Network Hash Rate: ~500 EH/s (500 quintillion hashes per second)
- Next Adjustment: Every 2,016 blocks
To put this in perspective: If you tried to mine Bitcoin on your laptop (1 MH/s), you'd find a block once every 10 million years on average. ๐
๐บ Whiteboard Crypto: What is Bitcoin Mining? (11 min)
The Halving: Bitcoin's Deflationary Schedule
Every 210,000 blocks (~4 years), the block reward halves. This is hardcoded into Bitcoin's protocol.
Halving History
| Date | Block | Reward | Total BTC Mined |
|---|---|---|---|
| Jan 2009 | 0 | 50 BTC | 0 |
| Nov 2012 | 210,000 | 25 BTC | 10,500,000 |
| Jul 2016 | 420,000 | 12.5 BTC | 15,750,000 |
| May 2020 | 630,000 | 6.25 BTC | 18,375,000 |
| Apr 2024 | 840,000 | 3.125 BTC | 19,687,500 |
| 2028 | 1,050,000 | 1.5625 BTC | 20,343,750 |
| 2140 | ~6,930,000 | 0 BTC | 21,000,000 |
Why Halving Matters
- Fixed Supply: Only 21 million Bitcoin will ever exist
- Predictable Issuance: No central bank can "print more"
- Deflationary: Supply decreases over time (opposite of fiat)
- Price Impact: Historically, halvings precede bull markets
Supply Schedule:
- 93% of all Bitcoin already mined (19.6M / 21M)
- Last Bitcoin mined around year 2140
- After 2140: Miners earn only transaction fees (no block subsidy)
๐ฐ DOWN THE RABBIT HOLE: The Halving Cycle & Bull Markets
Historically, Bitcoin's price has followed a 4-year cycle tied to the halving:
Pattern:
- Halving occurs โ Supply shock (new BTC issuance cut in half)
- 12-18 months later โ Bull market peak (all-time high)
- Bear market โ 80%+ crash from peak
- Accumulation phase โ Slow recovery
- Repeat
Historical Examples:
- 2012 Halving: $12 โ $1,100 (2013 peak) โ $200 (2015 bottom)
- 2016 Halving: $650 โ $19,000 (2017 peak) โ $3,200 (2018 bottom)
- 2020 Halving: $8,500 โ $69,000 (2021 peak) โ $15,500 (2022 bottom)
- 2024 Halving: $65,000 โ ??? (2025 peak?)
Why this happens:
- Supply shock: Fewer new coins entering market
- Demand stays same or increases: More adoption
- Price must rise: Basic supply/demand economics
Disclaimer: Past performance doesn't guarantee future results. But the pattern has held for 3 cycles so far...
Mining Hardware: The Arms Race
Bitcoin mining has evolved from hobbyist CPUs to industrial-scale operations.
Evolution of Mining Hardware
2009-2010: CPU Mining
- Regular computer processors
- Hash rate: ~1-10 MH/s
- Anyone could mine from home
- Satoshi mined on a laptop
2010-2011: GPU Mining
- Graphics cards (gaming GPUs)
- Hash rate: ~100-500 MH/s
- 50-100x faster than CPUs
- First "mining rigs" built
2011-2013: FPGA Mining
- Field-Programmable Gate Arrays
- Hash rate: ~1-25 GH/s
- More efficient than GPUs
- Expensive and complex
2013-Present: ASIC Mining
- Application-Specific Integrated Circuits
- Hash rate: 100+ TH/s (100 trillion hashes/sec)
- Built only for Bitcoin mining
- Industrial-scale operations
Modern ASIC Miners
Top miners (2024):
- Antminer S19 XP: 140 TH/s, 3,010W
- Whatsminer M50S: 130 TH/s, 3,276W
- Antminer S21: 200 TH/s, 3,500W
Cost: $2,000-$10,000 per unit Profitability: Depends on electricity cost and Bitcoin price
Mining Profitability
Break-even electricity cost: ~$0.05-0.07 per kWh
Example calculation:
- Miner: Antminer S19 (110 TH/s, 3,250W)
- Electricity: $0.05/kWh
- Daily cost: 3.25 kW ร 24 hrs ร $0.05 = $3.90/day
- Daily revenue: ~$8-12 (varies with difficulty/price)
- Profit: $4-8/day (~$120-240/month)
But this changes constantly based on:
- Bitcoin price
- Network difficulty
- Electricity costs
- Hardware efficiency
Mining Pools: Cooperation in Competition
Solo mining is like playing the lotteryโyou might never win. Mining pools let miners combine their hash power and share rewards.
How Mining Pools Work
- Join a pool: Connect your miner to pool's server
- Receive work: Pool assigns you block header variations to hash
- Submit shares: Send "near-valid" hashes as proof of work
- Pool finds block: Reward distributed based on shares contributed
- Get paid: Proportional to your hash rate contribution
Pool Reward Methods
PPS (Pay-Per-Share):
- Fixed payment per share submitted
- Guaranteed income
- Pool takes risk
PPLNS (Pay-Per-Last-N-Shares):
- Payment based on shares in last N shares before block found
- Higher variance
- Lower pool fees
FPPS (Full Pay-Per-Share):
- PPS + transaction fees
- Most predictable
- Slightly higher fees
Top Mining Pools (2024)
- Foundry USA: ~30% of network hash rate
- AntPool: ~20%
- F2Pool: ~15%
- Binance Pool: ~10%
- ViaBTC: ~8%
Centralization concern: Top 5 pools control ~80% of hash rate. If they colluded, they could attack Bitcoin. But they'd destroy their own business, so it's unlikely.
๐ฐ DOWN THE RABBIT HOLE: The 51% Attack
What is it? If someone controls 51% of Bitcoin's hash rate, they could:
- Double-spend their own transactions
- Prevent confirmations of specific transactions
- Reverse recent transactions (up to a few blocks)
What they CAN'T do:
- โ Steal Bitcoin from other addresses (need private keys)
- โ Change the 21M supply cap (nodes would reject)
- โ Create Bitcoin from nothing (invalid blocks rejected)
- โ Reverse old transactions (too much work to redo)
Cost of 51% attack on Bitcoin:
- Hash rate needed: ~250 EH/s
- Hardware cost: ~$15 billion in ASICs
- Electricity cost: ~$1 million per hour
- Total cost: $15B+ upfront + $24M/day ongoing
Why it won't happen:
- Too expensive: Billions of dollars
- Destroys value: Attack would crash Bitcoin price
- Miners lose: Attackers destroy their own investment
- Network adapts: Community would change PoW algorithm
Smaller chains have been attacked (Bitcoin Gold, Ethereum Classic), but Bitcoin is too big and too expensive to attack.
Bitcoin's Energy Use: The Controversy
Fact: Bitcoin uses a lot of energyโabout 150 TWh/year (similar to Argentina).
But context matters:
Energy Use Comparisons
- Bitcoin: 150 TWh/year
- Gold mining: 240 TWh/year
- Banking system: 260 TWh/year
- Christmas lights (USA): 6.6 TWh/year
- Always-on devices (USA): 1,375 TWh/year
- Global energy use: 176,000 TWh/year (Bitcoin = 0.08%)
The Renewable Energy Angle
Miners seek cheap electricity, which often means:
- Hydroelectric: 40%+ of Bitcoin mining
- Stranded energy: Gas flares, excess renewable energy
- Off-peak hours: Using otherwise wasted electricity
Bitcoin Mining Council estimates:
- 59% of Bitcoin mining uses sustainable energy
- Higher than most industries
The Security Argument
Bitcoin's energy use isn't wasteโit's security:
- Energy โ Hash rate โ Attack cost โ Network security
- More energy = more secure network
- This is the entire point of Proof-of-Work
Analogy: Is the energy used to secure Fort Knox "wasteful"? Noโit's the cost of security.
The Innovation Angle
Bitcoin mining drives:
- Renewable energy development: Miners fund new solar/hydro projects
- Grid stabilization: Miners can turn off instantly during peak demand
- Methane reduction: Miners capture and burn waste gas from landfills/oil fields
Why Mining Matters for Bitcoin
Mining isn't just about creating new coins. It's the security mechanism that makes Bitcoin trustworthy:
- Prevents double-spending: Expensive to rewrite history
- Decentralizes control: No single entity controls the network
- Incentivizes honesty: Miners earn more by following rules
- Proves scarcity: Can't fake the work required
- Distributes coins: Fair launch, no pre-mine
Without mining, Bitcoin would just be a database anyone could edit. Mining makes it immutable.
The Future of Mining
After 2140 (when block subsidy ends):
- Miners earn only transaction fees
- Fees must be high enough to secure network
- Lightning Network may reduce on-chain fees
- Layer 2 solutions may change fee dynamics
Possible scenarios:
- High fees: On-chain transactions become expensive (like international wire transfers)
- Layer 2 dominance: Most transactions happen off-chain (Lightning, sidechains)
- Fee market evolution: New fee mechanisms emerge
The bet: By 2140, Bitcoin will be valuable enough that transaction fees alone provide sufficient security.
Key Takeaways
- Mining = Security, not just coin creation
- Proof-of-Work makes attacking Bitcoin prohibitively expensive
- Difficulty adjusts every 2 weeks to maintain 10-min blocks
- Halving every 4 years creates fixed 21M supply
- ASICs dominate modern mining (100+ TH/s)
- Mining pools let small miners earn consistent rewards
- Energy use is the cost of security, increasingly renewable
- 51% attack is theoretically possible but economically irrational
๐ฏ Test Your Knowledge
โ ๏ธ ONE SHOT ONLY - STUDY UP!
You can only earn Quarks once per lesson. Take your time reviewing the material above before starting. You can retake the quiz as many times as needed, but Quarks are only awarded on your first perfect score!
โ Previous: Transactions & UTXOs | Next Lesson: Network & Nodes โ