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

# Statement encoding

> Byte-exact definition of the statement hash and the route encodings, with a test vector.

![The nine encoded words and their hash](https://mintcdn.com/ambi/zxJ8qP3zW6Y_3Fqs/images/art/layout-light.webp?fit=max\&auto=format\&n=zxJ8qP3zW6Y_3Fqs\&q=85\&s=2a5393f42c019f86b5935e87cc3826c8)

The statement is the only link between an order on Ethereum and a payment elsewhere. Every router, verifier, SDK and indexer must compute it identically.

## Definition

```solidity theme={null}
bytes32 constant PAYMENT_DOMAIN = keccak256("Ambi.Payment.v1");

requestHash = keccak256(abi.encode(request));   // the Ambi.Request tuple

statement = keccak256(abi.encode(
    PAYMENT_DOMAIN,   // bytes32
    originChainId,    // uint256, block.chainid of the market
    market,           // address
    id,               // uint256
    maker,            // address
    escrowToken,      // address, address(0) for ETH
    escrowAmount,     // uint256
    requestHash,      // bytes32
    filler            // address, the matched filler
));
```

## The request tuple

`Ambi.Request` is ABI-encoded as one tuple, `(string, string, bytes, bytes, uint256, address, uint64, uint64)`:

| Field | Type | EVM route encoding |
| - | - | - |
| `chain` | `string` | `"eip155:<chainId>"`, decimal |
| `asset` | `string` | `"native"`, or `"erc20:"` + lowercase hex address |
| `recipient` | `bytes` | 20-byte address, packed |
| `routeData` | `bytes` | `abi.encodePacked(router, token)`, 40 bytes; token is `address(0)` for native |
| `amount` | `uint256` | Base units of the destination token |
| `verifier` | `address` | The inbox on Ethereum |
| `payBy` | `uint64` | Unix seconds, destination clock |
| `proveBy` | `uint64` | `0` |

The router rebuilds the same tuple from its `RemoteOrder`: chain from `block.chainid`, asset and `routeData` from `order.token` and its own address, `proveBy` as `0`.

## Test vector

> [!NOTE]
>
> Computed off-chain with ethers v6. Confirm against the market's `quoteStatement` before relying on it.

```json theme={null}
{
  "domain": "0xa65810ad401c0c52486efe64ad690e7a70cbbca79a218be62ba56a3fae02cba6",
  "request": {
    "chain": "eip155:42161",
    "asset": "erc20:0xaf88d065e77c8cc2239327c5edb3a432268e5831",
    "recipient": "0x2222222222222222222222222222222222222222",
    "routeData": "0x1111111111111111111111111111111111111111af88d065e77c8cc2239327c5edb3a432268e5831",
    "amount": "9100000000",
    "verifier": "0x3333333333333333333333333333333333333333",
    "payBy": "1767225600",
    "proveBy": "0"
  },
  "requestHash": "0x18ff124f22d32f625822b403e0c5df000923b334bde1cbd5e298664ee81d0b34",
  "order": {
    "originChainId": 1,
    "market": "0x4444444444444444444444444444444444444444",
    "id": 7,
    "maker": "0x5555555555555555555555555555555555555555",
    "token": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
    "amount": "2500000000000000000",
    "filler": "0x6666666666666666666666666666666666666666"
  },
  "statement": "0x6afa01816bbe31a4e914b89a829a267077e1ee5df83c89605f2c31a45146c6a5"
}
```


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