Koinlytics

Merkle Trees Explained

Cryptographyintermediate7 min read
How a single hash summarizes a million transactions and lets you prove one exists in log(n) time. The data structure under every rollup and light client.

A Merkle tree is what happens when you hash pairs of hashes, then hash those hashes, and so on until you get one hash at the top. That top hash (the root) summarizes every leaf. Change any leaf and the root changes. This is the data structure that makes blockchains scalable to verify.

The construction

  1. Start with your data: transactions, accounts, whatever.
  2. Hash each item. These are the leaves.
  3. Pair adjacent leaves and hash the pair. That is the next level.
  4. Repeat until one hash remains. That is the Merkle root.

The killer feature: proofs

To prove a specific transaction is in a block of 1,000,000 transactions, you don't need to send all million. You send the transaction plus the log2(1,000,000) �?^ 20 sibling hashes along its path to the root. The verifier recomputes the root; if it matches the published root, the proof is valid.

Where you meet Merkle trees

Merkle proofs in airdrops

The classic pattern: publish the Merkle root of all eligible addresses and amounts on-chain. Recipients get their leaf and proof from an off-chain server. They submit both to the claim contract, which verifies the proof against the on-chain root and issues the token. This is how Uniswap, Optimism, Arbitrum, and hundreds of other airdrops have shipped: gas cost is O(log n) per claim, not O(n).

Verkle trees are next

Ethereum plans to replace its Merkle Patricia Trie with a Verkle tree (uses vector commitments). Verkle proofs are much smaller than Merkle proofs, which makes stateless clients possible. Every node stops needing the full state; they just verify Verkle proofs.

PreviousMPC and Threshold Signatures
Powered by Koinlytics · Free crypto education.

Ready to try what you just learned?

Open the Koinlytics dashboard and see the concepts live on your real portfolio.

Launch App