Every piece is already built: a way to commit a batch of transactions to one hash, and a way to make proposing a block expensive to compute but cheap to check. What does it look like to actually chain real blocks together using both at once?
This is the same genesis hash from the proof-of-work chapter, and the same Merkle root from the cryptographic-primitives chapter — nothing new is being invented here. Block 1 commits 4 transactions to a root, mines a nonce against that root, and block 2 repeats the process chained onto block 1's hash.
- Commit transactions to a Merkle root — reused, not reimplemented
is exactly the function from the cryptographic-primitives chapter. Every block runs its own transaction set through it once.
- A block's hash folds in the previous hash and this root
— the same shape as the mining chapter's
blockHash, with the Merkle root standing in for the raw data string. - Mining is the same brute-force nonce search
Try until . Same difficulty target , same search, same asymmetry: expensive to find, one hash to check.
- A chain is blocks whose prevHash fields actually link up
Block 's
prevHashmust equal block 's minedhash. Change anything upstream — a transaction, a root, a nonce — and every downstreamprevHashreference stops matching, breaking the chain from that point forward.
- root — this block's Merkle root, committing all of its transactions to one hash.
- prevHash — the previous block's mined hash; the literal link in "blockchain."
Both blocks are exactly as mined — every hash matches, and every link points at the block before it.
Tamper with block 1's first transaction and watch the damage cascade: a different Merkle root produces
a different block hash, that new hash no longer meets the difficulty target (it was only mined to work
for the original root), and block 2's stored prevHash no longer points at anything real. One
tampered transaction breaks two blocks.
Genesis hash 33 (mined in the proof-of-work chapter). Block 1 reuses the crypto-primitives chapter's exact 4 transactions.
- Block 1's Merkle root
— identical to the cryptographic-primitives chapter's worked example, because it's the same 4 transactions.
- Mining block 1
Searching nonces against : , then for nonces through — every one of them lands in the s, well past the target. Nonce is the first to succeed: .
- Mining block 2
A second batch of 4 transactions gives root . Chained onto block 1's hash , the same search against starts at , climbing through the s for the first several nonces, until nonce is the first to succeed, giving hash .
- Tampering with block 1
Change transaction 0 to
"alice pays bob 9": the Merkle root becomes instead of , so — nowhere near under . The nonce that worked for the original root doesn't work for the tampered one; block 1 is no longer validly mined, and block 2'sprevHash = 43no longer matches block 1's real (recomputed) hash.
Block 3 commits its 4 transactions to Merkle root 617 and chains onto block 2's hash (19). Find a nonce whose hash drops under the difficulty target of 50.
A blockchain is nothing more than these two ideas, chained: commit a batch of transactions to one hash (Merkle root), then spend real, unfakeable work proving you found a nonce that makes the resulting block hash small enough — with each block's proof depending on the exact hash of the one before it. Every later chapter in this Part — stake instead of work, forks and finality, sharding, Sybil resistance — is a variation on making that same chain harder to fake or cheaper to run.