What is x402?
x402 is an HTTP payment protocol built on the 402 Payment Required status code. It lets agents pay for API calls directly with on-chain USDC — no API keys, no OAuth, no rate limit tiers.
The flow:
- Client calls the API without any auth header
- API responds with
402 Payment Requiredand payment details (amount, recipient, network) - Client signs an EIP-3009 USDC transfer authorization and retries the request with
X-PAYMENTheader - API verifies the signature, executes the USDC transfer, and fulfills the request
Why x402?
For AI agents, x402 is ideal:
- Agents hold wallets, not API credentials
- Payments are programmable (agents can authorize specific amounts)
- No manual API key rotation or rate limits to manage
- Works with any USDC-holding wallet on Base
For developers, it's simple:
// Wrap fetch once, pay automatically
const fetchPay = wrapFetchWithPayment(fetch, client);
// Calls that need payment: handled automatically
await fetchPay("https://api.inkdprotocol.com/v1/projects", {
method: "POST",
body: JSON.stringify({ name: "my-project" }),
});EIP-3009
x402 uses EIP-3009 transferWithAuthorization — a standard for signing USDC transfers off-chain. The signed authorization is sent in the X-PAYMENT header. The API server executes the on-chain transfer on the client's behalf.
This means:
- No ETH gas needed from the agent wallet (gas is paid by the API server)
- Payment happens atomically with the API call
- Signatures are single-use (nonce prevents replay)
Pricing
| Operation | Cost |
|---|---|
| Create project | $5 USDC |
| Push version | $2 USDC |
| Read (list, get) | Free |
| Upload | Free |
Revenue flow
When you pay to create a project or push a version, the USDC flows through the protocol:
- USDC → Treasury — collected via EIP-3009
- Treasury.settle() — splits the payment:
- 50% → InkdBuyback (accumulates until $50 threshold, then auto-buys $INKD)
- 50% → Protocol treasury
Libraries
npm install @x402/fetch @x402/evm@x402/fetch— wrapsfetchwith automatic payment handling@x402/evm— EVM signer adapter (viem-compatible)
