Open this lesson in your favourite AI. It'll walk you through the why, explain the demo, and quiz you on the try-it list.
Block production on Bitcoin is auction-style: miners scan a nonce space to find a hash below the current target. Understanding the math (probability of finding a block, expected time, variance) tells you why the system is secure, why difficulty adjusts every 2016 blocks, and why 51% attacks have real-world costs.
Hash rate, difficulty, and probability.
Use these three in order. Each builds on the one before.
In one paragraph, explain Bitcoin mining.
Walk me through difficulty adjustment.
Why does mining variance favor pools, and what trade-offs does pooled mining introduce?
# Probability of finding a block in N hash attempts:
# P(find) = 1 - (1 - 1/D)^N ≈ N/D when N << D
# Target = 2^256 / difficulty (roughly)
# Current network difficulty: ~80 trillion (as of 2025)
current_difficulty = 80_000_000_000_000 # 80T
network_hashrate_eh_per_sec = 600 # 600 EH/s = 6e20 H/s
network_hashrate = 600e18
# Expected time for the entire network to find a block:
target = 2**256 / current_difficulty
expected_attempts = 2**256 / target # = current_difficulty * 2^32 approximately
expected_seconds = expected_attempts / network_hashrate
print(f"Expected block time: {expected_seconds:.1f}s (target: 600s)")
# Probability a single 100 PH/s miner finds the next block:
miner_hashrate = 100e15 # 100 PH/s
share = miner_hashrate / network_hashrate
print(f"Miner share: {share*100:.4f}%")
print(f"Expected blocks per day: {share * 144:.4f}")
# 144 blocks/day (10-min target) * share = expected blocks/day for this miner
# Variance is huge: a 100 PH/s miner gets ~0.024 blocks/day on average,
# but might go weeks without one. Pools exist for variance reduction.
# Why 51% attack is expensive:
# - Need >50% of network hashrate sustained for the attack window
# - 600 EH/s * 30 J/TH * 24h * 30d * $0.05/kWh ≈ $1.5B/month in electricity alone
# - Plus ASIC opex/capex; total cost easily $5-10B/month for sustained attack