# Paying for Poste with x402

Poste charges with the x402 protocol: HTTP 402 + a signed USDC transfer. No account, no API key signup.

Network: **Base Sepolia** (`eip155:84532`). Asset: USDC. Pay-to address is in every 402 response.

## Option A — any standard x402 client (recommended; no vendor SDK)

Poste is a plain x402 v2 paywall. Whatever your runtime already uses for x402 payments works unchanged.

**TypeScript / Node (public packages only):** save as `pay.mjs`, run `npm i @x402/fetch @x402/evm @x402/core viem` then `node pay.mjs`:
```js
import { privateKeyToAccount } from "viem/accounts";
import { x402Client } from "@x402/core/client";
import { registerExactEvmScheme } from "@x402/evm/exact/client";
import { wrapFetchWithPayment } from "@x402/fetch";
const account = privateKeyToAccount(process.env.X402_PRIVATE_KEY);
const client = new x402Client();
registerExactEvmScheme(client, { signer: { address: account.address, signTypedData: (m) => account.signTypedData(m) } });
const payingFetch = wrapFetchWithPayment(fetch, client);
const res = await payingFetch("https://poste.sh/v1/mailbox", { method: "POST", headers: { "Content-Type": "application/json" }, body: "{}" });
console.log(JSON.stringify(await res.json(), null, 2)); // → { address, token, ... } — persist this
```

**Python:** `pip install "x402[evm]"` and use its requests/httpx wrapper with the same URL.

**Claude Code:** install the x402 WebFetch hook once (https://developers.cloudflare.com/agents/tools/payments/x402/pay-with-tool-plugins/) — after that, fetching the 402 URL pays and retries automatically.

**Cloudflare Agents SDK:** `withX402Client`. **Cloudflare Wallets:** pays natively once Virtual Wallet spending ships.

Everything after payment is plain `curl` with `Authorization: Bearer <token>`.

## Getting a wallet with USDC
- Any EVM private key works. Generate one (`cast wallet new`, or `openssl rand -hex 32`) and fund it.
- Base Sepolia test USDC: https://faucet.circle.com (select Base Sepolia). Gas is paid by the facilitator; you only need USDC.
- Managed options with spend limits: Coinbase CDP Agentic Wallets, or **Cloudflare Wallets** (cloudflare.pay) — an Account Wallet delegates a capped Virtual Wallet to your agent; pays x402 natively. (Handle reservation is live; spending ships when Cloudflare enables it.)

## What you are charged
One price: **$1 = a mailbox with 30 days + 200 sends**. Paying $1 again (POST /v1/mailbox/renew) adds 30 days + 200 sends. Nothing else costs money. Every paid response includes `receipt.tx`.
