---
title: "Merkle Root — definition | Nuri Glossary"
description: "The single hash committing to every transaction in a block."
lang: "en"
type: "glossary-term"
canonical: "https://nuri.com/glossary/merkle-root"
---

# Merkle Root

The single hash committing to every transaction in a block.

## Basically

A Merkle root is one code that represents every transaction in a Bitcoin block. If any transaction changes, that code changes too.

## Key Takeaways

- A Merkle root is a single 32-byte hash that cryptographically commits to every transaction in a Bitcoin block. It sits inside the 80-byte block header and is produced by recursively pairing and hashing all transaction IDs in a Merkle tree.
- Merkle roots allow efficient transaction verification. An SPV client can confirm that a transaction is included in a block using only a small Merkle proof of O(log₂n) hashes, rather than downloading the entire block.
- Changing, removing or reordering any single transaction in a block produces a completely different Merkle root. The root therefore acts as a tamper-evident fingerprint of the block's contents.

## What Is a Merkle Root?

A Merkle root is the topmost hash in a binary hash tree called a Merkle tree. It summarises all transactions included in a Bitcoin block. Every block header contains exactly one Merkle root, and that single 32-byte value is enough to verify whether any given transaction belongs to the block.
The concept was invented by computer scientist Ralph Merkle in 1979 and later adapted by Satoshi Nakamoto for Bitcoin. The Merkle root serves as a compact, tamper-evident commitment to the block's transaction set in the Bitcoin protocol. Any altered, added or removed transaction changes the Merkle root entirely, making fraud immediately detectable.
The design makes lightweight wallets possible. SPV clients can verify individual transactions using only the block headers and a short proof path, instead of requiring every user to download and store every transaction.

## How It Works

The Merkle root calculation starts at the bottom of the tree with the raw transactions. Repeated rounds of hashing move upwards until a single hash remains.

## Computation Example

A block with four transactions, A, B, C and D, has its tree built from the bottom up. Each level pairs and hashes values until one root remains.
A block with three transactions, A, B and C, needs an even count. The last TXID is duplicated to create that even count.
The duplication rule applies at every level of the tree where the node count is odd. It does not apply only at the leaf level.

## Position in the Block Header

The Bitcoin block header is exactly 80 bytes and contains six fields. The Merkle root occupies the third field.
Miners hash the entire 80-byte header when they perform proof of work. Any change to any transaction alters the Merkle root in the header, invalidates the block's proof of work and forces the miner to start over. Bitcoin's consensus mechanism binds the transaction set to the block's proof of work in this way.

## Merkle Proofs and SPV

The Merkle root's most important practical application is enabling Merkle proofs, which allow lightweight clients to verify transaction inclusion without downloading full blocks. Section 8 of the Bitcoin whitepaper described the concept as Simplified Payment Verification (SPV).
An SPV client needs only the block headers, which require about 4.2 MB per year of chain growth, and the sibling hashes along the path from the transaction's leaf to the Merkle root. For a block with n transactions, the proof requires only ceil(log₂n) hashes.
The verifier reconstructs the path from the transaction's TXID up to the root, hashing with each sibling along the way. A computed root that matches the Merkle root in the block header proves that the transaction is included. The research article on Bitcoin light clients and SPV provides a deeper look at how lightweight clients use this mechanism.

## SegWit Witness Commitment

Segregated Witness (BIP 141) introduced a parallel Merkle tree for witness data. A separate witness Merkle root is computed from witness transaction IDs (wtxids), which include the signature data that regular TXIDs exclude. The witness commitment is stored in an OP_RETURN output of the coinbase transaction, maintaining backward compatibility as a soft fork.

## Lightweight Wallet Verification

Mobile wallets and browser-based clients cannot store the full blockchain, which is hundreds of gigabytes. These clients can download only block headers and request Merkle proofs for their own transactions, allowing them to verify payments with minimal bandwidth and storage. The approach is the foundation of SPV wallets and protocols like compact block filters (BIP 157/158).

## Mining and Block Construction

Miners compute a new Merkle root every time they adjust the transaction set in their candidate block. Miners sometimes modify the coinbase transaction by changing the extra nonce field when searching for a valid nonce. That change alters the first leaf and cascades through the entire tree, producing a new Merkle root and therefore a new block header hash.

## Cross-Chain and Layer 2 Verification

Merkle roots and Merkle proofs are used beyond Bitcoin's base layer. Layer 2 protocols and sidechains use similar tree structures to commit to off-chain state. Systems like Spark, for example, can reference on-chain Merkle roots to anchor off-chain transactions back to Bitcoin's security.

## CVE-2012-2459: Merkle Tree Mutation

The duplicate-last rule that handles odd transaction counts introduced a subtle vulnerability. An attacker could take a valid block and append duplicates of its last transactions to create an invalid block that produced the same Merkle root and therefore the same block hash. For example, transaction lists [1, 2, 3, 4, 5, 6] and [1, 2, 3, 4, 5, 6, 5, 6] could generate identical Merkle roots.
Nodes would reject the invalid block because duplicate transactions violate consensus rules, but Bitcoin Core cached rejected block hashes. A node that received the mutant block first would reject and cache the hash. When the legitimate block arrived later with the same hash, the node would reject it too, thinking it had already processed that block.
Forrest Voight discovered the issue, and it was disclosed in May 2012. The denial-of-service vulnerability could isolate victim nodes from the network but could not be used to steal funds, and Bitcoin Core versions before 0.4.6 were affected. The fix detects when two identical hashes would be paired at the end of a tree level and flags the block as having a mutated Merkle tree.

## 64-Byte Transaction Ambiguity

A related weakness, CVE-2017-12842, arises because internal Merkle tree nodes and leaf nodes use the same hash function without domain separation. Two 32-byte internal digests can be misinterpreted as a 64-byte transaction and vice versa, potentially deceiving SPV clients. The Bitcoin community has proposed invalidating 64-byte transactions via a soft fork as part of the Great Consensus Cleanup proposal to permanently eliminate this attack vector.

## SPV Trust Assumptions

Merkle proofs allow efficient verification that a transaction is included in a block, but they do not prove that the block itself is valid. An SPV client trusts that miners have validated the block's transactions correctly, so a majority of dishonest miners could theoretically produce a valid proof-of-work block containing invalid transactions. Running a full Bitcoin node remains the gold standard for applications requiring stronger guarantees.
The glossary entry is for informational purposes only and does not constitute financial or investment advice. Always do your own research before using any protocol or technology.
Part of the [Nuri glossary](https://nuri.com/glossary), which defines 1876 Bitcoin, Lightning, wallet, stablecoin and payment terms.
