Merkle Tree
16/04/2026
A Merkle tree is a hierarchical data structure where data is hashed in pairs repeatedly until a single hash remains — the Merkle root. Blockchains use Merkle trees to represent all transactions in a block in a compact, verifiable form.
How it works
- Each transaction in a block is hashed individually:
Hash(Tx1),Hash(Tx2), etc. - Adjacent hashes are paired and hashed together:
Hash(Hash(Tx1) + Hash(Tx2)) - This process repeats, combining pairs level by level, until only one hash remains
- This final hash is the Merkle root, which is stored in the block header
Merkle Root
/ \
H(1+2) H(3+4)
/ \ / \
H1 H2 H3 H4
| | | |
Tx1 Tx2 Tx3 Tx4
Why it matters
Efficiency: To verify that a specific transaction is in a block, you only need a small set of hashes along the path to the root (a Merkle proof) — not the entire block. This is critical for lightweight clients (SPV wallets) that don't download full blocks.
Integrity: Any change to any transaction changes its hash, which changes the parent hash, and so on up to the Merkle root. This makes tampering immediately detectable.
