moonpay-x402

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

x402 paid API requests

x402付费API请求

Goal

目标

Make HTTP requests to x402-protected endpoints. The CLI automatically detects 402 Payment Required responses, builds and signs a payment transaction with your local wallet, and retries the request with the payment proof.
向受x402保护的端点发起HTTP请求。CLI会自动检测402 Payment Required响应,使用本地钱包构建并签署支付交易,然后携带支付凭证重试请求。

Command

命令

bash
mp x402 request \
  --method POST \
  --url <x402-endpoint-url> \
  --body '<json-body>' \
  --wallet <wallet-name-or-address> \
  --chain solana
bash
mp x402 request \
  --method POST \
  --url <x402-endpoint-url> \
  --body '<json-body>' \
  --wallet <wallet-name-or-address> \
  --chain solana

Available x402 endpoints

可用的x402端点

EndpointCostInput
https://agents.moonpay.com/x402/upgrade
$1-$20
{"duration": "day"}
or
{"duration": "month"}
端点费用输入
https://agents.moonpay.com/x402/upgrade
1-20美元
{"duration": "day"}
{"duration": "month"}

Example flow

示例流程

  1. User: "Upgrade my rate limit for a day."
  2. Run:
    mp upgrade --duration day --wallet my-wallet --chain solana
  3. The CLI handles the 402 payment flow automatically and applies the upgrade.
  1. 用户:“将我的速率限制升级1天。”
  2. 运行:
    mp upgrade --duration day --wallet my-wallet --chain solana
  3. CLI自动处理402支付流程并完成升级。

Notes

注意事项

  • Requires a local wallet with USDC on Solana or Base.
  • Payments accepted on Solana mainnet and Base.
  • If the request fails (status >= 400), the payment is not settled — you don't pay for errors.
  • Use moonpay-auth to set up a local wallet first.
  • 需要在Solana或Base网络上持有USDC的本地钱包。
  • 支持在Solana主网和Base网络进行支付。
  • 如果请求失败(状态码 >= 400),支付不会完成——您无需为错误请求付费。
  • 请先使用moonpay-auth设置本地钱包。

Related skills

相关技能

  • moonpay-auth — Create or import a local wallet.
  • moonpay-check-wallet — Check your wallet balance before making paid requests.
  • moonpay-upgrade — Upgrade your rate limit via x402.
  • moonpay-auth — 创建或导入本地钱包。
  • moonpay-check-wallet — 在发起付费请求前检查钱包余额。
  • moonpay-upgrade — 通过x402升级速率限制。