solana/pay: the missing payment layer for HTTP and AI agents
The Solana Foundation's pay CLI handles x402 and MPP HTTP 402 payment challenges transparently — wrap curl, Claude Code, or Codex and let agents pay for APIs without sharing your private key. What it is, how the challenge-response flow works, and what the latest PR ships.
devrels.xyz/a/s25g9pshort linkHTTP has had a 402 Payment Required status code since 1991. For three decades it went unused — no settlement layer existed that made per-request micropayments viable. Solana's 400ms finality and sub-cent fees changed that. The Solana Foundation's pay is the tooling that makes it practical: a CLI that intercepts 402s, handles the payment challenge, and retries with proof — transparently, without changing the API or the caller.
The repo description is precise: "Let your agents pay for any API." The agent never holds your private key. It never sees the signing credential. It just gets the response it asked for, and you get a Touch ID prompt before any money moves.
Two protocols, one CLI
pay supports both live payment standards on Solana:
- x402 — the Coinbase-originated protocol where the server returns a
402with a JSON payment payload in theX-PAYMENT-RESPONSEheader. The client attaches a signed payment asX-PAYMENTand retries. Single-shot: one request, one payment. - MPP (Machine Payments Protocol) — the IETF-adjacent spec designed for streaming and session-based billing. The server issues a
WWW-Authenticate: MPPchallenge. The client opens a payment channel, sends vouchers for each request, and commits the channel at the end. Cheaper for many requests against the same endpoint.
pay detects which protocol the server speaks from the response headers and handles the correct flow automatically. You don't need to know which one an API uses.
# Without pay — you get a 402
curl https://debugger.pay.sh/mpp/quote/AAPL
# With pay — it handles the 402 and returns the data
pay curl https://debugger.pay.sh/mpp/quote/AAPLThe challenge-response flow
When pay curl gets a 402:
- Parse the
WWW-Authenticateor response body to extract the challenge — stablecoin, amount, destination, network. - Load the local account for that network (mainnet or sandbox devnet).
- Prepare the transaction but do not sign it — present a biometric prompt instead (Touch ID on macOS, Windows Hello on Windows, GNOME Keyring on Linux).
- If approved, sign with the key from the platform keychain and retry the original request with the payment proof attached.
- Return the response to stdout as if no 402 ever happened.
The agent (or human) running the command never touches the key material. The key stays in the OS keychain. Rejection at step 3 means the payment is not signed and the request does not go through.
Installation and setup
# macOS
brew install pay
# npm (cross-platform)
npm install -g @solana/pay
# From source
git clone https://github.com/solana-foundation/pay.git
cd pay && just install pay
# Setup — creates a wallet, stores key in OS keychain
pay setup
pay whoami
# Fund with USDC for mainnet use
pay topupAI-native: wrapping Claude Code and Codex
pay ships a built-in MCP server. When you run pay claude or pay codex, it injects itself into the agent session so every outbound HTTP request the agent makes is routed through the payment proxy. The agent gains access to paid APIs — Perplexity, stock data feeds, premium RPC endpoints — without any credential management in the prompt or tool configuration.
# Launch Claude Code with pay injected
pay claude
# Or add to claude_desktop_config.json for persistent access
# {
# "mcpServers": {
# "pay": { "command": "pay", "args": ["mcp"] }
# }
# }# Once inside the session the agent can run paid calls naturally
pay skills search "stock quotes"
pay skills endpoints perplexity
pay curl https://api.perplexity.ai/chat/completions \
-H "Content-Type: application/json" \
-d '{"model":"sonar","messages":[{"role":"user","content":"SOL price"}]}'The skills catalog
pay has an open-source catalog of pay-compatible API providers in the pay-skills repo. Each entry defines endpoints, pricing, and agent-readable usage notes. The CLI can search, browse, and install provider sources locally.
pay skills search "maps" # find providers by keyword
pay skills endpoints perplexity # list all endpoints + prices
pay skills list # show installed provider sources
pay skills update # refresh local cache
# Add a custom or pinned provider source
pay skills add https://github.com/my-org/my-api-skillsRunning a payment gateway for your own API
pay isn't just a client — it can turn any OpenAPI spec into a monetised endpoint in one command:
# Start a pay-aware gateway from your OpenAPI spec
pay server start --debugger spec.yml
# Or spin up the bundled sandbox demo
pay server demoThe --debugger flag starts the embedded Payment Debugger — a local web UI that renders every 402 challenge-response cycle as a sequence diagram. You can see exactly which headers were exchanged, which protocol was detected, and where a flow failed. A public instance is available for testing without running it locally.
PR #389: devex improvements (session 2)
The latest merged PR from lgalabru ships 27 files of developer experience improvements across the CLI and the Payment Debugger. The main areas:
- Debugger session view — a new
SessionChannelcomponent visualises the MPP channel lifecycle as a flow diagram, with colour-coded ribbons showing how payments split across recipients and capacity utilisation. TheReceiptLinkcomponent links each completed payment to its on-chain transaction. - Skills provider management — the
pay skillssub-commands gain aprovidergroup withprune-merged(drop pinned providers whose upstream PRs have merged) and aboxeddisplay mode for better terminal formatting.showandsearchget richer output. - Account and send UX —
pay account listandpay account newget cleaner output;pay sendgains--confidential(Token-2022 Confidential Transfer extension — amount hidden on-chain) and--fee-within(deduct fee from amount rather than adding on top, implied formaxsends). - Server auth improvements — session authenticate handling in
pay serverupdated for cleaner channel-open / voucher / commit / close lifecycle.
# Confidential transfer — amount hidden on-chain via Token-2022 CT extension
pay send 50 <recipient> --confidential
# Send entire balance (fee deducted from amount automatically)
pay send max <recipient>
# Browse improved skills output
pay skills show perplexityMPP sessions: cheaper for high-frequency agent calls
x402 costs one on-chain transaction per API call. For an agent making ten calls in a session, that's ten transactions. MPP payment channels amortise that: you open a channel with a deposit, sign off-chain vouchers for each request, and settle on-chain once at the end. For an agent making 50 calls against one endpoint, the cost difference is roughly 50× in transaction fees.
# MPP session visualised in the debugger
# open → [voucher × N] → commit
#
# Channel state at each step is now visible in the SessionChannel
# component — capacity bars, recipient splits, running total
pay server demo # start local sandbox + debugger
# navigate to http://localhost:4000 to see live session flowsEcosystem
The protocols are open. You don't need the pay CLI to accept payments — any server that returns a properly formatted 402 with x402 or MPP headers will work with any compliant client. Projects building on this infrastructure include pointifsol.com and the growing pay-skills catalog. The public debugger at debugger.pay.sh lets you test any 402-compatible endpoint without a local setup.
The full docs are at docs.solanapay.com. The repo is MIT-licensed and contributions to the skills catalog are open.
Keep reading
Mastercard's Agent Pay for Machines puts the incumbent into agentic payments — but the interesting part isn't the card network, it's where the authorization lives. Agent permissions and credentials are written to public blockchains (Solana among the first three) as a 'Verifiable Intent' ledger anyone can audit, while settlement stays on Mastercard's network. A look at the architecture and how it sits beside x402.
Both x402 and Mastercard's AP4M answer the same question — how does an agent pay without a human in the loop — and they answer it differently. One is an open HTTP status code settled in USDC on Solana; the other is a permissioned network that uses public chains only as a credential ledger. Here's the head-to-head, dimension by dimension, and a decision guide.
An agent that can call any paid API on the open internet sounds great until you ask: whose money, and what stops it from draining the wallet? This is the practical wiring — x402 inside the MCP tool loop, the @x402/svm client, and the Solana agent wallets (Coinbase, Crossmint, Privy, SendAI) that enforce spend caps and allowlists.
Get new articles in your inbox
Technical deep-dives on Solana tooling, infrastructure, and ecosystem. No noise.