Configure x402
Overview
Configures the x402 HTTP-native payment protocol for agent-to-agent micropayments settled on Base. x402 uses the HTTP 402 "Payment Required" status code to enable pay-per-request billing — agents pay fractions of a cent per API call in USDC, with ~200ms settlement, no API keys, no accounts, and no subscriptions.
This skill supports two modes:
- - Pay mode: Configure your agent to pay for MCP tool calls and external API access via x402
- Accept mode: Configure your agent as an x402 service provider that accepts micropayments for its services
- Both: Enable bidirectional x402 payments
x402 has processed 100M+ agent-to-agent transactions across 80+ ecosystem projects (Feb 2026). It eliminates API key onboarding friction and creates revenue streams from every agent interaction.
When to Use
Activate when the user says:
- - "Set up x402 payments for my agent"
- "Enable pay-per-swap via x402"
- "Configure my agent to accept x402 payments"
- "Set up micropayments on Base"
- "Enable x402 for my MCP server"
- "Monetize my agent's API"
- "Configure pay-per-request billing"
- "Set up agent-to-agent payments"
Parameters
| Parameter | Required | Default | Description |
|---|
| INLINECODE0 | No | both | Payment mode: "pay" (pay for services), "accept" (accept payments), or "both" |
| INLINECODE1 |
Yes | -- | USDC wallet address on Base for sending/receiving payments |
|
chain | No | base | Settlement chain (Base recommended for ~200ms settlement) |
|
pricePerCall | No | see pricing | Price per MCP tool call in USDC (for accept mode). Defaults to recommended pricing below. |
|
supportedTools | No | all | Which MCP tools to gate behind x402 payments (for accept mode). "all" or comma-separated list. |
|
maxSpendPerHour | No | $1.00 | Maximum x402 spend per hour (for pay mode). Safety limit to prevent runaway costs. |
|
facilitator | No | auto | x402 facilitator to use. "auto" selects the best available facilitator on Base. |
Recommended Pricing (Accept Mode)
| Tool Category | Price per Call | Examples |
|---|
| Price quotes | $0.001 | INLINECODE7 , INLINECODE8 |
| Pool analytics |
$0.003 |
get_pool_info,
get_pool_volume_history |
| Route optimization | $0.005 |
get_pools_by_token_pair,
search_tokens |
| Simulation | $0.01 |
simulate_transaction |
| Execution | $0.05 |
execute_swap,
add_liquidity |
Workflow
- 1. Parse configuration from the user's request. Determine the payment mode, wallet address, chain, pricing, and tool scope. Validate the wallet address format.
- 2. Validate wallet: Verify the wallet address exists on the target chain and has a USDC balance (for pay mode) or can receive USDC (for accept mode). Check that the chain supports x402 settlement.
- 3. Write x402 configuration: Generate the x402 configuration file at
.uniswap/x402-config.json with:
- Payment mode (pay/accept/both)
- Wallet address and chain
- Facilitator endpoint
- Per-tool pricing (accept mode)
- Spending limits (pay mode)
- Supported tools list
For accept mode, also generate the .well-known/x402-manifest.json that advertises the agent's x402-enabled endpoints to other agents.
- 4. Verify setup: Confirm the configuration is valid by checking:
- Wallet connectivity on the settlement chain
- Facilitator availability
- USDC token approval for the facilitator contract (if pay mode)
- Configuration file is properly formatted
Output Format
CODEBLOCK0
Important Notes
- - x402 settles on Base by default (~200ms). Ethereum mainnet settlement is possible but slower and more expensive.
- USDC is the only supported payment token for x402. The wallet must hold USDC on the settlement chain.
- The
maxSpendPerHour safety limit prevents runaway costs in pay mode. Adjust based on expected usage. - x402 uses the HTTP 402 "Payment Required" status code. When a client hits an x402-gated endpoint without payment, it receives a 402 response with payment instructions.
- Facilitators handle the payment settlement. The "auto" option selects the best available facilitator on the target chain.
- For accept mode, the
.well-known/x402-manifest.json file makes your agent discoverable on Coinbase Bazaar (12,365+ services). - x402 payments are per-request. There are no subscriptions, API keys, or accounts. Each request includes a micropayment.
- All x402 transactions are logged for treasury management and can be tracked via the
manage-treasury skill. - This skill does not execute any on-chain transactions. It only generates configuration files. The actual x402 payment flow happens at runtime when the MCP server processes requests.
Error Handling
| Error | User-Facing Message | Suggested Action |
|---|
| Invalid wallet | "Invalid wallet address format." | Provide a valid Ethereum address (0x...) |
| No USDC balance |
"Wallet has no USDC on [chain]. x402 payments require USDC." | Fund the wallet with USDC on Base |
| Chain not supported | "[chain] does not support x402 settlement." | Use Base (recommended) or Ethereum |
| Facilitator unavailable| "No x402 facilitator available on [chain]." | Try Base (most facilitators available) |
| Config write failed | "Could not write x402 configuration: [reason]." | Check file permissions |
| Wallet not configured | "No agent wallet found. Set up a wallet first." | Use
setup-agent-wallet skill first |
| Invalid pricing | "Price per call must be positive and in USDC." | Provide valid pricing values |
配置 x402
概述
配置基于 Base 链结算的 x402 HTTP 原生支付协议,用于代理间微支付。x402 使用 HTTP 402 需要付款 状态码实现按请求计费——代理每次 API 调用支付不到一美分的 USDC,结算时间约 200 毫秒,无需 API 密钥、账户或订阅。
该技能支持两种模式:
- - 支付模式:配置您的代理通过 x402 支付 MCP 工具调用和外部 API 访问
- 接收模式:将您的代理配置为接受其服务微支付的 x402 服务提供商
- 双向模式:启用双向 x402 支付
x402 已在 80 多个生态项目中处理了超过 1 亿次代理间交易(2026 年 2 月)。它消除了 API 密钥接入的摩擦,并从每次代理交互中创造收入流。
使用时机
当用户说出以下内容时激活:
- - 为我的代理设置 x402 支付
- 通过 x402 启用按次交换支付
- 配置我的代理接受 x402 支付
- 在 Base 上设置微支付
- 为我的 MCP 服务器启用 x402
- 将我的代理 API 货币化
- 配置按请求计费
- 设置代理间支付
参数
| 参数 | 必填 | 默认值 | 描述 |
|---|
| mode | 否 | both | 支付模式:pay(支付服务费用)、accept(接受支付)或 both(双向) |
| walletAddress |
是 | -- | 用于发送/接收支付的 Base 链 USDC 钱包地址 |
| chain | 否 | base | 结算链(推荐 Base,结算时间约 200 毫秒) |
| pricePerCall | 否 | 见定价表 | 每次 MCP 工具调用的 USDC 价格(接收模式)。默认为下方推荐定价。 |
| supportedTools | 否 | all | 需要通过 x402 支付才能使用的 MCP 工具列表(接收模式)。all 或逗号分隔列表。 |
| maxSpendPerHour | 否 | $1.00 | 每小时最大 x402 支出(支付模式)。防止成本失控的安全限制。 |
| facilitator | 否 | auto | 使用的 x402 协调器。auto 自动选择 Base 上最佳可用协调器。 |
推荐定价(接收模式)
| 工具类别 | 每次调用价格 | 示例 |
|---|
| 报价查询 | $0.001 | gettokenprice、getquote |
| 池分析 |
$0.003 | getpool
info、getpool
volumehistory |
| 路由优化 | $0.005 | get
poolsby
tokenpair、search_tokens |
| 模拟 | $0.01 | simulate_transaction |
| 执行 | $0.05 | execute
swap、addliquidity |
工作流程
- 1. 解析配置:从用户请求中解析配置。确定支付模式、钱包地址、链、定价和工具范围。验证钱包地址格式。
- 2. 验证钱包:验证钱包地址在目标链上存在,并具有 USDC 余额(支付模式)或能够接收 USDC(接收模式)。检查链是否支持 x402 结算。
- 3. 写入 x402 配置:在 .uniswap/x402-config.json 生成 x402 配置文件,包含:
- 支付模式(pay/accept/both)
- 钱包地址和链
- 协调器端点
- 按工具定价(接收模式)
- 支出限制(支付模式)
- 支持的工具列表
对于接收模式,还需生成 .well-known/x402-manifest.json 文件,向其他代理宣传该代理的 x402 启用端点。
- 4. 验证设置:通过检查以下内容确认配置有效:
- 结算链上的钱包连接
- 协调器可用性
- 协调器合约的 USDC 代币授权(支付模式)
- 配置文件格式正确
输出格式
text
x402 配置完成
模式: 双向(支付 + 接收)
链: Base (8453)
钱包: 0x1234...abcd
协调器: 自动选择(Coinbase x402)
支付模式:
最大支出: $1.00/小时
USDC 余额: $50.00(充足)
接收模式:
定价:
报价查询: $0.001/次调用
池分析: $0.003/次调用
路由优化: $0.005/次调用
模拟: $0.010/次调用
执行: $0.050/次调用
工具限制: 全部(17 个工具)
配置文件:
.uniswap/x402-config.json
.well-known/x402-manifest.json
状态:x402 支付就绪
重要说明
- - x402 默认在 Base 链上结算(约 200 毫秒)。以太坊主网结算可行但速度较慢且成本较高。
- USDC 是 x402 唯一支持的支付代币。钱包必须在结算链上持有 USDC。
- maxSpendPerHour 安全限制可防止支付模式下成本失控。根据预期使用量调整。
- x402 使用 HTTP 402 需要付款 状态码。当客户端访问 x402 限制的端点但未支付时,会收到包含支付说明的 402 响应。
- 协调器处理支付结算。auto 选项自动选择目标链上最佳可用协调器。
- 对于接收模式,.well-known/x402-manifest.json 文件使您的代理可在 Coinbase Bazaar(12,365+ 服务)中被发现。
- x402 支付是按请求进行的。没有订阅、API 密钥或账户。每个请求都包含一笔微支付。
- 所有 x402 交易均记录用于资金管理,可通过 manage-treasury 技能追踪。
- 该技能不执行任何链上交易。仅生成配置文件。实际的 x402 支付流程在 MCP 服务器处理请求时在运行时发生。
错误处理
| 错误 | 面向用户的提示信息 | 建议操作 |
|---|
| 无效钱包 | 钱包地址格式无效。 | 提供有效的以太坊地址(0x...) |
| 无 USDC 余额 |
钱包在 [chain] 上没有 USDC。x402 支付需要 USDC。 | 在 Base 上向钱包充值 USDC |
| 不支持的链 | [chain] 不支持 x402 结算。 | 使用 Base(推荐)或以太坊 |
| 协调器不可用 | [chain] 上没有可用的 x402 协调器。 | 尝试 Base(大多数协调器可用) |
| 配置写入失败 | 无法写入 x402 配置:[原因]。 | 检查文件权限 |
| 钱包未配置 | 未找到代理钱包。请先设置钱包。 | 先使用 setup-agent-wallet 技能 |
| 无效定价 | 每次调用价格必须为正数且以 USDC 计价。 | 提供有效的定价值 |