Proof of Work
Proof of Work turns block production into a costly lottery: guess a nonce until the block hash falls below a target. The cost is real, which is what makes attacks real.
In this lesson
- Explain the target and difficulty adjustment
- Describe the mining loop
- Justify why PoW resists history rewrites
Guess cheap, verify cheaper
A valid block hash must start with a number of leading zeros defined by the target. Miners vary the nonce, hash again, and try — trillions of times per second across the network. Anyone can verify the result with a single hash. Difficulty retargets every block (Bitcoin: every 2,016) so block time stays near 10 minutes.
Difficulty rule
More difficulty ⇒ smaller target ⇒ rarer valid hashes.
import hashlib\n\ndef mine(block, target):\n nonce = 0\n while True:\n block["nonce"] = nonce\n digest = hashlib.sha256(str(block).encode()).hexdigest()\n if int(digest, 16) < target:\n return nonce, digest\n nonce += 1
Example · A lottery with no shortcuts
No clever strategy beats brute force — each guess is independent, like scratch cards. That is why the only lever is more hardware and cheaper electricity, and why the chain with the most cumulative work is the one honest nodes follow (Nakamoto consensus).
Energy and centralisation
PoW converts electricity into tamper-evidence. Critics highlight the footprint and the mining-pool concentration; defenders point out that the energy buys a security budget no other mechanism has matched at base-layer scale. Both observations are fair — see the comparison lesson.
Mine under a target
Lower the target in the lab and watch the number of guesses needed explode quadratically.
What does the nonce do?
Practice · server-gradedRead the target
Practice · server-gradedCan a miner choose any hash?
No — the header is fixed except for the nonce (and extraNonce in coinbase). Changing anything changes the Merkle root.
What if the network gets faster?
Difficulty adjusts upward, keeping block time stable regardless of hardware.