Skip to content

Guide · Agent skill

How to use the Agent Payments via x402 agent skill

Updated · written with AI from the project's own documentation and checked against our catalogue data

This guide explains the agent-payment-x402 skill, which teaches an AI agent to pay for web services that charge per request using the x402 protocol. It is written for readers who have never used agent skills before. By the end you will know what the skill does, how to install it, how to ask an agent to use it, and which safety limits to set before any real payment happens.

Agent Payments via x402affaan-m/ECC · MIT

Quick start

  1. 1Download the skill. Download the ZIP of the agent-payment-x402 skill from this page. It contains SKILL.md.
  2. 2Unzip into the skills folder. Unzip it into ~/.claude/skills/ for personal use, or into .claude/skills/ inside your project. In the Claude apps, you can instead upload it under Settings, Capabilities, Skills.
  3. 3Choose your route. Pick the Base MCP route, the X Layer OKX route, or the upstream Solana and EVM client route based on which network your agent must pay on.
  4. 4Pin and register the payment package. For the Base route, add the agentwallet-sdk MCP server with a pinned version to your MCP configuration.
  5. 5Set signer keys and policy in the orchestrator. Store EVM and Solana keys in environment variables owned by the orchestrator. Set budgets, rate limits and the payee allowlist there, not in the agent.
  6. 6Test on a testnet. Run a small request against a testnet endpoint first and check that the 402 challenge matches your policy.
  7. 7Review the audit trail. After each run, read the transaction list and confirm the payments match what you approved.

What does the agent-payment-x402 skill make an agent do?

x402 extends HTTP status 402 (Payment Required) into a flow a machine can handle. When a server replies with 402, the agent's payment tool checks the price, confirms it fits the budget, signs the transaction, and retries only within the policy and confirmation limits set by the operator.

The skill adds spending controls. Every payment tool call is checked against a spending policy with per-task budgets, per-session budgets, an allowlist of payees, and rate limits. The agent holds its own keys through an ERC-4337 smart account, and the operator sets the policy before delegating work, so the agent cannot raise its own limits.

  • Per-task budget: the maximum spend for a single agent action
  • Per-session budget: a cumulative cap across the whole session
  • Allowlisted payees: limits which addresses or services the agent may pay
  • Rate limits: maximum transactions per minute or hour

Choose the right integration route

The skill covers three routes. Pick one based on whether your agent is buying access to a paid API, or whether you are charging for your own API.

Route A uses the agentwallet-sdk package as an MCP payment server for Base and other agentwallet-supported chains. Route B uses the OKX agent payments protocol for X Layer. Route C uses upstream x402 client packages for Solana and EVM networks. The skill also lists seller-side guides for TypeScript, Python, Go, Rust and Java, so you can charge for an API.

  • Agent pays a 402-gated API on Base: use agentwallet-sdk as an MCP server
  • Agent pays a 402-gated API on X Layer: use the OKX agent payments protocol
  • Agent pays on Solana or another x402 v2 network: wrap the HTTP client with the upstream @x402/fetch or @x402/axios package
  • Your API charges agents: use the upstream x402 middleware or the OKX seller SDK guide for your framework

Install the skill (ZIP download or upload)

Download the ZIP of the skill from this page. The skill is a folder that contains a single file, SKILL.md. Unzip it into one of these locations.

For a personal setup, unzip it into ~/.claude/skills/. For a single project, unzip it into the .claude/skills/ folder inside that project. If you use the Claude apps instead, open Settings, go to Capabilities, then Skills, and upload the skill there.

If you want the Base route, you also need to register the MCP server. Add the mcpServers block below to your agent harness's MCP configuration. The skill pins the package version, which you should keep pinned.

{"mcpServers": {"agentpay": {"command": "npx", "args": ["agentwallet-sdk@6.0.0"]}}}

Trigger the skill with natural requests

You do not need a special command. Describe the job in plain language and mention paying, buying, budgets or spending. The agent should pick up the skill from its description.

Expect the agent to ask for confirmation before any payment action. The skill requires explicit user confirmation before wallet checks or payment actions, so payments should not run hidden behind a general tool call.

  • Pay for one call to the weather API at the URL I give you, and stay under 0.01 USDC.
  • Check how much budget is left in this session before you call the paid data endpoint.
  • Show me the transaction log for all payments made in this task.
  • Set up a payment client for my Solana and Base API calls, using a per-call cap and a payee allowlist.

Tools the agent can call on the Base route

On the Base route the agent gets four tools. get_balance checks the agent wallet balance. send_payment sends a payment to an address or ENS name. check_spending shows the remaining budget. list_transactions returns the audit trail of all payments.

The spending policy is set by the orchestrator, not the agent, and it should be set through set_policy in an orchestration layer or a pre-task hook. Do not expose set_policy as a tool the agent can call.

  • get_balance
  • send_payment
  • check_spending
  • list_transactions

Safety notes: scripts, network and keys

This skill runs scripts and uses the network. It manages private keys, so pin package versions. An unpinned npx install is a supply chain risk. Signer keys should live in the orchestrator's environment variables, never hardcoded and never writable by the agent.

On the upstream route, the client should allow only the resource origins you name, refuse redirects, and check amount, asset and network against the server's challenge before signing. Your own numbers do not prove a budget, because the amount comes from the server. The skill's notes say default x402.org facilitator endpoints are testnet only, so do not point production payments at them. Check live coverage at the facilitator's /supported endpoint.

  • Pin every package version (for example agentwallet-sdk and @x402/fetch)
  • Keep private keys in environment variables owned by the orchestrator
  • Use the Base Sepolia testnet during development; treat Base mainnet as the production path
  • Check facilitator coverage at /supported before going live

Tips for a safe first run

Start on a testnet with a funded test wallet. Set a small per-task budget and a small session cap, then add a payee allowlist before running anything with real funds. Read list_transactions after each run so you can see what was paid and to whom.

If you are building the payment code itself, get the current SDK documentation first. The skill warns that payment packages and facilitator behaviour can change quickly, so do not copy old examples.

  • Begin with a testnet and a small session cap
  • Set a payee allowlist before the first live call
  • Review the audit trail after each run
  • Fetch current SDK documentation before writing production code

What people use it for

  • An agent that buys per-request access to a paid data API, within a fixed per-call cap
  • A research agent that pays a set of outside services and must stay under a session budget
  • A multi-agent system where one agent pays another, with every payment logged for audit
  • A developer prototype that tests x402 payments on Base Sepolia before any mainnet use

Frequently asked questions

Is the agent-payment-x402 skill free and what is its licence?

The source gives the licence as MIT. The skill itself is a document, but the packages it uses, such as agentwallet-sdk and the upstream x402 packages, are separate projects with their own terms. Check each package's licence before use.

How do I install the agent-payment-x402 skill?

Download the ZIP from this page and unzip it into ~/.claude/skills/ or a project's .claude/skills/ folder. In the Claude apps, you can upload it under Settings, Capabilities, Skills.

What do I need to run it?

You need Node.js and npx. The Base route needs a pinned agentwallet-sdk package. The client route needs EVM and Solana private keys in environment variables, plus upstream packages such as @x402/fetch, viem and @solana/kit. You also need access to facilitator endpoints and ideally a funded testnet wallet.

Why does my payment fail on the default x402.org facilitator?

The skill's notes say the default x402.org endpoints are testnet only, covering networks such as Base Sepolia and Solana devnet. They are not meant for mainnet routes. For production, use your own facilitator or a hosted one, and confirm coverage at /supported.

How does this compare with other ways of paying for APIs?

Unlike a normal API key, x402 lets a server ask for a small payment per request and lets the agent settle it. The skill's main difference from a raw x402 client is the spending policy layer: per-task and per-session budgets, payee allowlists, rate limits and an audit trail.

Can an agent spend money without my approval?

The skill says payment actions need explicit user confirmation before wallet checks or payment. A mistake can still cost real funds, so set strict budgets and allowlists and test on a testnet first.

New agent skills, repos and AI tools — every week

The best new skills and open-source projects, the fastest-growing repos, and one free prompt. Five minutes to read. Unsubscribe anytime.

Our verdict

Use this skill if you are a developer building agents that must pay for APIs or other agents, and you want hard budget caps and an audit trail. Pick something else if you want an agent to spend real money with little oversight, or if you are not comfortable managing private keys and wallets.

Download the skill