> For the complete documentation index, see [llms.txt](https://fourohtwo.gitbook.io/fourohtwo-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://fourohtwo.gitbook.io/fourohtwo-docs/reference/payment-flow.md). Agents can also search and read this documentation through its [MCP server](https://fourohtwo.gitbook.io/fourohtwo-docs/~gitbook/mcp).

# Payment flow

Every API on Fourohtwo is an x402 endpoint at `https://fourohtwo.xyz/x/<name>`.

## Parameters

Agents can pay with either of two stablecoins. The `402` lists every option that is open right now in `accepts`; pay with whichever your wallet holds.

| Field          | Robinhood Chain                                   | Base                                              |
| -------------- | ------------------------------------------------- | ------------------------------------------------- |
| Scheme         | `exact`                                           | `exact`                                           |
| Network        | `eip155:4663` (also `robinhood`)                  | `eip155:8453` (also `base`)                       |
| Asset          | USDG `0x5fc5360D0400a0Fd4f2af552ADD042D716F1d168` | USDC `0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913` |
| Decimals       | 6                                                 | 6                                                 |
| EIP-712 domain | name `Global Dollar`, version `1`, chain 4663     | name `USD Coin`, version `2`, chain 8453          |
| Authorization  | EIP-3009 `TransferWithAuthorization`              | EIP-3009 `TransferWithAuthorization`              |

Both coins are priced 1:1, so an API that costs 0.01 costs 0.01 USDG or 0.01 USDC. Base is only listed while the settlement wallet has gas there.

## Sequence

1. **Quote.** A request without payment returns `402` with a JSON body and a `PAYMENT-REQUIRED` header (base64 of the same body). Each entry in `accepts` holds the price (`amount`, also `maxAmountRequired`), `payTo`, `asset` and `extra.payOnSuccess: true`.
2. **Sign.** The client signs `TransferWithAuthorization` for at least the price and sends the request again with the payload in `PAYMENT-SIGNATURE` (v2) or `X-PAYMENT` (v1), base64-encoded.
3. **Check.** Fourohtwo verifies the signature, the recipient, the amount, the time window and the agent's spending rules, then checks on-chain that the nonce is unused and the balance covers it.
4. **Call.** The request is forwarded to the API.
5. **Settle.** Only if the API answers with a 2xx does Fourohtwo submit the transfer on the chain you paid on. The response is returned with a `PAYMENT-RESPONSE` header containing the transaction hash.

If the API fails, the authorization is never submitted and the response carries `X-Fourohtwo-Charged: false`.

Each authorization nonce can be used once, even under concurrent requests.

## Free trial calls

Every wallet gets **5 free calls** on Fourohtwo's own APIs (`/x/<name>`). Instead of paying, the agent proves it controls a wallet with a [Sign-In-With-X](https://github.com/x402-foundation/x402) signature. Nothing is transferred and no gas is needed.

1. The `402` carries a `sign-in-with-x` extension (an EIP-4361 challenge with `domain`, `uri`, `nonce`, `issuedAt`, `expirationTime` and the supported chains `eip155:8453` and `eip155:4663`) and a `fourohtwo-free-trial` extension with the number of free calls.
2. The agent signs the message and sends the request again with the signed payload, base64-encoded JSON, in the `SIGN-IN-WITH-X` header.
3. The API answers as usual, with `X-Fourohtwo-Charged: false` and `X-Fourohtwo-Free-Trial-Remaining`.

A call that fails does not use up a free call. Each signed challenge works once and expires after five minutes. Free calls are limited per network address per day and in total per day; when they run out, the `402` explains why (`free_trial_used`, `free_trial_ip_limit` or `free_trial_sold_out`) and the agent pays as normal. APIs launched by creators don't offer free calls.

The SDK (`fourohtwo` 0.2.1 and later) and the MCP server use free calls automatically before paying. Any x402 client with Sign-In-With-X support does the same.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://fourohtwo.gitbook.io/fourohtwo-docs/reference/payment-flow.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
