# Bits

> How Pearl's 4-byte bits field encodes the target, decoding 0x176af3a6 by hand, why difficulty 1 is 0x1b00ffff, and what the target judges.

Source: https://pearlcodex.com/technical/block/bits/ · Last updated: 2026-10-21 · Checked against Pearl's source code at v1.5.5

The **bits** field tells you how hard the block was to win. It holds the [target](https://pearlcodex.com/glossary/#target): a 256-bit number that a winning lottery ticket must not exceed. The smaller the target, the harder the block.

A 256-bit number takes 32 bytes, but this field is only 4. So the target is stored in a compact, scientific-notation-like form, the same one Bitcoin uses: an exponent and three digits of mantissa.

What’s different on Pearl is what the target is _for_. It’s never compared with the block hash. It judges a [ticket](https://pearlcodex.com/glossary/#ticket) inside the block’s certificate, scaled by how much work that ticket cost.

## Try it

Type a bits value and see the target it stands for, its difficulty, and how small a slice of all 256-bit numbers it is.

_Interactive: Bits, target and difficulty. Try it on the page: <https://pearlcodex.com/technical/block/bits/>_

## What does it look like?

- **Size:** 4 bytes
- **Type:** Compact number: exponent ‖ 3-byte mantissa
- **Format:** Little-endian

**Block 130,827 · header · 108 bytes**

```
00000020 999c961b04d94b8b21134e862dc31d5fa56cf9d1f027adb2a0cf95c6525c55eb 6389faa36bd9daffdefc800dea88ac3ef5af1198f7d7179ef3b904420c1cc2c6 1a96d76a a6f36a17 4d52a3fd32160cb032e22edf76912f67dfb1b88946a215281f203836c77ae649
```

| Field                                       | Bytes         | Value                                                                                                                                                                       |
| ------------------------------------------- | ------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Version (`header.version`)                  | 4, offset 0   | 0x20000000 · int32 LE. BIP-9 style 0x20000000 since block 1; no consensus meaning in Pearl.                                                                                 |
| Previous block (`header.prevBlock`)         | 32, offset 4  | eb555c52c695cfa0b2ad27f0d1f96ca55f1dc32d864e13218b4bd9041b969c99 · Hash of the parent block, stored byte-reversed; shown in display order.                                  |
| Merkle root (`header.merkleRoot`)           | 32, offset 36 | c6c21c0c4204b9f39e17d7f79811aff53eac88ea0d80fcdeffdad96ba3fa8963 · Root of the SHA256d Merkle tree of this block’s txids, stored byte-reversed.                             |
| Time (`header.timestamp`)                   | 4, offset 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, offset 72  | 0x176af3a6 · Compact target. Difficulty 40,157,376.49. The certificate's jackpot hash (not this header's hash) must meet it.                                                |
| Proof commitment (`header.proofCommitment`) | 32, offset 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 72 to 75 of block 130,827 are `a6 f3 6a 17`. As a [little-endian](https://pearlcodex.com/glossary/#little-endian) integer, that’s **0x176af3a6**.

## How do you decode it?

Split the four bytes into one byte of exponent and three of mantissa:

| Field    | Size | Description                                                                                                         |
| -------- | ---- | ------------------------------------------------------------------------------------------------------------------- |
| Exponent | 1    | `0x17` = 23: the target is 23 bytes long.                                                                           |
| Mantissa | 3    | `0x6af3a6`: the target’s first three bytes. (Its top bit is a sign bit, as in Bitcoin; targets are never negative.) |

Then shift the mantissa left by the remaining 20 bytes:

$$
\text{target} = \texttt{0x6af3a6} \times 256^{\,23 - 3} = \texttt{0x6af3a6} \times 2^{160}
$$

Written out as 32 bytes, that’s

`0000000000000000006af3a60000000000000000000000000000000000000000`

nine zero bytes, the three mantissa bytes, then twenty more zero bytes. Only three bytes of the target are ever free to vary. That’s the price of fitting it into 4 bytes.

## What is difficulty?

Difficulty compares a target with the easiest one Pearl allows, the target of bits **0x1b00ffff**:

$$
\begin{aligned} \text{difficulty} &= \frac{\text{target}(\texttt{0x1b00ffff})}{\text{target}(\text{bits})} = \frac{\texttt{0xffff} \times 2^{192}}{\texttt{0x6af3a6} \times 2^{160}} \\ &= \frac{65{,}535 \times 2^{32}}{7{,}009{,}190} \approx 40{,}157{,}376.49 \end{aligned}
$$

Block 130,827

That’s exactly what explorers show for block 130,827. A few more points along the chain’s history:

| Block   | Bits         | Target (32 bytes)              | Difficulty          |
| ------- | ------------ | ------------------------------ | ------------------- |
| 0 and 1 | `0x1b00ffff` | `000000000000ffff000…`         | 1.00000000          |
| 2       | `0x1b00ffea` | `000000000000ffea000…`         | 1.00032054          |
| 10,000  | `0x1a0ab2a8` | `0000000000000ab2a8000…`       | 23.92961877         |
| 100,000 | `0x1800c4ef` | `000000000000000000c4ef000…`   | 21,808,883.27997620 |
| 120,000 | `0x180089e0` | `00000000000000000089e0000…`   | 31,150,692.72892112 |
| 130,827 | `0x176af3a6` | `0000000000000000006af3a6000…` | 40,157,376.49334089 |

> **Pearl vs Bitcoin: Difficulty 1 is different**
>
> Bitcoin’s difficulty 1 is bits `0x1d00ffff`, target `0xffff × 2²⁰⁸`. Pearl’s limit is 2²⁰⁸ − 1, and its difficulty 1 is `0x1b00ffff`, target `0xffff × 2¹⁹²`: 2¹⁶ = 65,536 times smaller. So the same difficulty number means far more work on Pearl than on Bitcoin, and a header carrying Bitcoin’s `0x1d00ffff` would be rejected outright as above Pearl’s limit. The encoding itself is identical.

## What is the target compared with?

Not the block hash. On Pearl, the block hash `1df2f2c1…3c6d45b9` of block 130,827 is a big, random-looking number, nowhere near the target. See [block hash](https://pearlcodex.com/technical/block/block-hash/).

The comparison happens inside the certificate. Its `hash_jackpot`, a BLAKE3 hash of one tile’s transcript, read as a little-endian number, must be at most the target **times the work that tile cost**:

$$
\text{ticket} \le \text{target} \times h \cdot w \cdot L
$$

_h·w is the number of cells in the tile and L = k − (k mod r) the length of each cell’s sum. For block 130,827: 8 × 16 × 8,192 = 1,048,576 = 2²⁰._

For block 130,827 that bound is `00000000000006af3a6000…`, the target shifted left by 20 bits, and the ticket `0000000000000436…` is below it. The whole check, with every number, is on [tickets and target](https://pearlcodex.com/technical/mining/tickets-and-target/).

A node checks two simple things about bits itself: the target must be positive and no larger than Pearl’s limit, and the bits must equal what the difficulty rule computes from the parent block.

## How do bits change?

After every block. Pearl’s [WTEMA](https://pearlcodex.com/glossary/#wtema) rule nudges the target up when the last block was slow and down when it was fast, measured against 194 seconds, then re-encodes it in compact form. Each block’s bits come from its parent’s bits and how long the parent took to arrive after the grandparent. Here are six real consecutive blocks:

| Block   | Parent’s solve time | Bits         |
| ------- | ------------------- | ------------ |
| 130,822 | 204 s               | `0x176adb49` |
| 130,823 | 29 s                | `0x176ad3d2` |
| 130,824 | 29 s                | `0x176acc5b` |
| 130,825 | 295 s               | `0x176ad0eb` |
| 130,826 | 510 s               | `0x176adf34` |
| 130,827 | 646 s               | `0x176af3a6` |

A 29-second gap shrinks the target (harder); a 646-second gap grows it (easier). The details are on [WTEMA](https://pearlcodex.com/technical/difficulty/wtema/).

**Make a guess:** A block with bits 0x176af3a6 arrives 300 seconds after its parent. Will the next block’s difficulty go up or down?

**Answer:** Down, slightly: bits 0x176af872, difficulty 40,150,342.21.

300 seconds is slower than the 194-second target, so the target grows by about (300 − 194) ÷ 604,800 ≈ 0.0175%. Re-encoded, the mantissa goes from 0x6af3a6 to 0x6af872. Pearl’s own code gives exactly this. Because the compact form truncates, small changes can round away: the encoding always rounds the target down, a tiny bias toward higher difficulty.

## How much work does a target represent?

On average, 2²⁵⁶ ÷ (target + 1) attempts’ worth. That’s the “work” a node adds up to pick the chain with the most work, as in Bitcoin. For block 130,827 it’s about 1.13 × 10²² (exactly 11,303,469,090,474,696,447,598).

On Pearl that number has a physical meaning: because tickets are scaled by their tile’s work, it is, roughly, the expected number of multiply-accumulates needed to win the block (at the standard noise rank of 128). That reading is an inference from the design, not a figure Pearl publishes. Divided by time, it’s Pearl’s hashrate. See [hashrate](https://pearlcodex.com/technical/mining/hashrate/).

**Code: compact encoding and the difficulty number**

pearld decodes bits exactly like btcd and Bitcoin Core, in [`CompactToBig`](https://github.com/pearl-research-labs/pearl/blob/v1.5.5/node/blockchain/difficulty.go#L23-L57): mantissa = bits & 0x007fffff, exponent = bits >> 24, and target = mantissa × 256^(exponent − 3) (shifted right instead when the exponent is 3 or less), negated if bit 0x00800000 is set. The difficulty explorers show comes from [`getDifficultyRatio`](https://github.com/pearl-research-labs/pearl/blob/v1.5.5/node/rpcserver.go#L1038-L1054):

`node/rpcserver.go`

```go
max := blockchain.CompactToBig(params.PowLimitBits)   // 0x1b00ffff on mainnet
target := blockchain.CompactToBig(bits)
difficulty := new(big.Rat).SetFrac(max, target)
outString := difficulty.FloatString(8)
```

In JavaScript, with BigInt:

```js
const bits = 0x176af3a6;
const target = BigInt(bits & 0x007fffff) << BigInt(8 * ((bits >>> 24) - 3));
// 0x6af3a6n << 160n
```

## In short

- Bits is the header’s fifth field: 4 bytes that encode the 256-bit target as an exponent byte and a 3-byte mantissa, in Bitcoin’s compact format.
- Block 130,827 stores a6 f3 6a 17, which is 0x176af3a6: target = 0x6af3a6 × 256²⁰, difficulty 40,157,376.49.
- Pearl’s easiest target, difficulty 1, is 0x1b00ffff, which is 2¹⁶ times harder than Bitcoin’s difficulty 1. Bitcoin’s 0x1d00ffff is above Pearl’s limit and invalid.
- On Pearl the target is never compared with the block hash. A ticket in the certificate must be at most the target times the work its tile cost.
- Bits change after every block (WTEMA), and the compact format truncates, so each new target keeps only its top three bytes.

## Read the code

- [CompactToBig and BigToCompact](https://github.com/pearl-research-labs/pearl/blob/v1.5.5/node/blockchain/difficulty.go#L23-L57) `node/blockchain/difficulty.go:23-57`
- [PowLimit and PowLimitBits 0x1b00ffff](https://github.com/pearl-research-labs/pearl/blob/v1.5.5/node/chaincfg/params.go#L350-L358) `node/chaincfg/params.go:350-358`
- [Difficulty = target(0x1b00ffff) ÷ target(bits)](https://github.com/pearl-research-labs/pearl/blob/v1.5.5/node/rpcserver.go#L1038-L1054) `node/rpcserver.go:1038-1054`
- [The target must be positive and within the limit](https://github.com/pearl-research-labs/pearl/blob/v1.5.5/node/blockchain/validate.go#L309-L339) `node/blockchain/validate.go:309-339`
- [The ticket is checked against the scaled target](https://github.com/pearl-research-labs/pearl/blob/v1.5.5/zk-pow/src/api/sanity_checks.rs#L150-L159) `zk-pow/src/api/sanity_checks.rs:150-159`

## Sources

### Pearl source

- [Pearl source code at v1.5.5](https://github.com/pearl-research-labs/pearl/tree/v1.5.5)

### Chain data

- [Pearl Blockbook (bits and difficulty)](https://blockbook.pearlresearch.ai)

### Other

- [Bitcoin Developer Reference: target nBits](https://developer.bitcoin.org/reference/block_chain.html#target-nbits)
