Glossary · Network

Merkle root

By the CloudMineCrypto teamUpdated

Definition

The Merkle root is a single hash that sums up every transaction in a Bitcoin block. It’s built by hashing transactions in pairs, then pairing those hashes, until one hash is left, and it’s stored in the block header.

Part of the Bitcoin mining glossary, 88 terms in plain English.

Build a Merkle root

Merkle root, in the header

17b1344a79d1

hash 0+1

de80192c

hash 2+3

b87d4f25

tx 0

94e5fe9e

tx 1

c752a4cd

tx 2

934d1415

tx 3

3f172c5d

Tap Edit on any transaction. Its hash, its pair hash and the root all change.

Real double SHA-256, run in your browser, shortened for display. Real blocks hash transaction data, not sentences.

How is the Merkle root built?

Start with the ID of every transaction in the block, which is itself a double SHA-256 hash. Put them in order, coinbase first. Join neighbours in pairs and hash each pair. Now you have half as many hashes. Repeat until one is left: that’s the Merkle root.

If a level has an odd number of hashes, the last one is paired with itself. Change any transaction, even by one satoshi, and every hash on its path to the top changes, root included. Try it in the demo above.

Why a tree and not one big hash?

Proofs. To show a transaction is in a block, you only need the hashes along its branch, not the whole block. A block with about 4,000 transactions needs just 12 of them, a few hundred bytes. Satoshi’s whitepaper describes light wallets that check payments this way, keeping only block headers.

It also matters for mining. When a miner changes the extra nonce in the coinbase transaction, the Merkle root changes, and the block header gets a fresh set of nonces to try.

Sources

  1. Bitcoin: A Peer-to-Peer Electronic Cash System · Satoshi Nakamoto, 2008
  2. Block chain reference: headers, Merkle trees, target · Bitcoin developer documentation
  3. Merkle tree · Bitcoin Wiki

Live figures on this page come from the CloudMineCrypto API and public chain data, refreshed regularly, and are labelled where they appear. Educational only, not financial advice.

Now watch mining happen.

Claim a free 8-hour mining plan in the CloudMineCrypto app and watch your BTC balance grow from live network data. Withdraw to your own wallet, Lightning included. Rewards are estimates.