# x402-sdk

**GitHub:** [fastxyz/fast-sdk](https://github.com/fastxyz/fast-sdk/blob/main/README.md)

## What You Can Do

* **Pay-per-request APIs** — charge for individual API calls using HTTP 402
* **No accounts needed** — just sign and pay
* **Multi-chain** — Fast (instant), Arbitrum, Base, Ethereum

## Installation

```bash
npm install @fastxyz/x402-client @fastxyz/x402-server @fastxyz/x402-facilitator
```

## Packages

| Package                     | Description                        | GitHub                                                                                        |
| --------------------------- | ---------------------------------- | --------------------------------------------------------------------------------------------- |
| `@fastxyz/x402-client`      | Sign and pay for 402 content       | [→ GitHub](https://github.com/fastxyz/fast-sdk/blob/main/packages/x402-client/README.md)      |
| `@fastxyz/x402-server`      | Protect routes, verify payments    | [→ GitHub](https://github.com/fastxyz/fast-sdk/blob/main/packages/x402-server/README.md)      |
| `@fastxyz/x402-facilitator` | Verify signatures, settle on-chain | [→ GitHub](https://github.com/fastxyz/fast-sdk/blob/main/packages/x402-facilitator/README.md) |

## How It Works

The x402 protocol is HTTP-native. On the **server side**, you add payment middleware to your routes — unprotected requests receive a `402 Payment Required` response with payment details. On the **client side**, the SDK handles the full flow: receive the 402, sign a payment, attach proof, and retry — all in one call.

For complete setup instructions, runnable code examples for both server and client, and protocol details, see the individual package READMEs linked above or the [Fast SDK monorepo on GitHub](https://github.com/fastxyz/fast-sdk).


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.fast.xyz/sdk-references/payment-protocol-adapters/x402-sdk.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
