docs @ 402arc
Ship a paid endpoint
in five minutes
402ARC implements x402 v2 with the exact scheme over EIP-3009 transferWithAuthorization on Arc. The buyer signs, the seller receives USDC directly on-chain, and the facilitator verifies and broadcasts. It never holds funds, and the block it lands in is final.
1 · paywall your api
// npm i 402arc-middleware express
import express from "express";
import { arc402 } from "402arc-middleware";
const app = express();
app.use("/api", arc402({
price: "0.001", // USDC per request
payTo: "0xYourAddress", // you get paid here, directly
network: "eip155:5042", // Arc mainnet; eip155:5042002 for testnet
// facilitatorUrl defaults to the hosted 402ARC facilitator
}));
app.get("/api/report", (_req, res) => res.json({ paid: true }));
app.listen(4021);Requests without payment get an HTTP 402 with a PAYMENT-REQUIRED header. Paid responses carry a PAYMENT-RESPONSE header with the settlement tx hash.
2 · pay from code
// npm i 402arc-client
import { createSigner, payingFetch } from "402arc-client";
const pay = payingFetch({
account: createSigner(process.env.WALLET_KEY),
maxValue: 10_000n, // spend cap per request: 0.01 USDC
});
const res = await pay("https://api.example.dev/report");
// 402 → signs EIP-3009 authorization → retries → 2003 · charge agents per tool call
{
"mcpServers": {
"paid-tools": {
"command": "arc402-mcp-proxy",
"args": ["https://your-paid-mcp.example/mcp"],
"env": {
"ARC402_PRIVATE_KEY": "0x…",
"ARC402_MAX_VALUE": "10000"
}
}
}
}The proxy bridges stdio MCP to your paid HTTP endpoint and settles each tool call in USDC. Handshake and tool discovery stay free. Only tools/call is billed.
network reference
| Network | CAIP-2 | RPC | USDC |
|---|---|---|---|
| Arc Mainnet | eip155:5042 | https://rpc.mainnet.arc.io | 0x3600000000000000000000000000000000000000 |
| Arc Testnet | eip155:5042002 | https://rpc.testnet.arc.io | 0x3600000000000000000000000000000000000000 |
EIP-712 domain: name "USDC", version "2" · 6 decimals on the ERC-20 face · gas paid in the same USDC balance (18 decimals natively) · Malachite BFT with deterministic sub-second finality · 20 gwei base-fee floor. Testnet USDC for development: faucet.circle.com.
facilitator api
| GET | /supported | schemes + networks this facilitator services |
| GET | /status | settlement count + native USDC gas float per network, read live from Arc |
| POST | /verify | { paymentPayload, paymentRequirements } → { isValid, payer } |
| POST | /settle | verifies, then broadcasts transferWithAuthorization → { transaction } |
| GET | /events | SSE stream of verify/settle lifecycle events |
| GET | /healthz | liveness + mode |
Verification checks, in order: requirement match → time window → EIP-712 signature recovery → on-chain authorization replay state and payer balance. Settlement broadcasts the buyer's signed authorization; funds move payer → payee in one transaction.