> ## Documentation Index
> Fetch the complete documentation index at: https://rexrex.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Check Block Canonicality

> Compare a block hash with the canonical hash at the same block number.

Use `chain canonical` to check whether a block hash matches the canonical block at its block number.

## Command

```sh theme={null}
rex chain canonical \
  --hash 0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
```

## Example Output

Canonical:

```text theme={null}
CHAIN CANONICAL

Requested hash: 0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
Found:          yes
Block number:   128
Canonical hash: 0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
Status:         canonical
```

Not canonical:

```text theme={null}
CHAIN CANONICAL

Requested hash: 0xbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
Found:          yes
Block number:   128
Canonical hash: 0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
Status:         not canonical
```

## How It Works

The command:

* fetches the requested hash with `eth_getBlockByHash`
* reads that block's number
* fetches the canonical block at that number with `eth_getBlockByNumber`
* compares the two hashes

If the requested hash cannot be fetched by the node, the status is unknown.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.