Skip to content

Agent Payments via x402

Lets an AI agent pay for APIs and services within spending limits, using crypto wallets.

Repository
affaan-m/ECC
Stars
295,127
Licence
MIT
Files
1 file

What it does

This skill teaches an AI agent how to pay for web services that charge per request using the x402 protocol, where a server replies with HTTP 402 Payment Required and the agent can settle a small payment and retry. It adds guardrails: per-task and per-session budgets, allowlisted payees, rate limits, and a rule that the operator (not the agent) sets the spending policy. It covers three routes: a Base wallet SDK exposed as an MCP server, the OKX payment protocol for X Layer, and upstream x402 client packages for Solana and EVM networks. It also explains how to charge for an API in several languages.

Great for

  • Developers building agents that need to buy API access or pay other agents with crypto
  • Teams who want strict budget caps and an audit trail on agent spending
  • Developers evaluating x402 integrations before writing production payment code

Skip it if

  • Anyone who wants an agent to spend real money without careful review: the skill itself says payment actions need explicit user confirmation, and a mistake can cost real funds
  • Non-developers without experience managing private keys and wallets: setup requires signer keys in environment variables
  • Production payments on the x402.org facilitator: its default endpoints are testnet-only, per the skill's notes

Try asking

  • “Set up an agent wallet with a $5 per-task budget and show me how to configure the MCP server”
  • “Write a TypeScript client that pays 402-gated APIs on Base and Solana with a spending policy”
  • “Help me add x402 payment middleware to my Express API so agents can pay per call”
  • “Check the remaining session budget and list recent agent transactions”
Step-by-step guide: how to use Agent Payments via x402Install, first run, examples, tips and FAQs

Install in 3 steps

  1. 1

    Download the skill

    The ZIP contains the 1 original files, the MIT licence and an attribution note.

    agent-payment-x402.zip
  2. 2

    Add it to your agent

    Claude Code (all projects)

    mkdir -p ~/.claude/skills && unzip agent-payment-x402.zip -d ~/.claude/skills/

    Claude Code / Agent SDK (this project only)

    mkdir -p .claude/skills && unzip agent-payment-x402.zip -d .claude/skills/

    Claude apps (web/desktop): Settings → Capabilities → Skills → Upload skill, and choose the ZIP.

  3. 3

    Ask for the task

    No special command needed — the agent reads the skill's description and loads it when your request matches. Try one of the prompts above.

Get better results

  • Pin every package version and review the code before running it, since the skill handles private keys and npx installs are a supply-chain risk
  • Start on Base Sepolia or other testnets and verify facilitator coverage before any mainnet use
  • Set spending policies in your orchestrator or pre-task hook, never as tools the agent can call, and confirm each payment's amount, asset and network against the server's challenge

What's inside

  • SKILL.md

Redistributed unmodified from affaan-m/ECC under the MIT licence. The assessment was drafted with AI from the skill's files on 2026-10-29. Skills can instruct your agent to run code — read SKILL.md and any scripts before installing.