Merkle Root
The Merkle root is a single 256-bit hash value that serves as a cryptographic summary of every transaction included in a Bitcoin block. It sits in the block header and is a critical component of the mining process.
Understanding the Merkle Root
Section titled “Understanding the Merkle Root”A Merkle tree (named after computer scientist Ralph Merkle) is a binary tree of hashes. To construct it, you start by hashing each transaction individually. Then you pair up adjacent hashes and hash each pair together. You repeat this process, combining pairs layer by layer, until only a single hash remains at the top — the Merkle root.
Imagine a sports tournament bracket. Individual players (transactions) compete in pairs, and the winner of each match (the combined hash) advances to the next round. Eventually, there is one champion — the Merkle root — that represents the entire tournament.
The Merkle root is important for mining because it connects the block header to all the transactions in the block. Since the block header is what miners actually hash (not the full block of transactions), the Merkle root is what ensures that the proof of work covers all the transactions. If any transaction is added, removed, or modified, the Merkle root changes, which changes the block header, which invalidates the proof of work.
Practical Example
Section titled “Practical Example”A block contains 3,000 transactions. The pool hashes each one, pairs them up, and hashes pairs together through multiple rounds: 3,000 hashes become 1,500, then 750, then 375, and so on until one hash remains. This final hash is placed in the block header’s Merkle root field. When the pool sends a Stratum mining.notify message, it sends the Merkle branches (the path needed to recompute the root) rather than all 3,000 transactions, keeping the data transfer efficient.