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

# x402 (USDC)

> Pay per request in USDC on Solana or Base.

[x402](https://x402.org) maps the HTTP `402 Payment Required` status onto stablecoin payments. Syntalic speaks **x402 v2** on **Solana** and **Base**, in USDC. Version 1 clients (the old `X-PAYMENT` header) are refused.

The server is also listed on [x402scan](https://www.x402scan.com/server/fdf15e0c-8d66-49ae-acbb-d872c75e5147), so x402-aware agents can find it without knowing the URL.

## How it works

```mermaid theme={null}
sequenceDiagram
    participant Agent
    participant API as Syntalic API
    participant Chain as Solana / Base

    Agent->>API: GET /v1/measures/offers?subject=...
    API-->>Agent: 402 + payment-required header<br/>accepts: [solana, base]
    Agent->>Agent: Sign a USDC transfer authorization
    Agent->>API: Same request + PAYMENT-SIGNATURE header
    API->>Chain: Settle the transfer
    Chain-->>API: Confirmed
    API-->>Agent: 200 OK + PAYMENT-RESPONSE header + data
```

Retry the original URL and query parameters. Do not treat a transfer authorization as a reusable API credential. See [errors and retries](https://syntalic.com/docs/payments/overview.md#errors-and-retries) for the optional payment-identifier extension and ambiguous settlement.

## Use `@x402/fetch`

The wrapper handles the 402, signing and retry. Install the SDKs. These versions match the ones the Syntalic MCP server uses:

```bash theme={null}
npm install @x402/fetch@2.9.0 @x402/evm@2.9.0 @x402/svm@2.9.0 viem @solana/kit @scure/base
```

Register a scheme for each chain you hold USDC on. If you register both, the client pays with the first option in the 402 that you registered (Syntalic lists Solana first) and doesn't fall back to the other chain if that wallet is short. Register only the chain you've funded, or pass your own selector to `new x402Client(...)`.

```ts theme={null}
import { wrapFetchWithPayment, x402Client } from "@x402/fetch";
import { ExactEvmScheme } from "@x402/evm/exact/client";
import { ExactSvmScheme } from "@x402/svm/exact/client";
import { privateKeyToAccount } from "viem/accounts";
import { createKeyPairSignerFromBytes } from "@solana/kit";
import { base58 } from "@scure/base";

const evm = privateKeyToAccount(process.env.EVM_PRIVATE_KEY as `0x${string}`);
const svm = await createKeyPairSignerFromBytes(base58.decode(process.env.SOLANA_PRIVATE_KEY!));

const client = new x402Client()
  .register("eip155:8453", new ExactEvmScheme(evm))
  .register("solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp", new ExactSvmScheme(svm));

const paidFetch = wrapFetchWithPayment(fetch, client);
const res = await paidFetch("https://api.syntalic.com/v1/measures/offers?subject=airpods+pro");
```

## Without the SDK

1. Call the URL with no payment. Read the `accepts` array from the JSON body, or base64-decode the `payment-required` header. Each entry has `scheme`, `network`, `asset`, `amount`, `payTo`, `maxTimeoutSeconds` and `extra`; you need `extra` to sign.
2. Sign a transfer for that `amount` of `asset` to `payTo`, in the format of the [x402 spec](https://x402.org).
3. Retry the same request with a `PAYMENT-SIGNATURE` header holding your base64-encoded payment, which must include the entry you chose as `accepted`.

Never hardcode `payTo`. Read it from each 402; the address can change.

## Chains

| Chain | Asset |
| - | - |
| Solana | USDC (SPL) |
| Base | USDC (ERC-20) |

Settlement latency varies.

## Failed payments

A rejected payment can return `402` again. Read the error before retrying. A timeout or missing confirmation does not establish that no transfer settled; do not blindly sign a fresh authorization. See [errors and retries](https://syntalic.com/docs/payments/overview.md#errors-and-retries).


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