Skip to content
CryptoAcademy logo CryptoAcademy
Menu
Lesson Beginner · 15 min

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.

The mining loop
Mining searches for a nonce whose hash is below the difficulty target Candidate block prev: 0000…b2 merkle: a3f9…7c nonce = 0 hash SHA-256 + nonce ~10^18 hashes/s network-wide Compare with target your hash 31a0c7… (too high) target 000000… (leading zeros) Not below target → nonce++, retry Hash below target ✓ Block accepted & broadcast ~10 min expected per block Why this makes history expensive Each guess is independent — there is no shortcut. Rewriting a block means redoing all the work after it, while honest miners keep extending the real chain.
Find a hash under the target, broadcast, and every node re-verifies with one computation.

Difficulty rule

block_hash ≤ target = T_max / difficulty

More difficulty ⇒ smaller target ⇒ rarer valid hashes.

mine.py python
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.

Try it yourself

What does the nonce do?

Practice · server-graded
  • In Proof of Work, what is the nonce?

    1 pt

Read the target

Practice · server-graded
  • If difficulty requires a hash starting with three leading zeros, how many hex zeros must the hash begin with?

    1 pt
Can 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.

Share this page

Send this link to a friend, or scan the QR code to open it on your phone.