From 28c3f1f5a68bbad1eda49aa22c8dadb51095c4ce Mon Sep 17 00:00:00 2001 From: Johan Loutfi Date: Wed, 4 Nov 2026 11:25:27 +0100 Subject: [PATCH 01/21] docs(x402): the overview covers metered routes and agent clients --- src/pages/agents/x402/index.mdx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/pages/agents/x402/index.mdx b/src/pages/agents/x402/index.mdx index 87f1e0a..60c8673 100644 --- a/src/pages/agents/x402/index.mdx +++ b/src/pages/agents/x402/index.mdx @@ -19,11 +19,13 @@ It was designed for the agent economy. AI agents can't hold credit cards or comp Parallel runs an **x402 facilitator** and ships drop-in middleware so any API can accept stablecoin payments in a few lines: - **Drop-in middleware** for Express, Next.js, Fastify, and Hono. -- **Accepts USDp, USDC, and sUSDp** — the SDK routes the payment automatically. -- **Zero platform fee** — Parallel takes no cut of your revenue. +- **Accepts USDp, USDC, and sUSDp**: with the Parallel agent client, the agent pays from a token its wallet holds, and the facilitator converts it to the token you receive in the same transaction. USDp and sUSDp convert on every supported network, USDC on Base and Avalanche. +- **Metered pricing**: with `scheme: "upto"`, the agent signs a cap and your handler charges the actual cost, up to that cap. Metered routes settle on Base in USDp. They can also take USDC from standard x402 clients, which Parallel's escrow converts to USDp for you. +- **Agent clients**: agents pay with `@parallel-protocol/x402-fetch`, a drop-in `fetch` replacement. Standard x402 clients, AgentCash among them, can pay only the metered routes on Base that take USDC. +- **Zero platform fee**: Parallel takes no cut of your revenue. - **Gas sponsored** on Base, HyperEVM, and Avalanche. -- **Settles directly to your wallet** — non-custodial, no Parallel account. -- **MIT-licensed SDKs** — the middleware, the agent package and the CLI that signs its payments are published on npm. +- **Settles directly to your wallet**: non-custodial, no Parallel account. +- **MIT-licensed SDKs**: the middleware, the agent package and the CLI that signs its payments are published on npm. ## Start here From d35b8aceb034ede9f5cc0c343b88d9a3f22d6547 Mon Sep 17 00:00:00 2001 From: Johan Loutfi Date: Wed, 4 Nov 2026 11:25:40 +0100 Subject: [PATCH 02/21] docs(x402): the merchant quickstart covers metered routes and handler limits --- src/pages/agents/x402/quickstart.mdx | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/src/pages/agents/x402/quickstart.mdx b/src/pages/agents/x402/quickstart.mdx index b1196f0..962c1a3 100644 --- a/src/pages/agents/x402/quickstart.mdx +++ b/src/pages/agents/x402/quickstart.mdx @@ -1,5 +1,5 @@ --- -title: Accept stablecoins in Express in 5 minutes +title: Accept stablecoins in 5 minutes description: Add stablecoin payment support to any Express, Next.js, Fastify, or Hono API with one middleware. Free, sponsored gas, no signup. --- @@ -17,10 +17,10 @@ npm install @parallel-protocol/x402 ``` :::warning -Use version 0.8.2 or later. Since 1 October 2026 the facilitator settles a payment only when the settle presents the token it issued at verify, and versions before 0.8.0 do not send it: their settlements are refused with `SETTLE_TOKEN_REQUIRED`, and the agent gets a `402` instead of your response. Version 0.8.1 adds the facilitator URL checks of step 2, and 0.8.2 tells the agent to check with you before paying again for the reasons listed in the error codes. +Use version 0.8.2 or later, and 0.10.0 or later to take USDC from standard x402 clients on metered routes. Since 1 October 2026 the facilitator settles a payment only when the settle presents the token it issued at verify, and versions before 0.8.0 do not send it: their settlements are refused with `SETTLE_TOKEN_REQUIRED`, and the agent gets a `402` instead of your response. Version 0.8.1 adds the facilitator URL checks of step 2, and 0.8.2 tells the agent to check with you before paying again for the reasons listed in the error codes. ::: -Install your framework separately — they are optional peer dependencies: +Install your framework separately. It is an optional peer dependency: Express 4 or 5, Next.js 14 or 15, Fastify 5.12.7 or a later 5.x, or Hono 4. ```bash npm install express # or: next · fastify · hono @@ -30,7 +30,7 @@ npm install express # or: next · fastify · hono Point the middleware at the facilitator, then declare which routes are paid, at what price, on which network, and where funds should settle. -Write the facilitator's URL with https, as below. Since version 0.8.1, the SDK refuses any other URL with an `X402ConfigError` when the middleware is created, except plain http on `localhost`, `127.0.0.1` and `[::1]`: `http://agents.parallel.best` is refused. The SDK calls that address only and never follows a redirect, which fails the call with `FACILITATOR_UNAVAILABLE`. +Write the facilitator's URL with https, as below. Since version 0.8.1, the SDK refuses any other URL, except plain http on `localhost`, `127.0.0.1` and `[::1]`: `http://agents.parallel.best` is refused. It throws an `X402ConfigError` when the middleware is created, or on Fastify when the plugin is registered. The SDK calls that address only and never follows a redirect, which fails the call with `FACILITATOR_UNAVAILABLE`. @@ -77,6 +77,8 @@ export const GET = withPayment(config, async (req) => { }); ``` +`withPayment` passes your handler the request only, and expects a `NextResponse` back. On a dynamic segment, read the parameters from `req.nextUrl.pathname`. + @@ -122,26 +124,34 @@ app.get("/api/data", (c) => c.json({ data: "protected content" })); -That's it. Your API now charges $0.01 per request to `/api/data`. Agents pay in any [supported stablecoin](/agents/x402/concepts#supported-stablecoins) — funds settle directly to the wallet address you configured. +That's it. With the Express tab, each request to `/api/data` now costs 0.01 USDp, 0.01 USDC or 0.01 sUSDp, whichever the agent pays. Agents pay with [`@parallel-protocol/x402-fetch`](/agents/x402/agent-quickstart), from any [supported stablecoin](/agents/x402/concepts#supported-stablecoins) they hold. Funds settle directly to the wallet address you configured. A standard x402 client cannot pay this route. **No signup. No platform fee. Funds settle straight to your wallet.** :::tip -`price` is a human amount (`"0.01"`). Each accepted token is priced with its own decimals automatically, from Parallel's on-chain token catalog — `"0.01"` invoices 0.01 USDp and 0.01 USDC on the same 402. Set `decimals` on a route only for a custom token the catalog doesn't know; an unknown token without it fails fast at startup. See the [route configuration](/agents/x402/api-reference#routeconfig). +`price` is a human amount (`"0.01"`). Each accepted token is priced with its own decimals, read from the token catalog of `@parallel-protocol/chains`: `"0.01"` invoices 0.01 USDp, 0.01 USDC and 0.01 sUSDp on the same 402. Set `decimals` on a route only for a custom token the catalog does not know. It then overrides the catalog for every token of the route. An unknown token without it fails the first request to the route with `X402ConfigError`. See the [route configuration](/agents/x402/api-reference#routeconfig). ::: ## 3. What happens behind the scenes When an agent calls your endpoint with a signed payment header: -1. The middleware sends the payload to the facilitator's `/x402/verify` endpoint — an instant, off-chain check of the signature, the amount, the token and the recipient. A valid payment comes back with a settle token, which the middleware keeps in memory. +1. The middleware sends the payload to the facilitator's `/x402/verify` endpoint, a check of the signature, the amount, the token and the recipient, with no transaction sent. A valid payment comes back with a settle token, which the middleware keeps in memory. 2. If valid, **your handler runs** and produces the response. 3. If your handler returns a 2xx, the middleware calls `/x402/settle` with that token — the on-chain transfer happens, once per payment. 4. If your handler fails, **no settlement happens** — the agent is not charged. 5. If the settlement fails, the agent gets a `402` with `PAYMENT_SETTLEMENT_FAILED` and a `reason` instead of your response. A settle that timed out or could not reach the facilitator is retried once first: repeating it is safe, since the facilitator answers with the recorded outcome. See the [error codes](/agents/x402/error-codes). +On Express, Hono and Next.js, a handler that does not answer within 30 seconds gets a `504`, and nothing is settled. On a metered route, the limit is the route's `maxTimeoutSeconds`, 300 by default, minus two minutes, and 30 seconds at least. Fastify does not time handlers out. + Read more: [The verify / settle flow](/agents/x402/verify-vs-settle). +## 4. Optional: metered routes + +Set `scheme: "upto"` on a route whose cost is only known once it is served. `price` becomes a cap that the agent signs, and your handler names the amount it charges in the `payment-settle-amount` header, at most the cap. Without the header, the cap is charged. A `"0"` serves the request for free and settles nothing. An amount above the cap, malformed, or with more decimals than the token has, discards your response, and the agent gets a `402` with `INVALID_SETTLE_AMOUNT`. + +Metered routes settle on Base and accept USDp by default. To also take USDC from standard x402 clients, list `PARALLEL_TOKENS.base.usdc` in `acceptedTokens` next to `PARALLEL_TOKENS.base.usdp`, and approve the escrow for USDC from your `payTo` address. See [metered routes](/agents/x402/api-reference#metered-routes-upto). + ## Next steps - [Concepts: how routing, fees, and gas work](/agents/x402/concepts) From 4d07ae8748f231865812893d1fa7b69420aa9b48 Mon Sep 17 00:00:00 2001 From: Johan Loutfi Date: Wed, 4 Nov 2026 11:37:05 +0100 Subject: [PATCH 03/21] docs(x402): the concepts page covers metered usdc, the gas quota and conversion fees --- src/pages/agents/x402/concepts.mdx | 31 ++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/src/pages/agents/x402/concepts.mdx b/src/pages/agents/x402/concepts.mdx index 3e40f9f..d183694 100644 --- a/src/pages/agents/x402/concepts.mdx +++ b/src/pages/agents/x402/concepts.mdx @@ -7,7 +7,7 @@ import { HelpFooter } from '@/components/HelpFooter' # How the facilitator works -The **facilitator** is the service that verifies and settles x402 payments on-chain. Your API never touches a smart contract — the middleware talks to the facilitator, and the facilitator does the on-chain work. +The **facilitator** is the service that verifies and settles x402 payments on-chain. Your API never calls a smart contract: the middleware talks to the facilitator, and the facilitator does the on-chain work. One optional step is yours: to take USDC from standard x402 clients on a metered route, your `payTo` address approves the escrow for USDC. You declare paid routes in your middleware; the facilitator handles the rest. @@ -15,8 +15,8 @@ You declare paid routes in your middleware; the facilitator handles the rest. Every paid request goes through two phases: -1. **Verify** — the facilitator checks the agent's signed payment off-chain: its shape, signature, nonce and expiry, and that it delivers the required token, for at least the price, to your `payTo` on the route's network. Instant, no transaction. If it's valid, your handler runs, and the facilitator hands the middleware a settle token for this payment. -2. **Settle** — once your handler returns a success response, the middleware presents that token, and the facilitator submits the transfer on-chain and returns a settlement proof. +1. **Verify**: the facilitator checks the agent's signed payment without sending a transaction. It checks its shape, signature, nonce and expiry, and that it delivers the required token, for at least the price, to your `payTo` on the route's network. It refuses a payment whose conversion would go through a paused Parallelizer or savings vault. On a metered route paid in USDp, it checks that the payer holds the cap. On a metered route paid in USDC through Permit2, it simulates the settlement at the cap. If the payment is valid, the facilitator hands the middleware a settle token for it, and your handler runs. +2. **Settle**: once your handler returns a success response, the middleware presents that token, and the facilitator submits the transfer on-chain and returns a settlement proof. If verification fails, your handler never runs. If your handler fails, settlement never happens — the agent is only charged for a successful response. See [verify vs settle](/agents/x402/verify-vs-settle) for the full sequence. @@ -27,30 +27,41 @@ Each payment settles once. The facilitator claims the payment before it submits A route is priced in one of two schemes: - **`exact`**, the default: the agent signs the price, and you receive it. -- **`upto`**, for a resource whose cost is only known once it is served, such as an LLM completion: the agent signs the price as a cap, valid for the route's `maxTimeoutSeconds` (3,600 at most). Your handler names the amount it actually charges, and the escrow refunds the rest on-chain in the same settlement. Metered routes are paid in USDp only. +- **`upto`**, for a resource whose cost is only known once it is served, such as an LLM completion: the agent signs the price as a cap, valid for the route's `maxTimeoutSeconds` (3,600 at most). Your handler names the amount it actually charges, at most the cap, and only that amount is paid. Metered routes settle on Base, in USDp by default, through Parallel's escrow, which takes the signed cap and refunds the rest in the same transaction. A route can also take USDC from [standard x402 clients](#standard-x402-clients): they sign a Permit2 transfer, which moves only the amount charged, and the escrow converts it to USDp for you. -On a metered route the SDK keeps up to the last two minutes of that window for the settlement and its retry: on Express, Hono and Next.js the handler gets `maxTimeoutSeconds` minus 120 seconds, and 30 seconds at least. A settlement the facilitator confirms for another amount than the one your handler asked for is refused with `AMOUNT_MISMATCH` and the response is discarded. Alert on it: money moved, and the agent was not served. The configuration, with the `payment-settle-amount` header and the `meter` function, is in the [package README](https://www.npmjs.com/package/@parallel-protocol/x402). +On a metered route the SDK keeps up to the last two minutes of that window for the settlement and its retry: on Express, Hono and Next.js the handler gets `maxTimeoutSeconds` minus 120 seconds, and 30 seconds at least. Fastify does not time handlers out. An amount above the cap in the `payment-settle-amount` header is refused: the response is discarded, and the agent gets a `402` with `INVALID_SETTLE_AMOUNT`. An amount a `meter` function returns above the cap settles the cap. A settlement the facilitator confirms for another amount than the one your handler asked for is refused with `AMOUNT_MISMATCH` and the response is discarded. Alert on it: money moved, and the agent was not served. The configuration, with the `payment-settle-amount` header and the `meter` function, is in the [API reference](/agents/x402/api-reference#metered-routes-upto). ## Supported stablecoins -By default a route accepts **USDp**, **USDC**, and **sUSDp**. The agent pays with whichever of these it holds; you receive the token you configured — including sUSDp, Parallel's yield-bearing savings token, so your revenue can start earning the moment it settles. You can narrow or widen the accepted set per route with the [`acceptedTokens`](/agents/x402/api-reference#routeconfig) option. +By default a fixed-price route accepts **USDp**, **USDC**, and **sUSDp**, and a metered route accepts USDp. You can narrow or widen the accepted set per route with the [`acceptedTokens`](/agents/x402/api-reference#routeconfig) option. Each payment delivers one of the tokens your route accepts. `@parallel-protocol/x402-fetch` targets the first one in your list, unless the agent sets `payWith` to another token your route accepts, and without `payWith` it pays from whichever token the wallet holds. Put the token you prefer first. Accepting sUSDp, Parallel's yield-bearing savings token, lets your revenue start earning the moment it settles. + +## Standard x402 clients + +Standard x402 clients that support the `upto` scheme, such as AgentCash, can pay a metered route on Base in USDC. They sign a Permit2 transfer of the cap, and the escrow converts the USDC charged to USDp for you. They cannot pay a fixed-price route. + +To accept them: + +1. From your `payTo` address, approve the escrow for Base USDC with an ERC-20 `approve`. The escrow is `0xc3F4de61381A05ED7FBE61c8327B45507BA87F26`, which `getUptoEscrowAddress("base")` returns in `@parallel-protocol/chains` 0.6.0. It takes back each USDC charge to convert it, so every payment uses up that much of the allowance. A payment whose cap the remaining allowance does not cover is refused at verify with `MERCHANT_NOT_ENABLED`. Use a dedicated receiving address, since it limits what the approval exposes. +2. List `PARALLEL_TOKENS.base.usdc` in the route's `acceptedTokens`, next to `PARALLEL_TOKENS.base.usdp` for agents on the Parallel client. Write the price as a decimal string such as `"0.01"`: with USDp and USDC on the same route, a `bigint` price is refused at startup with `X402ConfigError`. + +The `402` then lists the USDC entry first, with what these clients need to sign. The receipt gives the USDC charged in `amountSettled`, and the USDp you received in `amountDelivered` when the facilitator could read it from the settlement. ## Smart routing -You set a price and the tokens you accept. The agent can choose which token to pay with — or let the SDK pick the route automatically. If the agent pays in a different token than the one you receive, the conversion happens inside the same settlement, at no extra platform fee. +You set a price and the tokens you accept. The agent's client chooses how to pay: the Parallel client picks from the wallet's balances unless the agent names a token. If the agent pays in a different token than the one you receive, the conversion happens inside the same settlement transaction, at no extra platform fee. On a fixed-price route, a swap through the Parallelizer pays its mint or burn fee on the agent's side, and you receive at least your price. On a metered route paid in USDC, the conversion to USDp goes through the Parallelizer, so its mint fee comes out of what you receive. At settle, the facilitator reads the Parallelizer's quote, and the conversion must deliver at least 99.9% of it, or the settlement fails and nothing is taken. ## Fees and gas - **Zero platform fee.** Parallel does not take a cut of your revenue. -- **Gas sponsored.** Transactions on Base, HyperEVM, and Avalanche are gas-sponsored — 1,000 per agent per month. Gas is not sponsored on Ethereum mainnet. +- **Gas sponsored.** The facilitator sends every settlement transaction, so agents need no gas token. On Base, HyperEVM, and Avalanche, the first 1,000 settlements of each payer address in a calendar month (UTC), across these chains together, count as sponsored. Settlements on Ethereum, and those past the quota, count as not sponsored and still settle. The receipt reports it in `gasSponsored`. ## Supported networks -The facilitator settles on **Base**, **Ethereum**, **Avalanche**, and **HyperEVM**. Most builders use Base for the lowest cost and sponsored gas. You choose the network per route with the `network` field. From version 0.8.3, the middleware refuses a route on another chain of the Parallel catalog, such as Sonic, with an `X402ConfigError` when it is created. +The facilitator settles on **Base**, **Ethereum**, **Avalanche**, and **HyperEVM**. Most builders use Base for the lowest cost and sponsored gas. You choose the network per route with the `network` field. From version 0.8.3, the middleware refuses a route on another chain of the Parallel catalog, such as Sonic, with an `X402ConfigError` when it is created. Metered payments settle on Base only: on another network they are refused at verify with `PAYMENT_METHOD_NOT_SUPPORTED`. ## Non-custodial settlement -Funds settle directly to the `payTo` address you configure. There is no Parallel account, no holding period, and no withdrawal step — the protocol is non-custodial and Cooper Labs never holds your funds. +Funds settle directly to the `payTo` address you configure. There is no Parallel account, no holding period, and no withdrawal step. The protocol is non-custodial, and Cooper Labs never holds your funds. Metered payments go through Parallel's escrow contract, and reach your `payTo` in the same transaction. ## Next steps From 9dbc2f74defc8a16c34763ee1efed1db4d97915a Mon Sep 17 00:00:00 2001 From: Johan Loutfi Date: Wed, 4 Nov 2026 11:44:15 +0100 Subject: [PATCH 04/21] docs(x402): the verify and settle page covers route v and slow handlers --- src/pages/agents/x402/verify-vs-settle.mdx | 25 ++++++++++++---------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/src/pages/agents/x402/verify-vs-settle.mdx b/src/pages/agents/x402/verify-vs-settle.mdx index df91f7f..ccbf7a7 100644 --- a/src/pages/agents/x402/verify-vs-settle.mdx +++ b/src/pages/agents/x402/verify-vs-settle.mdx @@ -1,13 +1,13 @@ --- title: The verify / settle flow -description: How the Parallel x402 middleware verifies a payment off-chain, runs your handler, then settles on-chain — so agents are never charged for failed requests. +description: How the Parallel x402 middleware verifies a payment, runs your handler, then settles on-chain, only after your handler succeeds. --- import { HelpFooter } from '@/components/HelpFooter' # The verify / settle flow -x402 payments settle in two phases: an off-chain **verify** before your handler runs, and an on-chain **settle** after it succeeds. This is what makes the payment safe — the agent is only charged when it actually receives a successful response. +x402 payments settle in two phases: a **verify** before your handler runs, which sends no transaction, and an on-chain **settle** after it succeeds. This is what makes the payment safe: the facilitator submits the transfer only after your handler returns a success response. ## Sequence @@ -39,16 +39,18 @@ Agent Merchant (the SDK) Facilitator - **The handler only runs after the signature is verified.** A request with a missing or invalid payment never reaches your code — it gets a `402`. - **Settlement happens after a 2xx.** The on-chain transfer is submitted only once your handler returns a success response. If your handler errors, nothing is charged. +- **A slow handler is not charged.** On Express, Hono and Next.js, a handler that does not answer within 30 seconds gets a `504`, and nothing is settled. On a metered route, the limit is `maxTimeoutSeconds` minus two minutes, and 30 seconds at least. Fastify does not time handlers out. - **The settle is bound to the merchant that verified.** `POST /x402/verify` hands the middleware a settle token that `POST /x402/settle` must present. The token stays in memory for the life of the request and never reaches the agent. The facilitator has required it since 1 October 2026, and `@parallel-protocol/x402` sends it from 0.8.0: a merchant on 0.7.x or earlier sees every settlement refused with `SETTLE_TOKEN_REQUIRED`, and is never paid. - **The SDK talks to the facilitator only.** From 0.8.1 it calls the facilitator at its configured https address and never follows a redirect, so the payment, the settle token and the API key never reach another address. - **One payment, one settlement.** The facilitator claims the payment before it submits anything, so two settles of the same payment never both reach the chain. A settle repeated once the first one has finished gets its recorded outcome: the confirmation, marked `alreadySettled`, the failure's own code when the payment may have gone through (`AUTHORIZATION_USED`, `RECEIPT_UNAVAILABLE`, `SUBMISSION_FAILED`), or `PAYMENT_NOT_VERIFIED` after any other failure. - **Concurrent payments do not collide.** On each chain, the facilitator sends its settlement transactions one at a time, so payments settled together each get their own transaction. - **A failed settlement discards the response and says why.** The middleware returns `402` instead of your handler's output, with a `reason` that tells the agent whether to sign a new payment or to check with you first. See [settlement failures](/agents/x402/error-codes#settlement-failures). - **CORS preflight passes through.** `OPTIONS` requests are never challenged. +- **Standard x402 clients are translated.** On a metered route that lists USDC, a standard x402 client sends its own Permit2 payment format. The middleware translates it into the facilitator's format before verify and settle. The facilitator rebuilds the Permit2 message from it and checks the payer's signature, so a mistranslated field fails verification. ## Settlement routes -The facilitator settles each payment through one of 13 routes, chosen from the signed payload. The settlement receipt names it in `route`. +The facilitator settles each payment through one of 14 routes, chosen from the signed payload. The settlement receipt names it in `route`. | Route | Method signed | Agent pays | Merchant receives | Gas (approx.) | How it settles | |---|---|---|---|---|---| @@ -65,27 +67,28 @@ The facilitator settles each payment through one of 13 routes, chosen from the s | **K** | `redeemWithAuthorization` and `swapExactOutputWithAuthorization` | sUSDp | Another backing collateral (exact) | 180K | Same as I, for the other collaterals of the Parallelizer. | | **L** | `partialRedeemWithAuthorization` | sUSDp and USDp | USDp or a backing collateral | 180K | A partial sUSDp redemption combined with the agent's USDp, in one transaction. | | **U** | `uptoWithAuthorization` | USDp (the cap) | USDp (the amount charged) | 130K | A [metered payment](/agents/x402/api-reference#metered-routes-upto): Parallel's escrow contract pulls the signed cap, pays the merchant the amount the handler charged, and refunds the rest to the agent, in one transaction. | +| **V** | `uptoPermit2` | USDC, the amount charged under a cap signed through Permit2 | USDp, converted from the amount charged | 390K | A metered payment from a standard x402 client: the Permit2 proxy pays the merchant the amount charged in USDC, and the escrow converts it to USDp, in one transaction. A Permit2 payment in USDp also settles on this route, with no conversion, at about 130K. | What each route needs on the chain: -- Routes B, D, E, G, I, K and L need the Parallelizer, deployed on Ethereum, Base, Avalanche and HyperEVM. -- Routes B and I swap to USDC, so they need USDC among the chain's collaterals, which is the case on Base and Avalanche. +- Routes B, D, E, G, I, K and L, and route V paid in USDC, need the Parallelizer, deployed on Ethereum, Base, Avalanche and HyperEVM. +- Routes B and I swap to USDC, and route V paid in USDC converts from it, so they need USDC among the chain's collaterals, which is the case on Base and Avalanche. - Routes C, G, H, I, J, K and L need sUSDp on the chain. - Route F takes the chain's USDC, on the four chains. Routes E and G take it only where USDC is a collateral of the Parallelizer, on Base and Avalanche. On these routes, any other token is refused with `PAYMENT_METHOD_NOT_SUPPORTED`, at verify and at settle. -- Route U needs the escrow contract, deployed on Base. On route U, verify also checks that the payer holds the cap. A metered payment on another chain is refused at verify with `PAYMENT_METHOD_NOT_SUPPORTED`. +- Routes U and V need the escrow contract, deployed on Base. On route U, verify also checks that the payer holds the cap. On route V, verify simulates the settlement at the cap, and refuses with `MERCHANT_NOT_ENABLED` when the merchant's USDC allowance to the escrow does not cover the cap. A metered payment on another chain is refused at verify with `PAYMENT_METHOD_NOT_SUPPORTED`. -The facilitator's `GET /capabilities?chain=` lists the routes available on a chain right now, with their gas estimates and fees, and the settlement receipt says in `gasSponsored` whether the facilitator paid the gas. +The facilitator's `GET /capabilities?chain=` lists the routes available on a chain right now, with their scheme, gas estimates and fees. The settlement receipt says in `gasSponsored` whether the payment counted as gas-sponsored. It is false on Ethereum, and once the same payer has passed 1,000 settlements in a calendar month (UTC). ## Headers involved | Phase | Header | Direction | |---|---|---| -| Challenge | `payment-required` | server → client (on `402`) | -| Payment | `payment-signature` (or `X-PAYMENT`) | client → server | -| Receipt | `payment-response` | server → client (on `200`) | +| Challenge | `payment-required` | server to client (on `402`) | +| Payment | `payment-signature` (or `X-PAYMENT`) | client to server | +| Receipt | `payment-response` | server to client (on a `2xx`) | All three carry base64-encoded payloads. The full shapes are documented in [Schemas](/agents/x402/schemas). -From version 0.5.0, `@parallel-protocol/x402-fetch` also sends an `x402-client` header with the paid request, naming the x402-fetch and CLI versions the agent runs, for example `x402-fetch/0.5.1 cli/0.5.2`. The middleware does not read it. Your handler can, to spot a payer on outdated versions and tell it to update. +From version 0.5.0, `@parallel-protocol/x402-fetch` also sends an `x402-client` header with the paid request, naming the x402-fetch and CLI versions the agent runs, for example `x402-fetch/0.5.2 cli/0.5.3`. The middleware does not read it. Your handler can, to spot a payer on outdated versions and tell it to update. From f4cf522a5729936823c425aded1765656f2a6d31 Mon Sep 17 00:00:00 2001 From: Johan Loutfi Date: Wed, 4 Nov 2026 11:51:32 +0100 Subject: [PATCH 05/21] docs(x402): the schemas page covers permit2 entries and the full receipt --- src/pages/agents/x402/schemas.mdx | 57 ++++++++++++++++++++++++------- 1 file changed, 44 insertions(+), 13 deletions(-) diff --git a/src/pages/agents/x402/schemas.mdx b/src/pages/agents/x402/schemas.mdx index 7cc5339..e2eb8eb 100644 --- a/src/pages/agents/x402/schemas.mdx +++ b/src/pages/agents/x402/schemas.mdx @@ -1,6 +1,6 @@ --- title: x402 payment schemas -description: Wire formats for the Parallel x402 payment headers — PaymentRequired, the signed payment payload, and the settlement confirmation. +description: "Wire formats for the Parallel x402 payment headers: PaymentRequired, the signed payment payload, and the settlement confirmation." --- import { HelpFooter } from '@/components/HelpFooter' @@ -9,7 +9,7 @@ import { HelpFooter } from '@/components/HelpFooter' The three x402 headers each carry a base64-encoded JSON payload. These are the shapes the middleware and the facilitator exchange. -## `402` response — `payment-required` +## `402` response: `payment-required` Returned when no valid payment is present. The `payment-required` header holds a base64-encoded `PaymentRequired` object: @@ -30,12 +30,22 @@ interface PaymentRequired { amount: string; // in the token's smallest unit (18 decimals for USDp) payTo: string; maxTimeoutSeconds: number; // the settlement window, 300 by default, 3,600 at most on "upto" - extra: { decimals: number }; // the payer must scale the amount with THESE decimals + extra: { + decimals: number; // the payer must scale the amount with THESE decimals + name?: string; // on a metered USDC entry paid through Permit2: the token's EIP-712 domain + version?: string; + facilitatorAddress?: string; // on that entry: the escrow that settles it + }; }>; + extensions?: { // present when an entry is paid through Permit2 + eip2612GasSponsoring: { info: { description: string; version: "1" }; schema: object }; + }; } ``` -## Request header — `payment-signature` +The same object is also the JSON body of the `402`. On a metered route that lists USDC, the USDC entry comes first, because the x402 SDK's client pays, by default, the first entry it supports. + +## Request header: `payment-signature` The agent attaches a `payment-signature` (or `X-PAYMENT`) header with a base64-encoded signed payload: @@ -60,13 +70,17 @@ const signedPayload = { const header = Buffer.from(JSON.stringify(signedPayload)).toString("base64"); ``` -Agent-side signing helpers (EIP-3009 authorizations, EIP-712 signing) live in the `@parallel-protocol/payment-core` package. +`network` is the chain slug, such as `"base"`, not the `eip155` form of the `402`. On a metered USDC entry, a standard x402 client sends its own Permit2 payload instead, with `accepted.scheme: "upto"` and `payload.permit2Authorization`. The middleware translates it to the method `uptoPermit2` before it reaches the facilitator. + +Agent-side signing helpers (EIP-3009 authorizations, EIP-712 signing) live in the `@parallel-protocol/payment-core` package, and from 0.3.0 `buildUptoPermit2TypedData` builds the Permit2 message of a metered payment. ### Metered payments (`upto`) -On a metered invoice, the agent signs a `ReceiveWithAuthorization` of the cap to Parallel's escrow contract, on the USDp domain, instead of a transfer to the merchant. The payload has `scheme: "upto"` and the method `uptoWithAuthorization`, carries the merchant in `uptoParams.payTo`, and puts the payer's random salt in `authorization.nonce`: the signed nonce is derived from the salt and the payment's terms, so the signature only holds for those exact values. `@parallel-protocol/payment-core` exports `deriveUptoNonce` for this. The escrow address comes from Parallel's chain catalog (`@parallel-protocol/chains`), never from the invoice. +On a metered invoice, the Parallel client signs a `ReceiveWithAuthorization` of the cap to Parallel's escrow contract, on the USDp domain, instead of a transfer to the merchant. The payload has `scheme: "upto"` and the method `uptoWithAuthorization`, carries the merchant in `uptoParams.payTo`, and puts the payer's random salt in `authorization.nonce`: the signed nonce is derived from the salt and the payment's terms, so the signature only holds for those exact values. `@parallel-protocol/payment-core` exports `deriveUptoNonce` for this. The escrow address comes from Parallel's chain catalog (`@parallel-protocol/chains`), never from the invoice. -## `200` response — `payment-response` +With `@parallel-protocol/chains` 0.6.0, the escrow on Base is `0xc3F4de61381A05ED7FBE61c8327B45507BA87F26`. The facilitator still settles route U payments signed for the previous escrow, `0xcCA03ed95Ab203a8566a8abfFDF03AEE4030B974`. A standard x402 client reads the escrow from `extra.facilitatorAddress` instead, and the facilitator settles a Permit2 payment only through the current escrow. + +## Paid response: `payment-response` On success, the middleware sets a `payment-response` header with a base64-encoded settlement confirmation: @@ -74,16 +88,22 @@ On success, the middleware sets a `payment-response` header with a base64-encode interface PaymentConfirmation { success: true; txHash: string; - route: string; // the settlement route, "A" to "L", or "U" for a metered payment - chain: string; // "base" + route: string; // the settlement route, "A" to "L", or "U" or "V" for a metered payment + chain: string; // "base" gasSponsored: boolean; - networkId: string; // "eip155:8453" - amountSettled?: string; // metered routes: the amount charged, in the token's smallest unit - alreadySettled?: true; // answered from an earlier settle's recorded outcome, nothing broadcast this time + networkId: string; // "eip155:8453" + amountSettled?: string; // metered routes: the amount charged, in the paid token's smallest unit + amountDelivered?: string; // route V: the USDp the merchant received, when the facilitator could read it + alreadySettled?: true; // answered from an earlier settle's recorded outcome, nothing broadcast this time + // The fields of the standard x402 settlement response, for clients built on the x402 SDK: + transaction?: string; // the txHash + network?: string; // "eip155:8453" + amount?: string; // amountSettled, or the invoice entry's amount on a fixed-price route + payer?: string; // the payer's address } ``` -`route` is one of the [settlement routes](/agents/x402/verify-vs-settle#settlement-routes). The middleware sets `access-control-expose-headers` automatically so browser clients can read `payment-response`. +From 0.10.0 the middleware always sends `transaction`, `network` and `amount`, and `payer` when the payment names it. `route` is one of the [settlement routes](/agents/x402/verify-vs-settle#settlement-routes). The middleware sets `access-control-expose-headers` automatically so browser clients can read `payment-response`. ## `402` after a failed settlement @@ -99,4 +119,15 @@ interface SettlementFailureBody { The facilitator's `Retry-After` header is copied when it sent one. The reasons and what the agent should do with each are listed in [settlement failures](/agents/x402/error-codes#settlement-failures). +## `402` for an invalid metered amount + +On a metered route, an amount the middleware cannot settle discards your response: a `payment-settle-amount` header that is malformed, has more decimals than the token, or exceeds the cap, or a `meter` function that throws or returns something that is not an amount. The agent gets a `402` with a plain JSON body and no `payment-required` header. Nothing is settled. + +```ts +interface InvalidSettleAmountBody { + error: "INVALID_SETTLE_AMOUNT"; + message: string; +} +``` + From ab5db3fae9cc31a61abd5db7a434bec42ae1693d Mon Sep 17 00:00:00 2001 From: Johan Loutfi Date: Wed, 4 Nov 2026 11:55:21 +0100 Subject: [PATCH 06/21] docs(x402): the webhooks page adds the facilitator's payment lookup --- src/pages/agents/x402/webhooks.mdx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/pages/agents/x402/webhooks.mdx b/src/pages/agents/x402/webhooks.mdx index 36e3b5b..64fa620 100644 --- a/src/pages/agents/x402/webhooks.mdx +++ b/src/pages/agents/x402/webhooks.mdx @@ -1,6 +1,6 @@ --- title: Webhooks -description: Merchant webhooks for the Parallel x402 facilitator are on the roadmap. Until then, confirm payments from the payment-response header or on-chain. +description: Merchant webhooks for the Parallel x402 facilitator are on the roadmap. Until then, confirm payments from the payment-response header, the facilitator, or on-chain. --- import { HelpFooter } from '@/components/HelpFooter' @@ -9,9 +9,10 @@ import { HelpFooter } from '@/components/HelpFooter' Webhook delivery for merchants is **on the roadmap**. -Until then, you can confirm payments in two ways: +Until then, you can confirm payments in three ways: -- **Read the `payment-response` header** on the successful response — it contains the on-chain `txHash` and settlement details ([schema](/agents/x402/schemas)). +- **Read the `payment-response` header** of the paid response. The middleware adds it after your handler has answered, so your handler does not see it: read it from the response on its way out. It holds the `txHash`, the `route`, the `payer` and the `amount` charged, and `amountSettled` on metered routes ([schema](/agents/x402/schemas)). If you build on `createPaymentGate`, `settleVerified` returns the same confirmation as an object. +- **Ask the facilitator.** `GET https://agents.parallel.best/x402/verify?txHash=&chain=` says in `x402Payment` whether the transaction is a payment the facilitator settled, and in `txMined` whether it was mined and succeeded. Without `chain`, a hash the facilitator has no record of gets a `400` with `MISSING_CHAIN`. - **Watch your `payTo` wallet on-chain** for incoming transfers. When webhooks ship, this page will document the event types, payload format, and signature verification. From f627c5ade81cc33bc92b8f13a1594ec8775be83a Mon Sep 17 00:00:00 2001 From: Johan Loutfi Date: Wed, 4 Nov 2026 12:00:01 +0100 Subject: [PATCH 07/21] docs(x402): the api reference covers metered usdc and the facilitator client errors --- src/pages/agents/x402/api-reference.mdx | 40 +++++++++++++++++-------- 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/src/pages/agents/x402/api-reference.mdx b/src/pages/agents/x402/api-reference.mdx index adda40b..fad7660 100644 --- a/src/pages/agents/x402/api-reference.mdx +++ b/src/pages/agents/x402/api-reference.mdx @@ -10,7 +10,7 @@ import { HelpFooter } from '@/components/HelpFooter' Reference for the `@parallel-protocol/x402` package: configuration, framework adapters, and the lower-level facilitator client. :::warning -Use version 0.8.2 or later. Since 1 October 2026 the facilitator settles a payment only when the settle presents the token it issued at verify, which the SDK sends from 0.8.0: with 0.7.x or earlier, every settlement is refused with `SETTLE_TOKEN_REQUIRED`. +Use version 0.8.2 or later. Since 1 October 2026 the facilitator settles a payment only when the settle presents the token it issued at verify, which the SDK sends from 0.8.0: with 0.7.x or earlier, every settlement is refused with `SETTLE_TOKEN_REQUIRED`. Accepting USDC on a metered route needs version 0.10.0 or later. ::: ## Configuration @@ -35,21 +35,21 @@ interface PaymentMiddlewareConfig { | Field | Type | Required | Description | |---|---|---|---| -| `price` | `string \| bigint \| (ctx) => string \| bigint \| Promise` | Yes | Amount required. A string like `"0.01"` is parsed with each accepted token's own decimals. Pass a `bigint` to skip parsing, or a function to price each request from its content. On a metered route, `price` is the cap. | -| `decimals` | `number` | No | Override for custom tokens only. Each accepted token's decimals are resolved automatically from Parallel's on-chain token catalog. An unknown token without `decimals` throws `X402ConfigError` at the first request on the route. | +| `price` | `string \| bigint \| (ctx) => string \| bigint \| Promise` | Yes | Amount required. A string like `"0.01"` is parsed with each accepted token's own decimals. Pass a `bigint` to skip parsing, or a function to price each request from its content. On a metered route, `price` is the cap. On a metered route that accepts tokens with different decimals, such as USDp and USDC, a `bigint` price is refused with `X402ConfigError`: use a string like `"2"`. | +| `decimals` | `number` | No | Override for custom tokens only. Each accepted token's decimals are read from the token catalog of `@parallel-protocol/chains`, and `decimals` replaces them for every token of the route. An unknown token without `decimals` throws `X402ConfigError` at the first request on the route. On a metered route that accepts tokens with different decimals, `decimals` is refused with `X402ConfigError` at startup. | | `network` | `string` | Yes | Chain slug: `"ethereum"`, `"base"`, `"avalanche"`, or `"hyperevm"`, the chains the facilitator settles on. From 0.8.3, another chain of the Parallel catalog, such as Sonic, throws `X402ConfigError` when the middleware is created. | | `payTo` | `Address` | Yes | The merchant's receiving address. | -| `acceptedTokens` | `Address[]` | No | Token addresses the route accepts. Defaults to USDp, USDC, and sUSDp for the network, and required on networks without defaults. A metered route accepts USDp only. | +| `acceptedTokens` | `Address[]` | No | Token addresses the route accepts. Defaults to USDp, USDC, and sUSDp for the network on a fixed-price route, and to USDp on a metered route. Required on networks without defaults. A metered route on Base can also list USDC, paid through Permit2 by standard x402 clients: see [USDC from standard x402 clients](#usdc-from-standard-x402-clients). Any other token on a metered route throws `X402ConfigError` at startup. | | `description` | `string` | No | Human-readable description of the resource, included in the `402` body. | -| `scheme` | `"exact" \| "upto"` | No | `exact` (default) charges `price` as invoiced. `upto` invoices `price` as a cap: the handler names the amount it actually charges, and the rest is refunded on-chain. See [metered routes](#metered-routes-upto). | +| `scheme` | `"exact" \| "upto"` | No | `exact` (default) charges `price` as invoiced. `upto` invoices `price` as a cap: the handler names the amount it actually charges, and only that amount is paid. See [metered routes](#metered-routes-upto). | | `maxTimeoutSeconds` | `number` | No | Settlement window announced to the payer, 300 by default. On a metered route it is 3,600 at most: a larger value throws `X402ConfigError` at startup. On metered routes, Express, Hono and Next.js give the handler this window minus two minutes, kept for the settlement and its retry, and 30 seconds at least. Fastify does not time handlers out. | -| `meter` | `(ctx) => string \| bigint \| undefined \| Promise` | No | Metered routes only: reads the amount to charge from the handler's response. See [metered routes](#metered-routes-upto). | +| `meter` | `(ctx) => string \| bigint \| null \| undefined \| Promise` | No | Metered routes only: reads the amount to charge from the handler's response. On a route that accepts tokens with different decimals, it must return a string, since a `bigint` is refused like a failing meter. See [metered routes](#metered-routes-upto). | Route matching is **longest-prefix-wins**: `/api/v1/users` matches a `/api/v1` config before a `/api` one. ### Metered routes (`upto`) -On a route with `scheme: "upto"`, `price` is a cap: the handler names the amount it charges, and the facilitator settles that amount through [route U](/agents/x402/verify-vs-settle#settlement-routes), refunding the rest to the agent. Metered payments are made in USDp, on Base. +On a route with `scheme: "upto"`, `price` is a cap: the handler names the amount it charges, and the facilitator settles that amount through [route U](/agents/x402/verify-vs-settle#settlement-routes), refunding the rest to the agent, or through route V for a payment signed with Permit2. Metered payments settle on Base, the one chain with the escrow. They are made in USDp, and in USDC from standard x402 clients, see [below](#usdc-from-standard-x402-clients). ```ts import { SETTLE_AMOUNT_HEADER } from "@parallel-protocol/x402"; @@ -71,18 +71,28 @@ The handler names the amount in the `payment-settle-amount` header, in whole tok | an amount up to `price` | That amount is settled, and the receipt's `amountSettled` carries it. | | malformed, more decimals than the token, or above `price` | The response is discarded and the agent gets `402 INVALID_SETTLE_AMOUNT`. | -Instead of the header, a `meter` function on the route can read the amount from the response: it receives `{ status, header(name), body, request }` and returns an amount, or nothing to let the header decide. An amount above the cap settles the cap, and a `meter` that throws makes the agent get `402 INVALID_SETTLE_AMOUNT`. +Instead of the header, a `meter` function on the route can read the amount from the response: it receives `{ status, header(name), body, request }` and returns an amount, or nothing to let the header decide. An amount above the cap settles the cap, and a `meter` that throws makes the agent get `402 INVALID_SETTLE_AMOUNT`. So does a `meter` that returns something that is not an amount. A handler that finishes after the window has done the work, but the payment can no longer settle: the agent gets `402 PAYMENT_SETTLEMENT_FAILED` with reason `PAYMENT_EXPIRED`, and the merchant is not paid. Keep a margin. +#### USDC from standard x402 clients + +On Base, a metered route can also accept USDC from standard x402 clients that support the `upto` scheme, such as AgentCash. They sign a Permit2 transfer of the cap, and the facilitator settles it through route V: the Permit2 proxy pays the merchant the USDC charged, and the escrow converts it to USDp in the same transaction. This needs version 0.10.0 or later. + +List the network's USDC in `acceptedTokens`, for example `[PARALLEL_TOKENS.base.usdc, PARALLEL_TOKENS.base.usdp]`. The `402` then lists the USDC entry first, with its EIP-712 domain and the escrow as `facilitatorAddress`. It also declares the `eip2612GasSponsoring` extension, so a client whose Permit2 allowance for USDC falls short can sign an EIP-2612 permit with the payment. + +Before you list USDC, approve the escrow for USDC from the `payTo` address, with an ERC-20 `approve`. Its address is `getUptoEscrowAddress("base")` from `@parallel-protocol/chains`, `0xc3F4de61381A05ED7FBE61c8327B45507BA87F26`. The escrow takes back each USDC charge to convert it, so every payment uses up that much of the allowance. A payment whose cap the remaining allowance does not cover is refused at verify with `MERCHANT_NOT_ENABLED`. Receive on a dedicated address rather than a treasury, since it bounds what the approval exposes. + +On such a route, `price` must be a decimal string such as `"2"`, and so must the amount a `meter` returns. The receipt gives the USDC charged in `amountSettled`, and the USDp the merchant received in `amountDelivered` when the facilitator could read it from the settlement. `@parallel-protocol/x402-fetch` does not pay the USDC entry. It pays the USDp entry of the same invoice, through route U. + ## Framework adapters | Import path | Export | Framework | |---|---|---| | `@parallel-protocol/x402/express` | `paymentMiddleware(config)` | Express 4 / 5 | | `@parallel-protocol/x402/next` | `withPayment(config, handler)` | Next.js 14 / 15 | -| `@parallel-protocol/x402/fastify` | `paymentMiddleware(config)` | Fastify 4 / 5 | -| `@parallel-protocol/x402/hono` | `paymentMiddleware(config)` | Hono 4+ | +| `@parallel-protocol/x402/fastify` | `paymentMiddleware(config)` | Fastify 5 (5.12.7 or later) | +| `@parallel-protocol/x402/hono` | `paymentMiddleware(config)` | Hono 4 | See the [quickstart](/agents/x402/quickstart) for a working example of each. @@ -105,6 +115,7 @@ const result = await client.settle(paymentHeader, paymentRequirements, { settleT if (result.success) { console.log(result.txHash, result.route, result.gasSponsored); console.log(result.amountSettled); // metered routes: the amount charged + console.log(result.amountDelivered); // route V: the USDp the merchant received, when readable console.log(result.alreadySettled); // true when an earlier settle already did it } else { console.error(result.error.code); // e.g. "INSUFFICIENT_BALANCE" @@ -113,7 +124,9 @@ if (result.success) { } ``` -The constructor throws `X402ConfigError` when the URL is neither https nor plain http on `localhost`, `127.0.0.1` or `[::1]`. `verify` uses a 10-second timeout and `settle` a 60-second one, since it waits for on-chain inclusion. `verify` throws an [`X402RuntimeError`](/agents/x402/error-codes) on any failure, with the facilitator's text in `.detail` and its status in `.status`, and a verify that issues no settle token is an invalid response. `settle` returns a result union on facilitator errors and throws on connectivity issues, with `SETTLE_TIMEOUT` when the 60 seconds ran out: the payment may then still settle. +A confirmation also carries the fields of the standard x402 settlement response: `transaction`, `network`, `amount` and `payer`. + +The constructor throws `X402ConfigError` when the URL is neither https nor plain http on `localhost`, `127.0.0.1` or `[::1]`. `verify` uses a 10-second timeout and `settle` a 60-second one, since it waits for on-chain inclusion. Both translate a standard x402 Permit2 payment into the form the facilitator verifies, and both throw `INVALID_PAYMENT` when the payment header cannot be decoded. `verify` throws an [`X402RuntimeError`](/agents/x402/error-codes) on any failure, with the facilitator's text in `.detail` and its status in `.status`. A verify that issues no settle token is an invalid response, `FACILITATOR_INVALID_RESPONSE`. `settle` returns a result union on the facilitator's refusals. It throws `SETTLE_TIMEOUT` when the 60 seconds ran out, `FACILITATOR_UNAVAILABLE` when it cannot reach the facilitator or gets an error answer that carries no `error` field, and `FACILITATOR_INVALID_RESPONSE` for a malformed answer. After `SETTLE_TIMEOUT` or `FACILITATOR_UNAVAILABLE`, the payment may still settle. The settle token is a secret for the life of the request. Keep it in memory, never log it, never send it to the payer. @@ -135,6 +148,7 @@ const result = await gate({ getMethod: () => request.method, getPath: () => request.path, getUrl: () => request.url, + getBody: async () => request.body, // optional: the parsed body, for price and meter functions }); if (result.type === "pass") { @@ -161,8 +175,10 @@ Use `createPaymentMiddleware` instead if you want the whole flow (verify, run th ## Utilities -| Function | Signature | Description | +| Export | Type | Description | |---|---|---| +| `PARALLEL_TOKENS` | `Record` | The token addresses of each network, such as `PARALLEL_TOKENS.base.usdc` | +| `getDefaultAcceptedTokens` | `(network) => [usdp, usdc, susdp] \| undefined` | The default `acceptedTokens` of a fixed-price route | | `parsePrice` | `(price, decimals?) => bigint` | `"0.01"` → `10000000000000000n` (18 decimals default) | | `validateAddress` | `(address) => boolean` | Checks `0x` + 40 hex chars | | `toEip155Network` | `(network) => string` | `"base"` → `"eip155:8453"` | From 37636ed5123bfe607935db509e737209e1cf2d4b Mon Sep 17 00:00:00 2001 From: Johan Loutfi Date: Wed, 4 Nov 2026 12:06:33 +0100 Subject: [PATCH 08/21] docs(x402): the error codes cover the permit2 refusals and the 64 kb limit --- src/pages/agents/x402/error-codes.mdx | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/src/pages/agents/x402/error-codes.mdx b/src/pages/agents/x402/error-codes.mdx index 9e8e5a1..d03762f 100644 --- a/src/pages/agents/x402/error-codes.mdx +++ b/src/pages/agents/x402/error-codes.mdx @@ -15,7 +15,8 @@ Since 1 October 2026 the facilitator settles a payment only when the settle pres | Error class | When | |---|---| -| `X402ConfigError` | Invalid config, with a message that names the field at fault. At middleware setup: bad `payTo`, a facilitator URL that is malformed or not https (plain http is accepted only for `localhost`, `127.0.0.1` and `[::1]`), a metered route with `maxTimeoutSeconds` above 3,600, or, from version 0.8.3, a `network` of the Parallel catalog other than `ethereum`, `base`, `avalanche` and `hyperevm`, such as Sonic. At the first request on a route: an unknown network with no `acceptedTokens`, an unknown token with no `decimals`, or a price below the token's precision. | +| `X402ConfigError` | Invalid config, with a message that names the field at fault. At middleware setup: no route, bad `payTo`, a price that is malformed or not positive, a facilitator URL that is malformed or not https (plain http is accepted only for `localhost`, `127.0.0.1` and `[::1]`), a `meter` on a route that is not metered, a metered route with `maxTimeoutSeconds` above 3,600, a metered route that lists a token other than the network's USDp and Base USDC, a `bigint` price or a `decimals` on a metered route whose tokens have different decimals, or, from version 0.8.3, a `network` of the Parallel catalog other than `ethereum`, `base`, `avalanche` and `hyperevm`, such as Sonic. At the first request on a route: an unknown network with no `acceptedTokens`, an unknown token with no `decimals`, a price below the token's precision, or a price function that throws or does not return a price. | +| `X402PriceRejectedError` | Thrown by your price function to refuse a request before anything is invoiced. The client gets its `status`, 400 by default, with `{ error: code, message }`. | | `X402RuntimeError` | A runtime failure. The specific cause is in `.code` (below). | ### `X402RuntimeError.code` @@ -35,10 +36,11 @@ When the facilitator refuses a payment at verify, your handler does not run and | Code | Facilitator status | Meaning | What the agent should do | |---|---|---|---| -| `INVALID_PAYLOAD` | 400 | The payload does not have the shape of its settlement route, carries a field another route would read, or uses a method of the other scheme. | Sign a payment that matches one of the `accepts` entries. | -| `INVALID_SIGNATURE` | 400 | Signature recovery failed. | Sign again. | +| `INVALID_PAYLOAD` | 400 | The payload does not have the shape of its settlement route, carries a field another route would read, uses a method of the other scheme, or names a token, escrow or proxy its route does not take. On a payment through Permit2, also an EIP-2612 permit that is not for the cap or ends before the Permit2 deadline. | Sign a payment that matches one of the `accepts` entries. | +| `INVALID_SIGNATURE` | 400 | Signature recovery failed. On a payment through Permit2, also the payer's contract wallet or Permit2 refusing the signature. | Sign again. | | `INVALID_NONCE` | 409 | Nonce already used: the same payment reached the facilitator before, and may have settled. | Do not sign another payment before checking with the merchant. | | `PAYMENT_EXPIRED` | 402 | The authorization's `validBefore` has passed. | Sign a new payment. | +| `PAYMENT_NOT_YET_VALID` | 402 | A payment through Permit2 whose `validAfter` has not passed yet. | Sign again with a `validAfter` in the past. | | `INSUFFICIENT_AMOUNT` | 402 | The amount the route guarantees the merchant is below the price: the signed amount on a transfer, the guaranteed output (`amountOut` or `amountOutMin`) on a conversion. Also an authorization for zero. | Sign for the invoiced `amount`. | | `INSUFFICIENT_BALANCE` | 402 | The payer does not hold the signed amount. Checked on metered payments, against the cap. | Fund the wallet, sign a new payment. | | `ASSET_MISMATCH` | 400 | The route does not deliver the token the merchant requires. | Pay so that the merchant receives one of the `accepts` assets. | @@ -47,12 +49,17 @@ When the facilitator refuses a payment at verify, your handler does not run and | `WINDOW_TOO_LONG` | 400 | A metered authorization valid for more than 3,600 seconds. | Sign again with a `validBefore` within the hour. | | `PAYMENT_METHOD_NOT_SUPPORTED` | 400 | No settlement route for this method or token on this chain, including a metered payment on a chain without the escrow. | Pay with another method or token. | | `COLLATERAL_NOT_SUPPORTED` | 400 | The swap delivers a token that is not a collateral of the chain. | Pay for another of the `accepts` assets. | -| `RATE_LIMIT_EXCEEDED` | 429 | The payer passed 1,000 verifies in the current UTC hour. | Pay again after `Retry-After`, which points to the next hour. | +| `RATE_LIMIT_EXCEEDED` | 429 | The payer passed 1,000 verifies in the current UTC hour. A verify counts once its signature and payment checks pass, even when it is refused after that, because a swap or the savings vault is paused, or another verify reserved the same nonce first. | Pay again after `Retry-After`, which points to the next hour. | | `PARALLELIZER_PAUSED` | 503 | The Parallelizer has paused the swap this route needs, or the facilitator could not read whether it has. Nothing was taken. | Pay with another token, or pay again later. | | `SAVINGS_PAUSED` | 503 | The sUSDp savings vault the payment deposits into or redeems from is paused, or the facilitator could not read whether it is. Nothing was taken. | Pay with another token, or pay again later. | | `SERVICE_UNAVAILABLE` | 503 | The facilitator could not read the chain or its own store. | Pay again after a short wait. | +| `PERMIT2_ALLOWANCE_REQUIRED` | 412 | A payment through Permit2 from a payer whose Permit2 approval for the token is below the cap, with no EIP-2612 permit or one the token refused. The message starts with `permit2_allowance_required`, the reason standard x402 clients look for. | Approve Permit2 for the token, or sign the payment with an EIP-2612 permit. | +| `TOKEN_BLOCKED` | 403 | A payment through Permit2 that the token refuses: the payer or the merchant is blacklisted, or the token is paused. Nothing was taken. | Pay with another token. | +| `MERCHANT_NOT_ENABLED` | 503 | A USDC payment through Permit2 to a merchant whose USDC allowance to the escrow does not cover the cap, so the escrow cannot convert it. Nothing was taken. | Pay with USDp, or pay again later. | +| `SWAP_UNAVAILABLE` | 503 | The Parallelizer cannot convert the USDC of a payment through Permit2 now, for instance because a cap is reached or a price feed is stale. Nothing was taken. | Pay with USDp, or pay again later. | +| `SETTLEMENT_WOULD_FAIL` | 402 | A payment through Permit2 whose settlement, simulated at verify, would revert for another reason. Nothing was taken. | Pay with another token, or sign a new payment later. | -An `error` from the facilitator that is not a code (capitals, digits and underscores) is not forwarded: the `402` carries `FACILITATOR_INVALID_RESPONSE` with the facilitator's message instead. That is the case of its per-IP rate limit (see [rate limits](#rate-limits)). +An `error` from the facilitator that is not a code (capitals, digits and underscores) is not forwarded: the `402` carries `FACILITATOR_INVALID_RESPONSE` with the facilitator's message instead. That is the case of its per-IP rate limit, status 429 (see [rate limits](#rate-limits)), of a payload that does not match its request schema, status 400, and of a request body above 64 KB, status 413, which a payment forwarded by the middleware stays well below. ## Settlement failures @@ -70,7 +77,7 @@ The settlement runs after your handler answered. When it fails, the middleware d | Reason | Facilitator status | Meaning | What the agent should do | |---|---|---|---| -| `INSUFFICIENT_BALANCE` | 402 | The payer no longer holds the signed amount. | Fund the wallet, sign a new payment. | +| `INSUFFICIENT_BALANCE` | 402 | The payer no longer holds the signed amount, or on a payment through Permit2 the amount charged. | Fund the wallet, sign a new payment. | | `AUTHORIZATION_USED` | 409 | The authorization is already consumed or cancelled on-chain. It may have paid the merchant. | Do not sign another payment before checking with the merchant. | | `PAYMENT_EXPIRED` | 402 | The authorization expired before settlement. On a metered route, the handler finished after the window. | Sign a new payment. | | `PAYMENT_NOT_VERIFIED` | 402 | No verified payment for this authorization, or an earlier settle of it failed. After `AUTHORIZATION_USED`, `RECEIPT_UNAVAILABLE` or `SUBMISSION_FAILED`, a repeated settle gets that code again instead. The merchant may have been paid, or may still be. | Do not sign another payment before checking with the merchant. | @@ -81,12 +88,12 @@ The settlement runs after your handler answered. When it fails, the middleware d | `SAVINGS_PAUSED` | 503 | The sUSDp savings vault the payment deposits into or redeems from is paused, or the facilitator could not read whether it is. This settle sent nothing, but the payment may still settle until its authorization expires, and an earlier attempt may already have settled it. | Do not sign another payment before checking with the merchant. | | `SERVICE_UNAVAILABLE` | 503 | The facilitator could not read its own store. This settle sent nothing, but the payment may still settle until its authorization expires, and an earlier attempt may already have settled it. | Do not sign another payment before checking with the merchant. | | `TX_REVERTED` | 500 | The transaction reverted for a reason the facilitator could not attribute. | Sign a new payment. | -| `SWAP_PRICE_MOVED` | 402 | The Parallelizer refused the swap: its price or fee moved, between signing and settlement, beyond the margin signed with the payment. The payment was not taken, and the facilitator will not settle it. | Sign a new payment. | +| `SWAP_PRICE_MOVED` | 402 | The Parallelizer refused the swap: its price or fee moved, between signing and settlement, beyond the margin signed with the payment. On a payment through Permit2, the margin is the one the facilitator sets under the Parallelizer's quote. The payment was not taken, and the facilitator will not settle it. | Sign a new payment. | | `SWAP_UNAVAILABLE` | 503 | The Parallelizer refused the swap because it cannot make it now: the swap closed since the facilitator checked it, a cap or a maximum fee is reached, the amount exceeds what it can release, or a price feed is stale. The payment was not taken, and the facilitator will not settle it. | Pay with another token, or later with a new payment. | | `SUBMISSION_FAILED` | 500 | The settle failed. When the message says the outcome is unknown, a transaction may have been sent, or the facilitator could not read whether the authorization was used, and the payment may have settled or may still settle. | Do not sign another payment before checking with the merchant. x402-fetch says so for this reason whatever the message. A client that reads the merchant's 402 itself may sign a new payment when the message says no transaction was submitted. | | `RECEIPT_UNAVAILABLE` | 500 | The transaction was sent but its confirmation could not be read. | Do not sign another payment before checking with the merchant. | | `INVALID_PAYLOAD`, `NETWORK_MISMATCH`, `PAYMENT_METHOD_NOT_SUPPORTED` | 400 | The settle does not match the payment that was verified, or a metered amount is missing, malformed or above the cap. Nothing was settled. | Sign a new payment. | -| `INSUFFICIENT_AMOUNT` | 402 | A metered amount of zero. Nothing was settled. | Sign a new payment. | +| `INSUFFICIENT_AMOUNT` | 402 | A metered amount of zero, or an authorization for zero. Nothing was settled. | Sign a new payment. | The SDK adds its own reasons: @@ -104,7 +111,7 @@ Before any of this, a settle that timed out or could not reach the facilitator i ## Rate limits -The facilitator counts the requests of each IP address that calls it, which is the merchant's server: 60 verifies a minute and 600 settles a minute, each on its own counter. It also counts the verifies of each payer: 1,000 per UTC hour. +The facilitator counts the requests of each IP address that calls it, which is the merchant's server: 60 verifies a minute and 600 settles a minute, each on its own counter. An IPv6 address counts with its /64 network. It also counts the verifies of each payer, 1,000 per UTC hour, including some that are refused at the last checks (see `RATE_LIMIT_EXCEEDED`). A request body above 64 KB is refused with `413`, which a payment forwarded by the middleware stays well below. | Limit | What the agent gets | |---|---| From 8e6a6882afa25a4d1e71a6453b9c06aa5a688605 Mon Sep 17 00:00:00 2001 From: Johan Loutfi Date: Wed, 4 Nov 2026 12:10:11 +0100 Subject: [PATCH 09/21] docs(x402): the agent quickstart covers x402-fetch 0.5.2 and metered invoices on base --- src/pages/agents/x402/agent-quickstart.mdx | 24 +++++++++++----------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/pages/agents/x402/agent-quickstart.mdx b/src/pages/agents/x402/agent-quickstart.mdx index 47737a1..b80bab4 100644 --- a/src/pages/agents/x402/agent-quickstart.mdx +++ b/src/pages/agents/x402/agent-quickstart.mdx @@ -15,9 +15,9 @@ This guide makes an agent pay x402 APIs autonomously. The whole integration is o npm install @parallel-protocol/x402-fetch ``` -This page describes version 0.5.1, the one a fresh install gets. The package signs through the payment engine of the [Parallel CLI](/agents/cli), `@parallel-protocol/cli`, which it installs as a regular dependency, in version 0.5.2 or a later 0.5 release. +This page describes version 0.5.2, the one a fresh install gets. The package signs through the payment engine of the [Parallel CLI](/agents/cli), `@parallel-protocol/cli`, which it installs as a regular dependency, in version 0.5.2 or a later 0.5 release. From CLI 0.5.3, a metered payment on Base is signed for the current escrow. The facilitator also settles payments signed for the previous escrow by earlier releases. -A project on an earlier release moves to 0.5.1 with `npm install @parallel-protocol/x402-fetch@latest`, which also sets its range to `^0.5.1`. Without `@latest`, `npm install` and `npm update` keep the release that a `^0.4` or older range allows, since it does not reach 0.5. From 0.3.0, `payFetch` rejects with an `X402FetchError` when the merchant answers a paid request with `402`, as described in [When the merchant refuses the payment](#when-the-merchant-refuses-the-payment) and [When the settlement fails](#when-the-settlement-fails): code written for 0.2 that read that response must catch the error instead. +A project on an earlier release moves to 0.5.2 with `npm install @parallel-protocol/x402-fetch@latest`, which also sets its range to `^0.5.2`. Without `@latest`, `npm install` and `npm update` keep the release that a `^0.4` or older range allows, since it does not reach 0.5. From 0.3.0, `payFetch` rejects with an `X402FetchError` when the merchant answers a paid request with `402`, as described in [When the merchant refuses the payment](#when-the-merchant-refuses-the-payment) and [When the settlement fails](#when-the-settlement-fails): code written for 0.2 that read that response must catch the error instead. ## 2. Fund a wallet @@ -59,7 +59,7 @@ const receipt = decodePaymentResponse(res); console.log("paid:", receipt?.txHash, "gas sponsored:", receipt?.gasSponsored); ``` -That's the entire agent. The first request costs nothing (it just reads the `402` invoice); the paid retry carries the signed authorization. +That's the entire agent. The first request costs nothing, since it only reads the `402` invoice. The paid retry carries the signed authorization. Besides `txHash` and `gasSponsored`, the `PaymentReceipt` type covers `route`, `chain`, `networkId`, `amountSettled` on a metered payment, and `alreadySettled`. The URL in the example is real: it is Parallel's **live demo API**, where every route charges 0.0001 of whichever token you pay with — try it as-is. For a complete runnable agent that also decodes the invoice and the on-chain settlement, clone the [agent starter](https://github.com/parallel-protocol/parallel-x402-agent-starter). @@ -72,13 +72,13 @@ The URL in the example is real: it is Parallel's **live demo API**, where every | `payWith` | *(auto)* | Force a payment token (`"usdp"`, `"usdc"`, `"susdp"`). Omitted, the agent picks from its balances. | | `maxAmount` | `"1"` | Hard spend cap per request, in token units. Invoices above it are refused before signing. | | `dailyBudget` | *(none)* | Cumulative spend ceiling per UTC day, across every payment the wrapper signs. Without it, nothing limits how many capped payments a day can sign. | -| `timeoutMs` | `60000` | Time budget of the payment engine, in milliseconds. | +| `timeoutMs` | `60000` | How long one payment may take in the payment engine, in milliseconds. It does not bound the requests to the merchant. A value that is not a whole number from 1 to 2147483647 throws `ENGINE_TIMEOUT` when you wrap `fetch`. | | `allowInsecure` | `false` | Pay merchants served over plain `http://`. Localhost is always allowed. | | `updateCheck` | `true` | Warn once when npm has a newer x402-fetch, or a newer CLI release this version accepts. See [versions](#versions). | ## Versions -The paid request carries an `x402-client` header with the x402-fetch and CLI versions the agent runs, for example `x402-client: x402-fetch/0.5.1 cli/0.5.2`, and nothing else about the agent. A merchant can spot a payer on outdated versions and tell it to update. Releases before 0.5.0 send no such header. +The paid request carries an `x402-client` header with the x402-fetch and CLI versions the agent runs, for example `x402-client: x402-fetch/0.5.2 cli/0.5.3`, and nothing else about the agent. A merchant can spot a payer on outdated versions and tell it to update. Releases before 0.5.0 send no such header. At the first payment of a process, in the background, the wrapper asks npm for the latest release of x402-fetch and of the CLI: two requests to `registry.npmjs.org` that carry only the package names. When the installed x402-fetch is older than its latest release, or the installed CLI is older than a latest release this x402-fetch accepts, it warns once, with `process.emitWarning` and the code `X402_FETCH_OUTDATED`. No payment waits for the check, and it says nothing when npm cannot be reached. The check does not run with `updateCheck: false`, in CI (`CI` set to anything but `false`), under a test runner (`NODE_ENV=test`), with `NO_UPDATE_NOTIFIER` set, or when Node warnings are off (`--no-warnings` or `NODE_NO_WARNINGS=1`). @@ -91,22 +91,22 @@ Every guard fires **before** the agent signs — a refused invoice never spends | `NO_SIGNING_KEY` | No private key provided (option or env), or a malformed one. Thrown when you wrap `fetch`. | | `UNKNOWN_CHAIN` | The configured `chain` is not a known chain. Thrown when you wrap `fetch`. | | `AMOUNT_EXCEEDS_MAX` | The invoice asks more than `maxAmount`. | -| `BUDGET_EXCEEDED` | The invoice would take the day's spend past `dailyBudget`. | +| `BUDGET_EXCEEDED` | The invoice would take the day's spend past `dailyBudget`. Also thrown when you wrap `fetch`, if `dailyBudget` is not a positive decimal amount. | | `CHAIN_MISMATCH` | The invoice targets a different chain than configured. | -| `UNSUPPORTED_SCHEME` | The invoice offers only schemes this client cannot pay on the configured chain. It pays `exact` invoices, and `upto` invoices in USDp. | +| `UNSUPPORTED_SCHEME` | The invoice offers only schemes this client cannot pay on the configured chain. It pays `exact` invoices, and `upto` invoices in USDp unless `payWith` names another token. | | `INVALID_INVOICE` | An invoice field is malformed: a `payTo` or `asset` that is not an address, an amount that is not a positive integer, or decimals that contradict the token catalog or fall outside 0 to 36. `decodePaymentResponse` also throws it, after the payment, when the receipt header cannot be decoded. | | `INSECURE_URL` | The merchant URL is plain `http://` (localhost excepted). | -| `ENGINE_NOT_FOUND` | The payment engine, `@parallel-protocol/cli`, could not be found. | -| `ENGINE_FAILED` | Payment preparation failed — the message carries the cause (usually balance, or a transient RPC error), and `engineCode` the engine's code, such as `INSUFFICIENT_BALANCE`. | -| `ENGINE_TIMEOUT` | Payment preparation exceeded its time budget. | +| `ENGINE_NOT_FOUND` | The payment engine, `@parallel-protocol/cli`, could not be found, or declares no binary. Reinstall the dependencies. | +| `ENGINE_FAILED` | The engine refused the payment, or failed. The message carries the cause, and `engineCode` the engine's code when it gave one: `INSUFFICIENT_BALANCE` when the wallet cannot cover the amount, or `RPC_ERROR` when no RPC node answered a read the payment needs. After `RPC_ERROR` nothing is signed: retry, or set `ALCHEMY_API_KEY`. | +| `ENGINE_TIMEOUT` | The engine did not answer this payment within `timeoutMs`. Other payments in flight are not affected. Also thrown when you wrap `fetch`, if `timeoutMs` is not a whole number of milliseconds from 1 to 2147483647. | Two more codes from `payFetch` come after the payment is sent, when the merchant answers the paid request with `402`: `PAYMENT_REFUSED` and `SETTLEMENT_FAILED`. The sections below describe them. ## Metered invoices -A merchant can invoice a route with the `upto` scheme: a cap rather than a price, for a resource whose cost is only known once it is served. The agent signs the cap for the window the merchant announced (`maxTimeoutSeconds`, 3,600 seconds at most), the merchant charges its actual cost, and the escrow refunds the rest on-chain in the same settlement. The receipt's `amountSettled` is what was really paid. +A merchant can invoice a route with the `upto` scheme: a cap rather than a price, for a resource whose cost is only known once it is served. The agent signs the cap for the window the merchant announced. That window is `maxTimeoutSeconds`, 300 seconds when the merchant announces none, and 3,600 seconds at most. The merchant charges its actual cost, and Parallel's escrow refunds the rest on-chain in the same settlement. The receipt's `amountSettled` is what was really paid. -Metered payments are made in USDp. The cap counts in full against `maxAmount` and `dailyBudget`, and the refund is never credited back to the day's budget. +Metered payments are made in USDp, on Base, from the wallet's USDp balance, which must cover the whole cap. The cap counts in full against `maxAmount` and `dailyBudget`, and the refund is never credited back to the day's budget. A metered invoice can also offer USDC through Permit2, for standard x402 clients: x402-fetch skips that entry and pays the USDp one. An invoice whose only entries on your chain are metered entries in another token is refused with `UNSUPPORTED_SCHEME`. The engine takes the escrow's address from its own catalog, never from the invoice. ## When the merchant refuses the payment From 0bbedb0685ca895675551cd8465b8b510120a27f Mon Sep 17 00:00:00 2001 From: Johan Loutfi Date: Wed, 4 Nov 2026 12:16:40 +0100 Subject: [PATCH 10/21] docs(mcp): the mcp page covers the stateless endpoint and its real warnings --- src/pages/agents/mcp/index.mdx | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/pages/agents/mcp/index.mdx b/src/pages/agents/mcp/index.mdx index c7c2c9d..eaaf30c 100644 --- a/src/pages/agents/mcp/index.mdx +++ b/src/pages/agents/mcp/index.mdx @@ -9,7 +9,7 @@ import { HelpFooter } from '@/components/HelpFooter' The Parallel MCP server lets any AI assistant read the protocol and prepare transactions for you: live TVL and savings rates, mint and redeem quotes, bridge transfers, staking — 36 tools behind one URL. -**Zero config. Never signs.** There is no API key, no account and no private key to provide. Read tools return live on-chain data; write tools return **unsigned transaction data** that you review and sign in your own wallet. The server cannot move funds — yours or anyone's. +**Zero config. Never signs.** There is no API key, no account and no private key to provide. Read tools return live on-chain data, [cached briefly](/agents/mcp/transactions#data-freshness). Write tools return **unsigned transaction data** that you review and sign in your own wallet. The server cannot move funds, yours or anyone's. ## 1. Connect @@ -36,6 +36,8 @@ claude mcp add --transport http parallel https://mcp.parallel.best/mcp **Any other MCP client** — point it at `https://mcp.parallel.best/mcp` with the Streamable HTTP transport. +The endpoint is stateless. Every request is a POST that stands on its own, `initialize` included. The server issues no session id, and a GET or DELETE gets HTTP 405. Answers come back as plain JSON, not as an event stream. A request body larger than 64 KB gets HTTP 413 with a JSON-RPC error (code `-32000`) before it is parsed. + ## 2. Try it Ask in plain language — the assistant picks the right tools: @@ -50,13 +52,13 @@ Total TVL, USDp supply, the savings APY and the proof-of-solvency ratio, in one What's the current sUSDp savings rate? ``` -The live protocol-wide APY (around 12% at the time of writing), the exchange rate and total deposits per chain. +The live protocol-wide APY, the exchange rate and total deposits per chain. ``` -Quote me a mint of 500 USDp with USDC on Base +Quote me a mint of USDp with 500 USDC on Base ``` -Expected output, fees and price impact — a read, nothing to sign. +The expected USDp output, the fee and the oracle price. A read, nothing to sign. ``` Deposit 100 USDp into savings on Base, receiver 0xYourAddress @@ -68,9 +70,9 @@ An unsigned transaction (plus an approval if needed) ready to review and sign in | The server | Your wallet | |---|---| -| Reads on-chain data through public RPCs | — | +| Reads on-chain data through RPC nodes, and some staking, governance and bridge data from HTTP APIs | — | | Builds and simulates unsigned transactions | Reviews, signs and submits every transaction | -| Warns before risky operations (slippage, penalties, lost boosts) | Decides | +| Warns before risky operations (failed simulations, unstake penalties, lost boosts, sunset chains) | Decides | | Holds no keys, no funds, no user accounts | Holds the keys | The endpoint is public and unauthenticated by design: there is nothing to steal and nothing to configure. From 2d687ebf01f93e7a32c7473426ec898df2e9e20c Mon Sep 17 00:00:00 2001 From: Johan Loutfi Date: Wed, 4 Nov 2026 12:35:51 +0100 Subject: [PATCH 11/21] docs(mcp): trim the mcp page back to its corrections --- src/pages/agents/mcp/index.mdx | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/pages/agents/mcp/index.mdx b/src/pages/agents/mcp/index.mdx index eaaf30c..3c2c084 100644 --- a/src/pages/agents/mcp/index.mdx +++ b/src/pages/agents/mcp/index.mdx @@ -9,7 +9,7 @@ import { HelpFooter } from '@/components/HelpFooter' The Parallel MCP server lets any AI assistant read the protocol and prepare transactions for you: live TVL and savings rates, mint and redeem quotes, bridge transfers, staking — 36 tools behind one URL. -**Zero config. Never signs.** There is no API key, no account and no private key to provide. Read tools return live on-chain data, [cached briefly](/agents/mcp/transactions#data-freshness). Write tools return **unsigned transaction data** that you review and sign in your own wallet. The server cannot move funds, yours or anyone's. +**Zero config. Never signs.** There is no API key, no account and no private key to provide. Read tools return live on-chain data; write tools return **unsigned transaction data** that you review and sign in your own wallet. The server cannot move funds — yours or anyone's. ## 1. Connect @@ -36,8 +36,6 @@ claude mcp add --transport http parallel https://mcp.parallel.best/mcp **Any other MCP client** — point it at `https://mcp.parallel.best/mcp` with the Streamable HTTP transport. -The endpoint is stateless. Every request is a POST that stands on its own, `initialize` included. The server issues no session id, and a GET or DELETE gets HTTP 405. Answers come back as plain JSON, not as an event stream. A request body larger than 64 KB gets HTTP 413 with a JSON-RPC error (code `-32000`) before it is parsed. - ## 2. Try it Ask in plain language — the assistant picks the right tools: @@ -58,7 +56,7 @@ The live protocol-wide APY, the exchange rate and total deposits per chain. Quote me a mint of USDp with 500 USDC on Base ``` -The expected USDp output, the fee and the oracle price. A read, nothing to sign. +Expected output, fees and oracle price — a read, nothing to sign. ``` Deposit 100 USDp into savings on Base, receiver 0xYourAddress @@ -70,7 +68,7 @@ An unsigned transaction (plus an approval if needed) ready to review and sign in | The server | Your wallet | |---|---| -| Reads on-chain data through RPC nodes, and some staking, governance and bridge data from HTTP APIs | — | +| Reads on-chain data through public RPCs | — | | Builds and simulates unsigned transactions | Reviews, signs and submits every transaction | | Warns before risky operations (failed simulations, unstake penalties, lost boosts, sunset chains) | Decides | | Holds no keys, no funds, no user accounts | Holds the keys | From ba4c591bb7bda81f537adadc1c4c6a4d0f5995a6 Mon Sep 17 00:00:00 2001 From: Johan Loutfi Date: Wed, 4 Nov 2026 12:36:01 +0100 Subject: [PATCH 12/21] docs(mcp): the tools page drops the fee share figure and the price impact --- src/pages/agents/mcp/tools.mdx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/pages/agents/mcp/tools.mdx b/src/pages/agents/mcp/tools.mdx index d66437c..04d33c3 100644 --- a/src/pages/agents/mcp/tools.mdx +++ b/src/pages/agents/mcp/tools.mdx @@ -28,7 +28,7 @@ import { HelpFooter } from '@/components/HelpFooter' | `get_supported_chains` | The 24 chains USDp is deployed on, with status and contract addresses (Sonic is flagged sunset — mint, redeem and savings were wound down there under PIP-64, while USDp, bridging and balance reads stay live) | | `get_supported_collaterals` | Collaterals accepted on a chain, with caps, utilization and mint/redeem status | | `get_fee_rates` | Adaptive mint/redeem fees per collateral — can be negative (incentives) | -| `get_savings_rate` | The protocol-wide sUSDp APY (7d/30d/90d), exchange rate and total deposits, with `feeShare`: the share of the protocol surplus not kept by the DAO Treasury, read on-chain (90% today), or `null` when that read fails | +| `get_savings_rate` | The protocol-wide sUSDp APY (7d/30d/90d), exchange rate and total deposits, with `feeShare`: the share of the protocol surplus not kept by the DAO Treasury, read on-chain, or `null` when that read fails | | `get_proof_of_solvency` | Total backing vs USDp supply — the canonical solvency ratio, per chain | ## Savings (sUSDp) @@ -44,7 +44,7 @@ import { HelpFooter } from '@/components/HelpFooter' | Tool | What it does | |---|---| -| `get_quote` | Exact mint or redeem quote: output, fees, price impact — read-only | +| `get_quote` | Exact mint or redeem quote: output, fees, oracle price — read-only | | `mint` | Builds a mint of USDp from a collateral (`collateral`, `amount`, `chain`, `receiver`, `slippageTolerance?`) | | `redeem` | Builds a redemption of USDp into one collateral | | `redeem_proportional` | Builds a redemption into the whole collateral basket, market-neutral | @@ -70,7 +70,7 @@ import { HelpFooter } from '@/components/HelpFooter' | `unstake` | On the `chain` that holds the position. With `amount`: builds the cooldown start. Without: builds the withdrawal of matured requests | | `claim_rewards` | Builds reward claims for sPRL1/sPRL2 on Base, paid in USDp, plus one on Polygon, paid in PAR, for the epochs published before the move to Base that can still be claimed | -New stakes go to Ethereum or Base: sPRL1, and the sPRL2 v2 vault, which replaced the paused v1 vault on Ethereum. sPRL1 on Polygon and Sonic is being sunset: a stake there is refused with `CHAIN_SUNSET`, while unstaking and withdrawing stay open and carry a `STAKING_SUNSET` warning. Every staking APR comes with an `aprNote`: a 0.00% means the last epoch distributed no rewards, not that a vault pays none. +New stakes go to Ethereum or Base: sPRL1, and the sPRL2 v2 vault, which replaced the paused v1 vault on Ethereum. sPRL1 on Polygon and Sonic is being sunset: the `stake` tool does not accept them, while unstaking and withdrawing stay open and carry a `STAKING_SUNSET` warning. Every staking APR comes with an `aprNote`: a 0.00% means the last epoch distributed no rewards, not that a vault pays none. ## Governance @@ -78,7 +78,7 @@ New stakes go to Ethereum or Base: sPRL1, and the sPRL2 v2 vault, which replaced |---|---| | `get_proposals` | Snapshot proposals (PIP/PGP/PIR), filterable by type and status | | `get_proposal_details` | One proposal in full, votes and result included | -| `get_protocol_parameters` | Contract addresses, governance roles, fees, collateral caps, bridge limits and `savingsFeeShare` (90% today, read on-chain, `null` when that read fails), in one JSON answer | +| `get_protocol_parameters` | Contract addresses, governance roles, fees, collateral caps, bridge limits and `savingsFeeShare` (read on-chain, `null` when that read fails), in one JSON answer | ## Agent payments (x402) From 57fb0d6dd73c2608c5e8f370a763761a0652ecf6 Mon Sep 17 00:00:00 2001 From: Johan Loutfi Date: Wed, 4 Nov 2026 12:36:15 +0100 Subject: [PATCH 13/21] docs(mcp): the transactions page corrects the response shapes and the cache list --- src/pages/agents/mcp/transactions.mdx | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/pages/agents/mcp/transactions.mdx b/src/pages/agents/mcp/transactions.mdx index b579b26..f9e3c0e 100644 --- a/src/pages/agents/mcp/transactions.mdx +++ b/src/pages/agents/mcp/transactions.mdx @@ -7,11 +7,11 @@ import { HelpFooter } from '@/components/HelpFooter' # How transactions work -The server prepares; **your wallet decides**. No write tool signs, broadcasts or custodies anything — each returns an **unsigned** transaction object you inspect, sign and submit yourself (from a wallet, a script, or an agent runtime). +The server prepares; **your wallet decides**. No write tool signs, broadcasts or custodies anything — each returns **unsigned** data you inspect, sign and submit yourself (from a wallet, a script, or an agent runtime). ## The transaction object -Every write tool returns the same shape — raw calldata, no signature anywhere in it: +The Parallelizer, savings and bridge tools return this shape — raw calldata, no signature anywhere in it: ```json { @@ -27,7 +27,7 @@ Every write tool returns the same shape — raw calldata, no signature anywhere - `to`, `data`, `value`, `chainId` — pass them to your wallet as-is. - `gas` is a best-effort estimate; it can be absent (for `bridge` the field is named `gasEstimate`). Never block on it — your wallet estimates anyway. -- Most tools return a single `tx` (plus an `approvalTx` when needed). Some staking flows return more: `stake` for sPRL2 returns an `approvalTxs` array and a `txs` array, and `claim_rewards` returns a `txs` array that can span several chains. Check whether you got `tx` or `txs`, and check each transaction's `chainId` before sending. +- `stake` for sPRL1 and `unstake` nest it under `tx`. Some staking flows return more: `stake` for sPRL2 returns an `approvalTxs` array and a `txs` array, and `claim_rewards` returns a `txs` array that can span several chains. Check whether you got `tx` or `txs`, and check each transaction's `chainId` before sending. ## Approvals @@ -45,7 +45,7 @@ The approval is **bounded**: the calldata grants exactly `approvalAmount` — th ## Pre-flight simulation -Every write is statically simulated before it reaches you: +Every transaction is statically simulated before it reaches you: - `simulation.success: false` comes with a `revertReason`. When the response bundles an `approvalTx`, a revert on allowance is the expected pre-approval state and is flagged `PENDING_APPROVAL` with severity `info` — submit the approval first, then the transaction. Any other revert is flagged `SIMULATION_FAILED` with severity `error`: the transaction would fail on-chain, don't send it. - `warnings[]` also surfaces business risks before you sign: an sPRL1 early-unstake penalty (`EARLY_UNSTAKE_PENALTY`), a ParaBoost about to be lost on unstake (`PARABOOST_LOST`) or locked on stake (`PARABOOST_LOCK`), or an unstake on Polygon or Sonic, where staking is being sunset (`STAKING_SUNSET`). @@ -54,19 +54,19 @@ Each warning has a `severity` (`info`, `warning`, `error`) and a human-readable ## When the server refuses -Impossible operations fail with a structured error code instead of doomed calldata: a sunset chain (`CHAIN_SUNSET`), a chain without a Parallelizer deployment (`PARALLELIZER_NOT_DEPLOYED`), a redeem or mint beyond the deposited collateral (`EXCEEDS_CAP`, with the remaining capacity), a bridge route that does not exist (`ROUTE_UNAVAILABLE` — same-chain, or a destination without a bridgeable token), a bridge amount above the daily capacity (`EXCEEDS_BRIDGE_LIMIT`, with the reset time), or an unknown collateral (`COLLATERAL_NOT_SUPPORTED`, with the valid list). +Impossible operations fail with a structured error code instead of doomed calldata: a sunset chain (`CHAIN_SUNSET`), a chain without a Parallelizer deployment (`PARALLELIZER_NOT_DEPLOYED`), a mint beyond the collateral cap or a redeem beyond the deposited collateral (`EXCEEDS_CAP`, with the remaining capacity), a bridge route that does not exist (`ROUTE_UNAVAILABLE` — same-chain, or a destination without a bridgeable token), a bridge amount above the daily capacity (`EXCEEDS_BRIDGE_LIMIT`, with the reset time), or an unknown collateral (`COLLATERAL_NOT_SUPPORTED`, with the valid list). ## Partial reads Multi-chain aggregates never fake completeness. When a chain read fails, the response carries `partial: true` and a `failedChains` list, and the totals exclude those chains — a lower bound, never a silently amputated number. Partial results are also never cached, so the next call retries the failed chains. -Some reads go further and refuse to answer at all rather than mislead — `get_proof_of_solvency` (a ratio computed on incomplete data could declare the protocol insolvent when it is not) and the savings rate reads, whose partial answer would be structurally wrong. These fail with a `PARTIAL_READ` error naming the chains that could not be read. +Some reads go further and refuse to answer at all rather than mislead — `get_proof_of_solvency` (a ratio computed on incomplete data could declare the protocol insolvent when it is not) and the savings rate reads when Ethereum, which the APY is computed on, cannot be read. These fail with a `PARTIAL_READ` error naming the chains that could not be read. **How to handle it:** `PARTIAL_READ` is transient — a retry a few seconds later usually succeeds. If it persists, `parallel_health_check` tells you which chain's RPCs are down. ## Data freshness -Read tools cache briefly: savings and exchange rates 30 s, TVL/supply/staking 60 s, collaterals and fees 120 s, chain list 5 min. Bridge status and history are always live. If an RPC degrades, the server serves the last known value for up to 10 minutes rather than failing. +Read tools cache briefly: savings and exchange rates 30 s, TVL/supply/staking 60 s, collaterals and fees 120 s. Bridge status and history are always live. If an RPC degrades, the server serves the last known value for up to 10 minutes rather than failing. ## Next steps From dffdb0d3be24abca73fb5e12e60889247e61fe87 Mon Sep 17 00:00:00 2001 From: Johan Loutfi Date: Wed, 4 Nov 2026 12:39:57 +0100 Subject: [PATCH 14/21] docs(cli): the wallet model covers pay engine, --address and pay prepare --- src/pages/agents/cli/index.mdx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/agents/cli/index.mdx b/src/pages/agents/cli/index.mdx index b93ee62..2ce4911 100644 --- a/src/pages/agents/cli/index.mdx +++ b/src/pages/agents/cli/index.mdx @@ -27,7 +27,7 @@ Requires Node.js ≥ 22. The package is MIT-licensed. ```bash parallel protocol overview # TVL, USDp supply, savings APY, solvency ratio parallel protocol tvl --chain base -parallel savings rate # protocol-wide sUSDp APY (~12% at the time of writing) +parallel savings rate # protocol-wide sUSDp APY ``` Optionally, set your defaults once — `parallel config init` walks you through it and writes `~/.parallel/config.toml`. @@ -52,7 +52,7 @@ Success envelopes print to stdout; error envelopes print to stderr, so stdout st ## The wallet model -The CLI never looks for a key unless you pass `--wallet`. Without it, nothing signs: add `--dry-run` to any transaction command and it prints the full unsigned transaction (add `--address ` to simulate for a real account instead of the zero address); with neither `--wallet` nor `--dry-run`, the command refuses with `WALLET_REQUIRED`. +The CLI never looks for a key unless you pass `--wallet`, or run `pay engine`, which signs with `$PARALLEL_PRIVATE_KEY`. Without it, nothing signs: add `--dry-run` to any transaction command and it prints the full unsigned transaction (add `--address ` to simulate for a real account instead of the zero address, which also prints it without `--dry-run`). With none of `--wallet`, `--dry-run` or `--address`, the command refuses with `WALLET_REQUIRED`. `pay prepare` never refuses: without a wallet it prints an unsigned payload. | You run | What happens | |---|---| From ffa4a04659a58faf18ef067f266b9b2feccd44e1 Mon Sep 17 00:00:00 2001 From: Johan Loutfi Date: Wed, 4 Nov 2026 12:40:05 +0100 Subject: [PATCH 15/21] docs(cli): drop the inert global flags and correct three error rows --- src/pages/agents/cli/commands.mdx | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/pages/agents/cli/commands.mdx b/src/pages/agents/cli/commands.mdx index e6f0f70..4f0eb07 100644 --- a/src/pages/agents/cli/commands.mdx +++ b/src/pages/agents/cli/commands.mdx @@ -18,8 +18,6 @@ Global flags, available across commands: | `--dry-run` | | Build the transaction without signing or broadcasting | | `--wallet [path\|env]` | `-w` | Sign and broadcast — see [the wallet model](/agents/cli#the-wallet-model) | | `--address <0x…>` | | Simulate a write for a real account without a wallet — works on swap, savings, staking and bridge write commands | -| `--no-cache` | | Bypass the read cache and force a fresh RPC call | -| `--verbose` | `-v` | Verbose logs | ## Protocol data @@ -143,10 +141,10 @@ Failures exit 1 and print `Error [CODE]: message`. In JSON mode the envelope `{ | `INVALID_AMOUNT` | Negative, zero, malformed or sub-decimal amount | | `UNKNOWN_CHAIN` | Chain identifier not recognised | | `CHAIN_SUNSET` | Operation not available on a sunset chain | -| `PARALLELIZER_NOT_DEPLOYED` | Mint, redeem and savings need a chain with a Parallelizer | +| `PARALLELIZER_NOT_DEPLOYED` | Mint and redeem need a chain with a Parallelizer | | `COLLATERAL_NOT_SUPPORTED` | Collateral (or bridge token) not accepted on this chain | -| `EXCEEDS_CAP` | Mint or redeem beyond the collateral's deposited capacity — the message carries the remaining capacity | -| `EXCEEDS_BRIDGE_LIMIT` | Daily or global bridge limit reached — the message carries the reset time | +| `EXCEEDS_CAP` | Mint beyond the collateral cap, or redeem beyond what is deposited — the message carries the remaining capacity | +| `EXCEEDS_BRIDGE_LIMIT` / `EXCEEDS_GLOBAL_LIMIT` | Daily or global bridge limit reached — the message carries the daily capacity left, or the global limit | | `ROUTE_UNAVAILABLE` | The bridge route does not exist (same chain, or no bridgeable token on the destination), or `pay prepare` cannot sign for the token: its signing domain matches no known version | | `PARTIAL_READ` | Some chain reads failed and the aggregate would be wrong — retry shortly | | `INSUFFICIENT_BALANCE` | Wallet balance too low for the requested amount | From 087d235743efb8f17ca8d90aa0f4498e34bc9e46 Mon Sep 17 00:00:00 2001 From: Johan Loutfi Date: Wed, 4 Nov 2026 12:42:58 +0100 Subject: [PATCH 16/21] docs(security): the x402 risks match the metered routes, gas and mcp approvals --- src/pages/security/risks.mdx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/pages/security/risks.mdx b/src/pages/security/risks.mdx index 3dc0154..7251e42 100644 --- a/src/pages/security/risks.mdx +++ b/src/pages/security/risks.mdx @@ -212,10 +212,10 @@ Off-chain services (the app, the MCP server, subgraphs, the proof-of-solvency da Parallel runs an **x402 facilitator**: an off-chain service that verifies an agent's signed payment, then settles it on-chain, so any API can charge AI agents per request. Two facts matter before you depend on it: -- **The facilitator is not audited and not open source.** The audits on the [audits page](/security/audits) (Bail Security, Cyfrin, Certora) cover the protocol smart contracts the settlement goes through, not the hosted service itself. The middleware, the agent SDK and the CLI are MIT-licensed on npm; the facilitator is a closed service operated by Parallel. +- **The facilitator is not audited and not open source.** The audits on the [audits page](/security/audits) (Bail Security, Cyfrin, Certora) cover the protocol smart contracts that fixed-price payments settle through, not the hosted service itself. The middleware, the agent SDK and the CLI are MIT-licensed on npm; the facilitator is a closed service operated by Parallel. - **It is a single dependency.** If it is down, slow (the SDK times out after 10 seconds on `verify` and 60 on `settle`, and retries a settle once when it timed out or could not reach the facilitator) or misbehaving, agents cannot pay and merchants cannot get paid until it recovers. -An agent can pay in USDp, USDC or sUSDp only, with gas sponsored on Base, HyperEVM and Avalanche (1,000 transactions per agent per month); on Ethereum it pays its own gas. A leaked agent key drains whatever that wallet holds, and a token-swapping settlement fails when the Parallelizer is paused (`PARALLELIZER_PAUSED`). +An agent can pay in USDp, USDC or sUSDp only, with gas sponsored on Base, HyperEVM and Avalanche (1,000 transactions per agent per month). A leaked agent key drains whatever that wallet holds, and a token-swapping settlement fails when the Parallelizer is paused (`PARALLELIZER_PAUSED`). The **MCP server** and **CLI** are a different dependency: the MCP server never signs, broadcasts or custodies anything, returning unsigned transactions for your wallet to sign, so the risk is signing something you did not read. The CLI with `--wallet` broadcasts immediately after signing, with no extra confirmation step. @@ -225,8 +225,8 @@ The **MCP server** and **CLI** are a different dependency: the MCP server never - **One settlement per payment.** The facilitator claims a payment before it submits anything, so the same payment never settles twice, and a settle repeated after a lost answer gets the recorded outcome instead of a second transfer. - **Non-custodial.** Funds settle straight to the merchant's `payTo` wallet: the facilitator never holds them, so there is nothing to withdraw or lose if it disappears; an unsettled authorization simply expires. - **Bounded authorizations.** Every payment carries an amount, a chain, an expiry and a nonce; replays, expired signatures and chain mismatches are rejected and each signer is rate-limited hourly. Verify also refuses a payload that does not have its route's shape, does not deliver the asset the merchant requires, or does not pay the merchant's `payTo`. See the [error codes page](/agents/x402/error-codes). -- **Audited settlement path.** The contracts that move tokens are the audited protocol contracts; gas sponsoring alone cannot move funds. -- **Unsigned by design.** Every MCP write tool simulates the transaction and returns `simulation.success`, a revert reason on failure, and business warnings before you sign, such as the staking warnings in section 7. See [how MCP transactions work](/agents/mcp/transactions). +- **Audited settlement path.** On fixed-price routes, the contracts that move tokens are the audited protocol contracts; gas sponsoring alone cannot move funds. +- **Unsigned by design.** Every MCP transaction tool simulates the transaction and returns `simulation.success`, a revert reason on failure, and business warnings before you sign, such as the staking warnings in section 7. See [how MCP transactions work](/agents/mcp/transactions). ### What you can do @@ -234,7 +234,7 @@ The **MCP server** and **CLI** are a different dependency: the MCP server never - **Confirm settlement yourself.** Merchant [webhooks](/agents/x402/webhooks) are on the roadmap, not live: read the `payment-response` header (it carries the on-chain `txHash`) or watch your `payTo` wallet before treating a request as paid. - **Handle the facilitator being down.** Catch `FACILITATOR_UNAVAILABLE` and `FACILITATOR_INVALID_RESPONSE` (and `SETTLE_TIMEOUT` when you call the facilitator client yourself) and decide whether to fail closed or serve unpaid. Behind the middleware, a failed settlement answers the agent `402` with `PAYMENT_SETTLEMENT_FAILED` and a `reason`; alert on `AMOUNT_MISMATCH`, which means a metered settlement was confirmed for another amount than the one asked. - **Treat the facilitator as a vendor.** If your business cannot tolerate an unaudited hosted service, settle against the audited contracts yourself. -- **Read before you sign.** Inspect the `to`, `chainId`, `value` and warnings of every transaction an MCP client shows you, and replace the default unlimited approval with an exact one if you prefer. +- **Read before you sign.** Inspect the `to`, `chainId`, `value` and warnings of every transaction an MCP client shows you. ## 10. Regulatory note From fa389db3d74dd29f35c16b02ae63f4623df432c0 Mon Sep 17 00:00:00 2001 From: Johan Loutfi Date: Wed, 4 Nov 2026 12:54:26 +0100 Subject: [PATCH 17/21] docs(x402): the escrow approval is renewed once payments use it up --- src/pages/agents/x402/api-reference.mdx | 2 +- src/pages/agents/x402/concepts.mdx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/agents/x402/api-reference.mdx b/src/pages/agents/x402/api-reference.mdx index fad7660..7829735 100644 --- a/src/pages/agents/x402/api-reference.mdx +++ b/src/pages/agents/x402/api-reference.mdx @@ -81,7 +81,7 @@ On Base, a metered route can also accept USDC from standard x402 clients that su List the network's USDC in `acceptedTokens`, for example `[PARALLEL_TOKENS.base.usdc, PARALLEL_TOKENS.base.usdp]`. The `402` then lists the USDC entry first, with its EIP-712 domain and the escrow as `facilitatorAddress`. It also declares the `eip2612GasSponsoring` extension, so a client whose Permit2 allowance for USDC falls short can sign an EIP-2612 permit with the payment. -Before you list USDC, approve the escrow for USDC from the `payTo` address, with an ERC-20 `approve`. Its address is `getUptoEscrowAddress("base")` from `@parallel-protocol/chains`, `0xc3F4de61381A05ED7FBE61c8327B45507BA87F26`. The escrow takes back each USDC charge to convert it, so every payment uses up that much of the allowance. A payment whose cap the remaining allowance does not cover is refused at verify with `MERCHANT_NOT_ENABLED`. Receive on a dedicated address rather than a treasury, since it bounds what the approval exposes. +Before you list USDC, approve the escrow for USDC once from the `payTo` address, with an ERC-20 `approve`. Its address is `getUptoEscrowAddress("base")` from `@parallel-protocol/chains`, `0xc3F4de61381A05ED7FBE61c8327B45507BA87F26`. Each payment uses up the USDC it converts from that allowance: when what is left falls below the route's cap, approve again. Until then, and before the first approval, these payments are refused at verify with `MERCHANT_NOT_ENABLED`. Receive on a dedicated address rather than a treasury, since it bounds what the approval exposes. On such a route, `price` must be a decimal string such as `"2"`, and so must the amount a `meter` returns. The receipt gives the USDC charged in `amountSettled`, and the USDp the merchant received in `amountDelivered` when the facilitator could read it from the settlement. `@parallel-protocol/x402-fetch` does not pay the USDC entry. It pays the USDp entry of the same invoice, through route U. diff --git a/src/pages/agents/x402/concepts.mdx b/src/pages/agents/x402/concepts.mdx index d183694..0f9bf9b 100644 --- a/src/pages/agents/x402/concepts.mdx +++ b/src/pages/agents/x402/concepts.mdx @@ -41,7 +41,7 @@ Standard x402 clients that support the `upto` scheme, such as AgentCash, can pay To accept them: -1. From your `payTo` address, approve the escrow for Base USDC with an ERC-20 `approve`. The escrow is `0xc3F4de61381A05ED7FBE61c8327B45507BA87F26`, which `getUptoEscrowAddress("base")` returns in `@parallel-protocol/chains` 0.6.0. It takes back each USDC charge to convert it, so every payment uses up that much of the allowance. A payment whose cap the remaining allowance does not cover is refused at verify with `MERCHANT_NOT_ENABLED`. Use a dedicated receiving address, since it limits what the approval exposes. +1. From your `payTo` address, approve the escrow for Base USDC once with an ERC-20 `approve`. The escrow is `0xc3F4de61381A05ED7FBE61c8327B45507BA87F26`, which `getUptoEscrowAddress("base")` returns in `@parallel-protocol/chains` 0.6.0. Each payment uses up the USDC it converts from that allowance: when what is left falls below the route's cap, approve again. Until then, and before the first approval, these payments are refused at verify with `MERCHANT_NOT_ENABLED`. Use a dedicated receiving address, since it limits what the approval exposes. 2. List `PARALLEL_TOKENS.base.usdc` in the route's `acceptedTokens`, next to `PARALLEL_TOKENS.base.usdp` for agents on the Parallel client. Write the price as a decimal string such as `"0.01"`: with USDp and USDC on the same route, a `bigint` price is refused at startup with `X402ConfigError`. The `402` then lists the USDC entry first, with what these clients need to sign. The receipt gives the USDC charged in `amountSettled`, and the USDp you received in `amountDelivered` when the facilitator could read it from the settlement. From 49321afd4cca17468f73ca0a561a9c7cd8f036ec Mon Sep 17 00:00:00 2001 From: Johan Loutfi Date: Fri, 6 Nov 2026 11:02:18 +0100 Subject: [PATCH 18/21] docs(x402): align the pages with x402 0.10.1 --- src/pages/agents/recipes/migrate-from-coinbase-x402.mdx | 2 +- src/pages/agents/x402/api-reference.mdx | 2 +- src/pages/agents/x402/error-codes.mdx | 4 +++- src/pages/agents/x402/quickstart.mdx | 2 +- src/pages/agents/x402/verify-vs-settle.mdx | 2 +- 5 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/pages/agents/recipes/migrate-from-coinbase-x402.mdx b/src/pages/agents/recipes/migrate-from-coinbase-x402.mdx index 7072d4c..f686cab 100644 --- a/src/pages/agents/recipes/migrate-from-coinbase-x402.mdx +++ b/src/pages/agents/recipes/migrate-from-coinbase-x402.mdx @@ -69,7 +69,7 @@ app.use(paymentMiddleware({ })); ``` -Install `@parallel-protocol/x402` 0.10.0 or later. It is the first version that takes payments from Coinbase x402 clients, on metered routes. A version before 0.8.0 no longer settles anything: since 1 October 2026 the facilitator refuses a settle that does not present the token it issued at verify. Version 0.8.1 adds the URL checks below. +Install `@parallel-protocol/x402` 0.10.1 or later. Version 0.10.0 is the first that takes payments from Coinbase x402 clients, on metered routes, and 0.10.1 stops a request from reaching a paid route unpaid through another form of its path. A version before 0.8.0 no longer settles anything: since 1 October 2026 the facilitator refuses a settle that does not present the token it issued at verify. Version 0.8.1 adds the URL checks below. Keep the facilitator's URL in https, as above. Since 0.8.1, the SDK refuses a plain http URL outside `localhost`, `127.0.0.1` and `[::1]` with an `X402ConfigError` when the middleware is created. It calls that address only and never follows a redirect, which fails the call with `FACILITATOR_UNAVAILABLE`. diff --git a/src/pages/agents/x402/api-reference.mdx b/src/pages/agents/x402/api-reference.mdx index 7829735..453e433 100644 --- a/src/pages/agents/x402/api-reference.mdx +++ b/src/pages/agents/x402/api-reference.mdx @@ -10,7 +10,7 @@ import { HelpFooter } from '@/components/HelpFooter' Reference for the `@parallel-protocol/x402` package: configuration, framework adapters, and the lower-level facilitator client. :::warning -Use version 0.8.2 or later. Since 1 October 2026 the facilitator settles a payment only when the settle presents the token it issued at verify, which the SDK sends from 0.8.0: with 0.7.x or earlier, every settlement is refused with `SETTLE_TOKEN_REQUIRED`. Accepting USDC on a metered route needs version 0.10.0 or later. +Use version 0.10.1 or later: in earlier versions a request could reach a paid route unpaid through another form of its path. Since 1 October 2026 the facilitator settles a payment only when the settle presents the token it issued at verify, which the SDK sends from 0.8.0: with 0.7.x or earlier, every settlement is refused with `SETTLE_TOKEN_REQUIRED`. Accepting USDC on a metered route needs version 0.10.0 or later. ::: ## Configuration diff --git a/src/pages/agents/x402/error-codes.mdx b/src/pages/agents/x402/error-codes.mdx index d03762f..d7e0d1b 100644 --- a/src/pages/agents/x402/error-codes.mdx +++ b/src/pages/agents/x402/error-codes.mdx @@ -8,7 +8,7 @@ import { HelpFooter } from '@/components/HelpFooter' # Error codes :::warning -Since 1 October 2026 the facilitator settles a payment only when the settle presents the token it issued at verify. `@parallel-protocol/x402` sends it from version 0.8.0. A merchant on 0.7.x or earlier sees every settlement refused with `SETTLE_TOKEN_REQUIRED`: the agent gets a `402` instead of the response, and the merchant is never paid. Use 0.8.2 or later. +Since 1 October 2026 the facilitator settles a payment only when the settle presents the token it issued at verify. `@parallel-protocol/x402` sends it from version 0.8.0. A merchant on 0.7.x or earlier sees every settlement refused with `SETTLE_TOKEN_REQUIRED`: the agent gets a `402` instead of the response, and the merchant is never paid. Use 0.10.1 or later. ::: ## Thrown by the SDK @@ -30,6 +30,8 @@ Since 1 October 2026 the facilitator settles a payment only when the settle pres An `X402RuntimeError` also carries the facilitator's text in `.detail`, its HTTP status in `.status` (the redirect's status for a redirect), and its `Retry-After` in `.retryAfter` when it sent one. +From version 0.10.1, a request whose path has `.` or `..` segments gets a `400` with `{ error: "INVALID_PATH", message }` when it reaches a paid route, before any invoice, since routers and proxies do not all resolve these segments. The agent should send the path resolved. + ## Refused at verify When the facilitator refuses a payment at verify, your handler does not run and nothing moves. The middleware re-issues a `402` with a new invoice: the facilitator's code is the `error` field, its text the `message` field, and its `Retry-After` header is copied whenever it sent one. The facilitator's own status is the `.status` of the error when you call the [`FacilitatorClient`](/agents/x402/api-reference#facilitatorclient) yourself. diff --git a/src/pages/agents/x402/quickstart.mdx b/src/pages/agents/x402/quickstart.mdx index 962c1a3..a10e00e 100644 --- a/src/pages/agents/x402/quickstart.mdx +++ b/src/pages/agents/x402/quickstart.mdx @@ -17,7 +17,7 @@ npm install @parallel-protocol/x402 ``` :::warning -Use version 0.8.2 or later, and 0.10.0 or later to take USDC from standard x402 clients on metered routes. Since 1 October 2026 the facilitator settles a payment only when the settle presents the token it issued at verify, and versions before 0.8.0 do not send it: their settlements are refused with `SETTLE_TOKEN_REQUIRED`, and the agent gets a `402` instead of your response. Version 0.8.1 adds the facilitator URL checks of step 2, and 0.8.2 tells the agent to check with you before paying again for the reasons listed in the error codes. +Use version 0.10.1 or later: in earlier versions a request could reach a paid route unpaid through another form of its path, such as `/API/data` on Express or `/api/dat%61` on Fastify. Since 1 October 2026 the facilitator settles a payment only when the settle presents the token it issued at verify, and versions before 0.8.0 do not send it: their settlements are refused with `SETTLE_TOKEN_REQUIRED`, and the agent gets a `402` instead of your response. Version 0.8.1 adds the facilitator URL checks of step 2, and 0.8.2 tells the agent to check with you before paying again for the reasons listed in the error codes. ::: Install your framework separately. It is an optional peer dependency: Express 4 or 5, Next.js 14 or 15, Fastify 5.12.7 or a later 5.x, or Hono 4. diff --git a/src/pages/agents/x402/verify-vs-settle.mdx b/src/pages/agents/x402/verify-vs-settle.mdx index ccbf7a7..0cde540 100644 --- a/src/pages/agents/x402/verify-vs-settle.mdx +++ b/src/pages/agents/x402/verify-vs-settle.mdx @@ -45,7 +45,7 @@ Agent Merchant (the SDK) Facilitator - **One payment, one settlement.** The facilitator claims the payment before it submits anything, so two settles of the same payment never both reach the chain. A settle repeated once the first one has finished gets its recorded outcome: the confirmation, marked `alreadySettled`, the failure's own code when the payment may have gone through (`AUTHORIZATION_USED`, `RECEIPT_UNAVAILABLE`, `SUBMISSION_FAILED`), or `PAYMENT_NOT_VERIFIED` after any other failure. - **Concurrent payments do not collide.** On each chain, the facilitator sends its settlement transactions one at a time, so payments settled together each get their own transaction. - **A failed settlement discards the response and says why.** The middleware returns `402` instead of your handler's output, with a `reason` that tells the agent whether to sign a new payment or to check with you first. See [settlement failures](/agents/x402/error-codes#settlement-failures). -- **CORS preflight passes through.** `OPTIONS` requests are never challenged. +- **CORS preflight passes through.** `OPTIONS` requests are never challenged. On a paid route, only the status code and the `Access-Control-*`, `Vary` and `Allow` headers of your answer go out. On Next.js the preflight gets an empty `204` without running your handler, so set its CORS headers in `next.config.js`. - **Standard x402 clients are translated.** On a metered route that lists USDC, a standard x402 client sends its own Permit2 payment format. The middleware translates it into the facilitator's format before verify and settle. The facilitator rebuilds the Permit2 message from it and checks the payer's signature, so a mistranslated field fails verification. ## Settlement routes From 3602b3fb63d9dfef6a866667825dc9817a0e4a72 Mon Sep 17 00:00:00 2001 From: Johan Loutfi Date: Fri, 6 Nov 2026 11:06:46 +0100 Subject: [PATCH 19/21] docs(x402): note the route key check and the normalized matching of 0.10.1 --- src/pages/agents/x402/api-reference.mdx | 2 +- src/pages/agents/x402/error-codes.mdx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/agents/x402/api-reference.mdx b/src/pages/agents/x402/api-reference.mdx index 453e433..116f299 100644 --- a/src/pages/agents/x402/api-reference.mdx +++ b/src/pages/agents/x402/api-reference.mdx @@ -45,7 +45,7 @@ interface PaymentMiddlewareConfig { | `maxTimeoutSeconds` | `number` | No | Settlement window announced to the payer, 300 by default. On a metered route it is 3,600 at most: a larger value throws `X402ConfigError` at startup. On metered routes, Express, Hono and Next.js give the handler this window minus two minutes, kept for the settlement and its retry, and 30 seconds at least. Fastify does not time handlers out. | | `meter` | `(ctx) => string \| bigint \| null \| undefined \| Promise` | No | Metered routes only: reads the amount to charge from the handler's response. On a route that accepts tokens with different decimals, it must return a string, since a `bigint` is refused like a failing meter. See [metered routes](#metered-routes-upto). | -Route matching is **longest-prefix-wins**: `/api/v1/users` matches a `/api/v1` config before a `/api` one. +Route matching is **longest-prefix-wins**: `/api/v1/users` matches a `/api/v1` config before a `/api` one. From version 0.10.1, the request path and the keys are compared once normalized, so case, percent-encoding and repeated slashes make no difference: a free route that is another form of a paid one, such as `/Reports/q1` next to a paid `/reports/q1`, is charged. ### Metered routes (`upto`) diff --git a/src/pages/agents/x402/error-codes.mdx b/src/pages/agents/x402/error-codes.mdx index d7e0d1b..78c5f60 100644 --- a/src/pages/agents/x402/error-codes.mdx +++ b/src/pages/agents/x402/error-codes.mdx @@ -15,7 +15,7 @@ Since 1 October 2026 the facilitator settles a payment only when the settle pres | Error class | When | |---|---| -| `X402ConfigError` | Invalid config, with a message that names the field at fault. At middleware setup: no route, bad `payTo`, a price that is malformed or not positive, a facilitator URL that is malformed or not https (plain http is accepted only for `localhost`, `127.0.0.1` and `[::1]`), a `meter` on a route that is not metered, a metered route with `maxTimeoutSeconds` above 3,600, a metered route that lists a token other than the network's USDp and Base USDC, a `bigint` price or a `decimals` on a metered route whose tokens have different decimals, or, from version 0.8.3, a `network` of the Parallel catalog other than `ethereum`, `base`, `avalanche` and `hyperevm`, such as Sonic. At the first request on a route: an unknown network with no `acceptedTokens`, an unknown token with no `decimals`, a price below the token's precision, or a price function that throws or does not return a price. | +| `X402ConfigError` | Invalid config, with a message that names the field at fault. At middleware setup: no route, bad `payTo`, a price that is malformed or not positive, a facilitator URL that is malformed or not https (plain http is accepted only for `localhost`, `127.0.0.1` and `[::1]`), a `meter` on a route that is not metered, a metered route with `maxTimeoutSeconds` above 3,600, a metered route that lists a token other than the network's USDp and Base USDC, a `bigint` price or a `decimals` on a metered route whose tokens have different decimals, two route keys that are the same path once normalized, such as `/api/data` and `/API/data/`, with different configs (from version 0.10.1), or, from version 0.8.3, a `network` of the Parallel catalog other than `ethereum`, `base`, `avalanche` and `hyperevm`, such as Sonic. At the first request on a route: an unknown network with no `acceptedTokens`, an unknown token with no `decimals`, a price below the token's precision, or a price function that throws or does not return a price. | | `X402PriceRejectedError` | Thrown by your price function to refuse a request before anything is invoiced. The client gets its `status`, 400 by default, with `{ error: code, message }`. | | `X402RuntimeError` | A runtime failure. The specific cause is in `.code` (below). | From 82c9ce72a6c84283a62799dd265edd443bbab82d Mon Sep 17 00:00:00 2001 From: Johan Loutfi Date: Fri, 6 Nov 2026 11:14:26 +0100 Subject: [PATCH 20/21] docs(x402): note the Next.js cookies on a refusal and the HANDLER_TIMEOUT answer --- src/pages/agents/x402/error-codes.mdx | 2 ++ src/pages/agents/x402/verify-vs-settle.mdx | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/pages/agents/x402/error-codes.mdx b/src/pages/agents/x402/error-codes.mdx index 78c5f60..71cc919 100644 --- a/src/pages/agents/x402/error-codes.mdx +++ b/src/pages/agents/x402/error-codes.mdx @@ -32,6 +32,8 @@ An `X402RuntimeError` also carries the facilitator's text in `.detail`, its HTTP From version 0.10.1, a request whose path has `.` or `..` segments gets a `400` with `{ error: "INVALID_PATH", message }` when it reaches a paid route, before any invoice, since routers and proxies do not all resolve these segments. The agent should send the path resolved. +A handler that does not answer in time gets a `504` with `{ error: "HANDLER_TIMEOUT", message }` on Express and Hono, and an empty `504` on Next.js. Nothing is settled. + ## Refused at verify When the facilitator refuses a payment at verify, your handler does not run and nothing moves. The middleware re-issues a `402` with a new invoice: the facilitator's code is the `error` field, its text the `message` field, and its `Retry-After` header is copied whenever it sent one. The facilitator's own status is the `.status` of the error when you call the [`FacilitatorClient`](/agents/x402/api-reference#facilitatorclient) yourself. diff --git a/src/pages/agents/x402/verify-vs-settle.mdx b/src/pages/agents/x402/verify-vs-settle.mdx index 0cde540..4419461 100644 --- a/src/pages/agents/x402/verify-vs-settle.mdx +++ b/src/pages/agents/x402/verify-vs-settle.mdx @@ -44,7 +44,7 @@ Agent Merchant (the SDK) Facilitator - **The SDK talks to the facilitator only.** From 0.8.1 it calls the facilitator at its configured https address and never follows a redirect, so the payment, the settle token and the API key never reach another address. - **One payment, one settlement.** The facilitator claims the payment before it submits anything, so two settles of the same payment never both reach the chain. A settle repeated once the first one has finished gets its recorded outcome: the confirmation, marked `alreadySettled`, the failure's own code when the payment may have gone through (`AUTHORIZATION_USED`, `RECEIPT_UNAVAILABLE`, `SUBMISSION_FAILED`), or `PAYMENT_NOT_VERIFIED` after any other failure. - **Concurrent payments do not collide.** On each chain, the facilitator sends its settlement transactions one at a time, so payments settled together each get their own transaction. -- **A failed settlement discards the response and says why.** The middleware returns `402` instead of your handler's output, with a `reason` that tells the agent whether to sign a new payment or to check with you first. See [settlement failures](/agents/x402/error-codes#settlement-failures). +- **A failed settlement discards the response and says why.** The middleware returns `402` instead of your handler's output, with a `reason` that tells the agent whether to sign a new payment or to check with you first. On Next.js, cookies set with `cookies()` from `next/headers` still go out with the `402`, since Next adds them to any response: set the cookies of a paid response on the `NextResponse` you return. See [settlement failures](/agents/x402/error-codes#settlement-failures). - **CORS preflight passes through.** `OPTIONS` requests are never challenged. On a paid route, only the status code and the `Access-Control-*`, `Vary` and `Allow` headers of your answer go out. On Next.js the preflight gets an empty `204` without running your handler, so set its CORS headers in `next.config.js`. - **Standard x402 clients are translated.** On a metered route that lists USDC, a standard x402 client sends its own Permit2 payment format. The middleware translates it into the facilitator's format before verify and settle. The facilitator rebuilds the Permit2 message from it and checks the payer's signature, so a mistranslated field fails verification. From 4a94377d2eeb3ba6d7c5d14612cb9740ccb749a7 Mon Sep 17 00:00:00 2001 From: Johan Loutfi Date: Thu, 12 Nov 2026 10:47:36 +0100 Subject: [PATCH 21/21] docs(agents): the verify refusals of every route since the settle is simulated --- src/pages/agents/x402/concepts.mdx | 2 +- src/pages/agents/x402/error-codes.mdx | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/pages/agents/x402/concepts.mdx b/src/pages/agents/x402/concepts.mdx index 0f9bf9b..d977d16 100644 --- a/src/pages/agents/x402/concepts.mdx +++ b/src/pages/agents/x402/concepts.mdx @@ -15,7 +15,7 @@ You declare paid routes in your middleware; the facilitator handles the rest. Every paid request goes through two phases: -1. **Verify**: the facilitator checks the agent's signed payment without sending a transaction. It checks its shape, signature, nonce and expiry, and that it delivers the required token, for at least the price, to your `payTo` on the route's network. It refuses a payment whose conversion would go through a paused Parallelizer or savings vault. On a metered route paid in USDp, it checks that the payer holds the cap. On a metered route paid in USDC through Permit2, it simulates the settlement at the cap. If the payment is valid, the facilitator hands the middleware a settle token for it, and your handler runs. +1. **Verify**: the facilitator checks the agent's signed payment without sending a transaction. It checks its shape, signature, nonce and expiry, and that it delivers the required token, for at least the price, to your `payTo` on the route's network. It refuses a payment whose conversion would go through a paused Parallelizer or savings vault. It simulates the settlement, at the cap on a metered route, and refuses a payment whose settlement would fail. If the payment is valid, the facilitator hands the middleware a settle token for it, and your handler runs. 2. **Settle**: once your handler returns a success response, the middleware presents that token, and the facilitator submits the transfer on-chain and returns a settlement proof. If verification fails, your handler never runs. If your handler fails, settlement never happens — the agent is only charged for a successful response. See [verify vs settle](/agents/x402/verify-vs-settle) for the full sequence. diff --git a/src/pages/agents/x402/error-codes.mdx b/src/pages/agents/x402/error-codes.mdx index 71cc919..cf1769d 100644 --- a/src/pages/agents/x402/error-codes.mdx +++ b/src/pages/agents/x402/error-codes.mdx @@ -42,26 +42,28 @@ When the facilitator refuses a payment at verify, your handler does not run and |---|---|---|---| | `INVALID_PAYLOAD` | 400 | The payload does not have the shape of its settlement route, carries a field another route would read, uses a method of the other scheme, or names a token, escrow or proxy its route does not take. On a payment through Permit2, also an EIP-2612 permit that is not for the cap or ends before the Permit2 deadline. | Sign a payment that matches one of the `accepts` entries. | | `INVALID_SIGNATURE` | 400 | Signature recovery failed. On a payment through Permit2, also the payer's contract wallet or Permit2 refusing the signature. | Sign again. | -| `INVALID_NONCE` | 409 | Nonce already used: the same payment reached the facilitator before, and may have settled. | Do not sign another payment before checking with the merchant. | +| `INVALID_NONCE` | 409 | Nonce already used, at the facilitator or on-chain: the payment may have settled. | Do not sign another payment before checking with the merchant. | | `PAYMENT_EXPIRED` | 402 | The authorization's `validBefore` has passed. | Sign a new payment. | -| `PAYMENT_NOT_YET_VALID` | 402 | A payment through Permit2 whose `validAfter` has not passed yet. | Sign again with a `validAfter` in the past. | +| `PAYMENT_NOT_YET_VALID` | 402 | The authorization's `validAfter` has not passed yet. | Sign again with a `validAfter` in the past. | | `INSUFFICIENT_AMOUNT` | 402 | The amount the route guarantees the merchant is below the price: the signed amount on a transfer, the guaranteed output (`amountOut` or `amountOutMin`) on a conversion. Also an authorization for zero. | Sign for the invoiced `amount`. | -| `INSUFFICIENT_BALANCE` | 402 | The payer does not hold the signed amount. Checked on metered payments, against the cap. | Fund the wallet, sign a new payment. | +| `INSUFFICIENT_BALANCE` | 402 | The payer does not hold the signed amount, or on a metered payment the cap. | Fund the wallet, sign a new payment. | | `ASSET_MISMATCH` | 400 | The route does not deliver the token the merchant requires. | Pay so that the merchant receives one of the `accepts` assets. | | `RECIPIENT_MISMATCH` | 400 | The signed recipient is not the merchant's `payTo`. | Sign to the invoiced `payTo`. | | `NETWORK_MISMATCH` | 400 | The facilitator does not support the payload's chain, or it is not the route's chain. | Sign on the invoiced network. | | `WINDOW_TOO_LONG` | 400 | A metered authorization valid for more than 3,600 seconds. | Sign again with a `validBefore` within the hour. | +| `WINDOW_TOO_SHORT` | 400 | The authorization ends too soon for the handler to run and the payment to settle. | Sign again with a later `validBefore`. | | `PAYMENT_METHOD_NOT_SUPPORTED` | 400 | No settlement route for this method or token on this chain, including a metered payment on a chain without the escrow. | Pay with another method or token. | | `COLLATERAL_NOT_SUPPORTED` | 400 | The swap delivers a token that is not a collateral of the chain. | Pay for another of the `accepts` assets. | -| `RATE_LIMIT_EXCEEDED` | 429 | The payer passed 1,000 verifies in the current UTC hour. A verify counts once its signature and payment checks pass, even when it is refused after that, because a swap or the savings vault is paused, or another verify reserved the same nonce first. | Pay again after `Retry-After`, which points to the next hour. | +| `RATE_LIMIT_EXCEEDED` | 429 | The payer passed 1,000 verifies in the current UTC hour. A verify counts once its signature and payment checks pass, even when it is refused after that, because its settlement would fail, or another verify reserved the same nonce first. | Pay again after `Retry-After`, which points to the next hour. | | `PARALLELIZER_PAUSED` | 503 | The Parallelizer has paused the swap this route needs, or the facilitator could not read whether it has. Nothing was taken. | Pay with another token, or pay again later. | | `SAVINGS_PAUSED` | 503 | The sUSDp savings vault the payment deposits into or redeems from is paused, or the facilitator could not read whether it is. Nothing was taken. | Pay with another token, or pay again later. | | `SERVICE_UNAVAILABLE` | 503 | The facilitator could not read the chain or its own store. | Pay again after a short wait. | | `PERMIT2_ALLOWANCE_REQUIRED` | 412 | A payment through Permit2 from a payer whose Permit2 approval for the token is below the cap, with no EIP-2612 permit or one the token refused. The message starts with `permit2_allowance_required`, the reason standard x402 clients look for. | Approve Permit2 for the token, or sign the payment with an EIP-2612 permit. | | `TOKEN_BLOCKED` | 403 | A payment through Permit2 that the token refuses: the payer or the merchant is blacklisted, or the token is paused. Nothing was taken. | Pay with another token. | | `MERCHANT_NOT_ENABLED` | 503 | A USDC payment through Permit2 to a merchant whose USDC allowance to the escrow does not cover the cap, so the escrow cannot convert it. Nothing was taken. | Pay with USDp, or pay again later. | -| `SWAP_UNAVAILABLE` | 503 | The Parallelizer cannot convert the USDC of a payment through Permit2 now, for instance because a cap is reached or a price feed is stale. Nothing was taken. | Pay with USDp, or pay again later. | -| `SETTLEMENT_WOULD_FAIL` | 402 | A payment through Permit2 whose settlement, simulated at verify, would revert for another reason. Nothing was taken. | Pay with another token, or sign a new payment later. | +| `SWAP_PRICE_MOVED` | 402 | The swap's price or fee moved beyond the margin signed with the payment. Nothing was taken. | Sign a new payment. | +| `SWAP_UNAVAILABLE` | 503 | The Parallelizer cannot make the payment's conversion now, for instance because a cap is reached or a price feed is stale. Nothing was taken. | Pay with another token, or pay again later. | +| `SETTLEMENT_WOULD_FAIL` | 402 | A payment whose settlement, simulated at verify, would revert for another reason. Nothing was taken. | Pay with another token, or sign a new payment later. | An `error` from the facilitator that is not a code (capitals, digits and underscores) is not forwarded: the `402` carries `FACILITATOR_INVALID_RESPONSE` with the facilitator's message instead. That is the case of its per-IP rate limit, status 429 (see [rate limits](#rate-limits)), of a payload that does not match its request schema, status 400, and of a request body above 64 KB, status 413, which a payment forwarded by the middleware stays well below.