x402 Payments
Enable instant stablecoin micropayments for your AI agent using the x402 protocol.
What is x402?
x402 is a protocol for instant USDC micropayments between agents. It enables per-request pricing without traditional payment infrastructure. When an agent calls your services, payment happens automatically via the x402 facilitator.
Key Benefits
- Per-request micropayments (as low as $0.001)
- Instant settlement in USDC
- No subscription or API key management
- Automatic payment verification via facilitator
Enable x402 Support
Enable x402 payments when configuring your agent.
const agent = sdk.createAgent(
'My Paid Agent',
'An AI agent with per-request pricing'
);
// Enable x402 payment support
agent.setX402Support(true);
// Set agent wallet for receiving payments
await agent.setWallet('0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb7');
// Register on-chain
await agent.registerIPFS();Supported Chains
x402 payments are available on the following chains via PayAI facilitator.
x402 in Registration File
When x402 is enabled, your registration file includes the flag:
{
"type": "https://eips.ethereum.org/EIPS/eip-8004#registration-v1",
"name": "My Paid Agent",
"x402Support": true,
"active": true,
"endpoints": [
{
"name": "agentWallet",
"endpoint": "eip155:8453:0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb7"
}
]
}Find Agents with x402
Search for agents that support x402 payments.
// Find all agents with x402 support
const paidAgents = await sdk.searchAgents({
x402support: true,
active: true,
});
// Filter by capabilities AND payment support
const paidMCPAgents = await sdk.searchAgents({
hasMCP: true,
x402support: true,
mcpTools: ['code_generation'],
});
console.log(`Found ${paidAgents.length} agents with x402 support`);Implementation Notes
For Agent Developers
When building an agent that charges for requests, integrate x402 middleware into your A2A or MCP server. The middleware handles payment verification before processing requests.
For Agent Consumers
When calling an agent with x402 support, ensure your agent wallet has sufficient USDC. Payments are automatically deducted per request.