Anyone can claim to be "the next block." With no central authority to pick a winner, how does a network of strangers agree on whose claim actually counts — in a way that's cheap to check but expensive to fake?
over the target — try another nonce
Slide the nonce and watch the hash bounce around with no pattern at all — there's no way to guess which nonce will land under the target line except by trying it. That randomness is the entire point: finding a winning nonce takes real, unavoidable work, but once found, anyone can verify it in one hash.
- A block hashes its own contents plus a nonce
— the same hash from the last chapter, now folding in a free variable: the nonce.
- Proof-of-work is a threshold on that hash
A nonce "wins" if for a difficulty target . Lower means fewer winning nonces out of every 1000 possible hash values — harder to find, but the check itself (one hash, one comparison) stays instant either way.
- Mining is brute-force search, nothing cleverer
There's no shortcut: try and hash each one until . With hashes landing uniformly across , a fraction of nonces succeed, so the expected number of attempts before the first success is .
- This is Nakamoto consensus's actual mechanism
Whoever finds a winning nonce first gets to propose the next block. Because that costs real, unfakeable computational work, the network agrees on whoever paid the most to get there — no vote, no central authority, just a race everyone can independently verify the winner of.
- prevHash — the previous block's hash, chaining this block to everything before it.
- nonce — the only value miners are free to change; searched from 0 up to 999 here.
- — the difficulty target; a hash below it counts as a valid block.
over the target — try another nonce
1 attempt so far
Step through nonces one at a time on the genesis block. Every single attempt costs the same one hash — there's no way to skip ahead, and no way to tell in advance how many attempts it'll take. That's the "cost" in proof-of-work: real energy spent per attempt, with no guarantee of when it pays off.
Mining the genesis block: prevHash = 0, data = "block-one", target .
- Try the first few nonces
, then for nonces through — every one of them lands in the 930s, nowhere near under .
- Nonce 10 finally succeeds
. Since , this block is now mined — it took attempts (nonces through ).
- Chain a second block onto it
With
prevHash = 33(the genesis block's hash) anddata = "checkpoint-block", the first winning nonce is , giving hash — a completely different search, because prevHash changed the entire input. - Compare to the expected attempt count
expected attempts on average.
- The genesis block happened to need only
- The second needed
Mining is a race against probability, not a guarantee.
Chained onto the genesis block's hash (33), find a nonce whose hash drops under the difficulty target of 50.
Proof-of-work turns "who proposes the next block" into a race that costs real computation to win but costs almost nothing to verify — the asymmetry that lets a network of mutually distrusting nodes agree without a referee. The next chapters look at what happens when two miners find a valid block at nearly the same time (forks), and at an entirely different way to make block proposal expensive: staking money instead of burning electricity.