§ 07

§ 07 · Blocks

Merkle root

One 32-byte hash that vouches for every transaction in the block

The Merkle root is how a 108-byte header vouches for a block full of transactions.

Every transaction ID in the block is hashed in pairs, the pairs are hashed in pairs, and so on, until one hash is left. That hash goes into the header. Change, add, remove or reorder a single transaction and the root comes out different, so the header no longer matches the block.

The tree itself is explained step by step in Merkle trees. This page is about the header field: where it sits, what it covers and what it doesn’t, and the part it plays in Pearl’s mining.

Try it

Add, edit or reorder transactions and watch the root recompute.

Merkle tree builder

Pair, hash, repeat: many txids become one 32-byte root

1fad76f4e6eccfa580d0001e2b764a4d1ff50558a96f7dd9a78bb18ced5063131fad76f4 coinbase01744c2b9431725b5169245d7b9057d421e6b5bf25fce05818cbaf08c164025f01744c2b tx 1dd6b8f7c597a5473d387379fee85e8d3e9d0a8510e9ec1209debcf1377dd2b57dd6b8f7c tx 24cb8ba415afc98591258733b427d15e19698bb48b850c07c8631fab3829db1b54cb8ba41 tx 375149cb026f2fb1b50f5cea1b4c8e3f03c1c36f8c678cbc05d83df8a9f0e0f2075149cb0 tx 455fd26a7a646df78abc30d4e1dcbb69b218ce2a5677e5465adab5e836a7b974255fd26a7 tx 5f8b682ac2145d11c8416349396156d0f2c2c52f9c91695506cd63902cb8da017f8b682ac83053c79d215153346e8041cfb72ecb6ffa16e3cb3df071b8cef433e9bd913a983053c79c78d3ee1342b1ef1506895314f5dec480faaf50a274a4d9c80567783b56f4b12c78d3ee15bbe61bf5b7102604ac22cfa42fa88c85b4883ba69fe4bee3600e5bda95a92245bbe61bfd989bdca710aaf29cf684945031191ee024376d754cf9cde35ae174e792636d2d989bdcac6c21c0c4204b9f39e17d7f79811aff53eac88ea0d80fcdeffdad96ba3fa8963c6c21c0c Merkle rootCopy of the last node (odd count)copy
Merkle root ✓ matches block 130,827’s header

c6c21c0c4204b9f39e17d7f79811aff53eac88ea0d80fcdeffdad96ba3fa8963

Proof for leaf 0 ✓ verifies

To prove leaf 0 is in the block, send these 3 hashes, not all 6 txids. Hash upward, putting each one on its side:

  1. start1fad76f4e6…506313
  2. me ‖ sibling 01744c2b94…64025f
  3. me ‖ sibling 83053c79d2…d913a9
  4. me ‖ sibling d989bdca71…2636d2
  5. = rootc6c21c0c42…fa8963
Leaves (txids) 6 of 16

Runs in your browser · nothing is sent src/lib/merkle.ts · SHA256d pairs, same as Bitcoin

Where is it in the header?

Size
32 bytes
Type
SHA256d Merkle root of the txids
Format
Internal byte order (shown reversed)
Block 130,827 · header 108 bytes
00000020 999c961b04d94b8b21134e862dc31d5fa56cf9d1f027adb2a0cf95c6525c55eb 6389faa36bd9daffdefc800dea88ac3ef5af1198f7d7179ef3b904420c1cc2c6 1a96d76a a6f36a17 4d52a3fd32160cb032e22edf76912f67dfb1b88946a215281f203836c77ae649
Field Bytes Value
Version header.version 4 @0 0x20000000 int32 LE. BIP-9 style 0x20000000 since block 1; no consensus meaning in Pearl.
Previous block header.prevBlock 32 @4 eb555c52c695cfa0b2ad27f0d1f96ca55f1dc32d864e13218b4bd9041b969c99 Hash of the parent block, stored byte-reversed; shown in display order.
Merkle root header.merkleRoot 32 @36 c6c21c0c4204b9f39e17d7f79811aff53eac88ea0d80fcdeffdad96ba3fa8963 Root of the SHA256d Merkle tree of this block’s txids, stored byte-reversed.
Time header.timestamp 4 @68 1792513562 (2026-10-20 16:26:02 UTC) uint32 LE Unix seconds. Must be at least 1 s after the parent and at most 5 min in the future.
Bits header.bits 4 @72 0x176af3a6 Compact target. Difficulty 40157376.49334089. The certificate's jackpot hash (not this header's hash) must meet it.
Proof commitment header.proofCommitment 32 @76 49e67ac73638201f2815a24689b8b1df672f9176df2ee232b00c1632fda3524d SHA256d(LE32(certificate version) ‖ public data). Replaces Bitcoin’s nonce: Pearl headers have no nonce.
Block hash
1df2f2c1bf39b1a444e622c1788c11736da2f91f4e9a875a38dc23063c6d45b9
Height
130,827
Time
2026-10-20 16:26:02 UTC
Difficulty
40,157,376.49

Bytes 36 to 67. In block 130,827 they are 6389faa3…0c1cc2c6, which an explorer shows reversed as c6c21c0c4204b9f39e17d7f79811aff53eac88ea0d80fcdeffdad96ba3fa8963. That block has 6 transactions, so its tree has three levels above the leaves:

6→3→2→16 \to 3 \to 2 \to 1
Block 130,827
Each level pairs up the hashes below it. With 3, the last hash is paired with a copy of itself.

A node rebuilds the tree from the transactions it received and compares the result with the header. If they differ, the block is invalid, before any expensive checks run.

What does the simplest tree look like?

One leaf. If a block contains only its coinbase, the Merkle root is the coinbase’s txid.

Block 1 is such a block. Its coinbase’s txid is 36b18b26fba6b71149951d88904945c64137e74b250de8d76c4beded90560be2, and here it is in the header, stored reversed:

Block 1 · header 108 bytes
00000020 d7ad8dc5415fb548ff53efe75f10e0e27403d1a33f07dd0c8f61ffb793308da1 e20b5690eded4b6cd7e80d254be73741c6454990881d954911b7a6fb268bb136 9125ef69 ffff001b a6702c7bc69f78c1889ee018904bc9389ee6a71dd55865d263b1c469359088f0
Field Bytes Value
Version header.version 4 @0 0x20000000 int32 LE. BIP-9 style 0x20000000 since block 1; no consensus meaning in Pearl.
Previous block header.prevBlock 32 @4 a18d3093b7ff618f0cdd073fa3d10374e2e0105fe7ef53ff48b55f41c58dadd7 Hash of the parent block, stored byte-reversed; shown in display order.
Merkle root header.merkleRoot 32 @36 36b18b26fba6b71149951d88904945c64137e74b250de8d76c4beded90560be2 Root of the SHA256d Merkle tree of this block’s txids, stored byte-reversed.
Time header.timestamp 4 @68 1777280401 (2026-04-27 09:00:01 UTC) uint32 LE Unix seconds. Must be at least 1 s after the parent and at most 5 min in the future.
Bits header.bits 4 @72 0x1b00ffff Compact target. Difficulty 1. The certificate's jackpot hash (not this header's hash) must meet it.
Proof commitment header.proofCommitment 32 @76 f088903569c4b163d26558d51da7e69e38c94b9018e09e88c1789fc67b2c70a6 SHA256d(LE32(certificate version) ‖ public data). Replaces Bitcoin’s nonce: Pearl headers have no nonce.
Block hash
a09851a4761539d170f7dfe7531864ae92879b02bbe999a6c238f63745a69726
Height
1
Time
2026-04-27 09:00:01 UTC
Difficulty
1

This is common on Pearl. In a 200-block sample taken on 2026-10-20, 107 blocks contained nothing but their coinbase.

What does the root cover, and what not?

It covers the txids. A txid is the hash of a transaction without its witness data, the signatures that unlock its inputs. So the header’s Merkle root doesn’t directly cover signatures.

Witnesses are covered one step removed, exactly as in Bitcoin’s segwit:

  1. A second tree over wtxids

    The node builds another Merkle tree over every transaction’s wtxid (the hash including witness data), with the coinbase’s set to 32 zero bytes.

  2. Its root goes into the coinbase

    SHA256d of that root and a 32-byte reserved value is written into a coinbase output starting 6a24aa21a9ed: the witness commitment.

  3. The coinbase is under the main root

    The coinbase’s txid is the first leaf of the header’s tree, so the header vouches for the witness commitment, which vouches for every witness.

Here is the witness commitment in block 130,825’s coinbase, output 1:

Coinbase of block 130,825 216 bytes
02000000 00 01 01 0000000000000000000000000000000000000000000000000000000000000000 ffffffff 27 0309ff01048393d76a2f706f6f6c2e6b7279707465782e636f6d2f1550cad31e016e7bf00f2ecb ffffffff 02 cc84ce1d34000000 22 5120e31e8032a67b9af27dc279f448c003457bae6c5d28de7ee719bc87b6801ede17 0000000000000000 26 6a24aa21a9ed78cc1a61dcfcee9c59ddd9f4d56a98764c071e077bcc36fe9d1cf0aad50ebac3 01 20 0000000000000000000000000000000000000000000000000000000000000000 00000000
Field Bytes Value
Version version 4 @0 2 int32 little-endian. Pearl wallets and pearld coinbases use version 1; relay policy accepts 1-2.
Marker marker 1 @4 0x00 Segwit marker (BIP-144): says witness data follows the outputs.
Flag flag 1 @5 0x01 Witness flag; 0x01 is the only value Pearl accepts.
Input count vin.length 1 @6 1 CompactSize number of inputs.
Previous txid vin[0].txid 32 @7 0000000000000000000000000000000000000000000000000000000000000000 All zeros: this input creates new coins (coinbase).
Output index vin[0].vout 4 @39 0xffffffff 0xffffffff together with a zero txid marks a coinbase.
scriptSig length vin[0].scriptSig.length 1 @43 39 CompactSize length of the scriptSig.
Coinbase script vin[0].scriptSig 39 @44 0309ff01048393d76a2f706f6f6c2e6b7279707465782e636f6d2f1550cad31e016e7bf00f2ecb Coinbase data. It starts with the block height 130825 (BIP-34, required in every Pearl block), then anything the miner likes.
Sequence vin[0].sequence 4 @83 0xffffffff Final (0xffffffff): no RBF signal, no relative locktime, and locktime is ignored for this input. Pearl wallets use this.
Output count vout.length 1 @87 2 CompactSize number of outputs.
Amount vout[0].value 8 @88 223,838,373,068 grains (2238.38373068 PRL) int64 little-endian, in grains (1 PRL = 100,000,000 grains).
Script length vout[0].scriptPubKey.length 1 @96 34 CompactSize length of the locking script.
Locking script vout[0].scriptPubKey 34 @97 prl1puv0gqv4x0wd0ylwz086y3sqrg4a6umza9r08aecehjrmdqq7mctsmqaqsh OP_1 OP_PUSHBYTES_32 <output key Q>: a Taproot output.
Amount vout[1].value 8 @131 0 grains (0.00000000 PRL) int64 little-endian, in grains (1 PRL = 100,000,000 grains).
Script length vout[1].scriptPubKey.length 1 @139 38 CompactSize length of the locking script.
Locking script vout[1].scriptPubKey 38 @140 witness commitment 78cc1a61dcfcee9c59ddd9f4d56a98764c071e077bcc36fe9d1cf0aad50ebac3 OP_RETURN aa21a9ed ‖ SHA256d(witness Merkle root ‖ nonce): the BIP-141 witness commitment.
Witness items witness[0].length 1 @178 1 Number of witness stack items for input 0.
Witness reserved value length witness[0][0].length 1 @179 32 CompactSize length of this witness item.
Witness reserved value witness[0][0] 32 @180 0000000000000000000000000000000000000000000000000000000000000000 The coinbase witness is one 32-byte value (the witness-commitment nonce); pearld uses zeros.
Locktime locktime 4 @212 0 0: no time lock.
txid
0a2acb6004406b21252d1578585dec84efd7e7547f1bca19c30c17538c51caa0
Size
216 bytes · 189 vbytes
Block
130,825

A coinbase-only block can leave the commitment out: it has no witnesses to commit to. Some Pearl miners do, and others include it anyway.

The certificate is not under the Merkle root. It isn’t a transaction. It is tied to the header through the last field, the proof commitment, which hashes the certificate’s version and public data.

Why does the Merkle root matter to miners?

Because it is one of the inputs to the mining puzzle. The first 76 bytes of the header, Merkle root included, are hashed into the job key, and the job key seeds all of the noise a miner must add to its matrices.

So any change to the block’s transactions gives the miner a completely new puzzle:

  • a new transaction from the mempool changes the root;
  • so does changing a few bytes of the coinbase. Pools put an extranonce there, as in Bitcoin, and on Pearl every new extranonce means a fresh job. Kryptex’s coinbase in block 130,825 ends with 12 such bytes, 1550cad31e016e7bf00f2ecb, after its pool tag /pool.kryptex.com/.
Coinbase of block 130,825 216 bytes
02000000 00 01 01 0000000000000000000000000000000000000000000000000000000000000000 ffffffff 27 0309ff01048393d76a2f706f6f6c2e6b7279707465782e636f6d2f1550cad31e016e7bf00f2ecb ffffffff 02 cc84ce1d34000000 22 5120e31e8032a67b9af27dc279f448c003457bae6c5d28de7ee719bc87b6801ede17 0000000000000000 26 6a24aa21a9ed78cc1a61dcfcee9c59ddd9f4d56a98764c071e077bcc36fe9d1cf0aad50ebac3 01 20 0000000000000000000000000000000000000000000000000000000000000000 00000000
Field Bytes Value
Version version 4 @0 2 int32 little-endian. Pearl wallets and pearld coinbases use version 1; relay policy accepts 1-2.
Marker marker 1 @4 0x00 Segwit marker (BIP-144): says witness data follows the outputs.
Flag flag 1 @5 0x01 Witness flag; 0x01 is the only value Pearl accepts.
Input count vin.length 1 @6 1 CompactSize number of inputs.
Previous txid vin[0].txid 32 @7 0000000000000000000000000000000000000000000000000000000000000000 All zeros: this input creates new coins (coinbase).
Output index vin[0].vout 4 @39 0xffffffff 0xffffffff together with a zero txid marks a coinbase.
scriptSig length vin[0].scriptSig.length 1 @43 39 CompactSize length of the scriptSig.
Coinbase script vin[0].scriptSig 39 @44 0309ff01048393d76a2f706f6f6c2e6b7279707465782e636f6d2f1550cad31e016e7bf00f2ecb Coinbase data. It starts with the block height 130825 (BIP-34, required in every Pearl block), then anything the miner likes.
Sequence vin[0].sequence 4 @83 0xffffffff Final (0xffffffff): no RBF signal, no relative locktime, and locktime is ignored for this input. Pearl wallets use this.
Output count vout.length 1 @87 2 CompactSize number of outputs.
Amount vout[0].value 8 @88 223,838,373,068 grains (2238.38373068 PRL) int64 little-endian, in grains (1 PRL = 100,000,000 grains).
Script length vout[0].scriptPubKey.length 1 @96 34 CompactSize length of the locking script.
Locking script vout[0].scriptPubKey 34 @97 prl1puv0gqv4x0wd0ylwz086y3sqrg4a6umza9r08aecehjrmdqq7mctsmqaqsh OP_1 OP_PUSHBYTES_32 <output key Q>: a Taproot output.
Amount vout[1].value 8 @131 0 grains (0.00000000 PRL) int64 little-endian, in grains (1 PRL = 100,000,000 grains).
Script length vout[1].scriptPubKey.length 1 @139 38 CompactSize length of the locking script.
Locking script vout[1].scriptPubKey 38 @140 witness commitment 78cc1a61dcfcee9c59ddd9f4d56a98764c071e077bcc36fe9d1cf0aad50ebac3 OP_RETURN aa21a9ed ‖ SHA256d(witness Merkle root ‖ nonce): the BIP-141 witness commitment.
Witness items witness[0].length 1 @178 1 Number of witness stack items for input 0.
Witness reserved value length witness[0][0].length 1 @179 32 CompactSize length of this witness item.
Witness reserved value witness[0][0] 32 @180 0000000000000000000000000000000000000000000000000000000000000000 The coinbase witness is one 32-byte value (the witness-commitment nonce); pearld uses zeros.
Locktime locktime 4 @212 0 0: no time lock.
txid
0a2acb6004406b21252d1578585dec84efd7e7547f1bca19c30c17538c51caa0
Size
216 bytes · 189 vbytes
Block
130,825

Make a guess

A miner adds one more transaction to its template half-way through a multiplication. Can it keep the tickets it has already computed?

Think of your answer first, then check it.

Answer No.

The new transaction changes the Merkle root, so the first 76 header bytes change, so the job key, the noise seeds and the noise all change. Every ticket computed against the old template belongs to a block that is no longer being built. In practice miners pick up template changes between jobs, not mid-way.

Can a light wallet use Merkle proofs on Pearl?

It can, but it would only be trusting the header. Bitcoin’s old way for light wallets (BIP 37) sends a merkleblock: a header plus a Merkle proof for the wallet’s transactions. Pearl still has that message, but it carries the bare 108-byte header with no certificate, so a client relying on it alone couldn’t check that the block was really mined.

Pearl’s own light client works differently. It follows the compact-filter design (BIP 157/158), downloads every header with its certificate, and verifies each certificate’s zero-knowledge proof before trusting the chain. See light clients.

Code: the node's check

In checkBlockSanity (node/blockchain/validate.go:470-482 at v1.5.2, on GitHub), pearld builds the tree and compares it with the header before anything else expensive:

node/blockchain/validate.go Go
calcMerkleRoot := CalcMerkleRoot(block.Transactions(), false)
if !header.MerkleRoot.IsEqual(&calcMerkleRoot) {
	str := fmt.Sprintf("block merkle root is invalid - block "+
		"header indicates %v, but calculated value is %v",
		header.MerkleRoot, calcMerkleRoot)
	return ruleError(ErrBadMerkleRoot, str)
}

Then it rejects duplicate transactions (lines 484–496), and only after that verifies the certificate, because, as the code comment says, “certificate verification is compute intensive”. The witness commitment is checked separately, in checkBlockContext (node/blockchain/validate.go:762-766 at v1.5.2, on GitHub).

The codex

Suggested

Up and down arrows move through the results, Enter opens one, Escape closes. Anywhere on the site, slash or Command K opens this search, and the square brackets [ and ] go to the previous and next page.