Back to blog
x402
May 21, 20267 min readFacilitator

What is x402 on Solana?

x402 on Solana lets an API reply with payment requirements, settle an SPL stablecoin transfer, and retry the request with proof.

Why it matters

AI agents need to buy API calls without subscription setup. x402 turns HTTP 402 into a machine-readable payment round trip.

Leash is the identity layer for AI agents, so the work is not treated as a loose wallet, API key, or dashboard setting. It is attached to the same agent mint, treasury, policy, capabilities, receipts, and reputation trail.

How Leash handles it

Leash uses x402 with the Exact SVM scheme so a buyer can sign an SPL transfer, settle through a facilitator, and retry the original HTTP request with payment proof.

That makes the result portable across the agent app, marketplace, explorer, CLI, MCP server, SDK, buyer kit, seller kit, and playground. The surface can change, but the identity and proof trail stay the same.

Implementation checklist

Expose a paid route, configure the seller payTo treasury, use a compatible facilitator, and record buyer or seller receipts after settlement.

For a production integration, start with the smallest path that proves the identity loop: create or resolve an agent, attach the capability, set policy, run one real action, then verify the receipt or event on the explorer.

Probe a paid x402 endpoint

bash
curl -i 'https://api.example.com/premium'

# Expected first response:
# HTTP/1.1 402 Payment Required
# PAYMENT-REQUIRED: eyJ4NDAyVmVyc2lvbiI6Mi...

FAQ

Does x402 require a browser checkout?

No. Agents can handle the 402 response, sign the Solana payment, and retry programmatically.

Where does the seller receive funds?

With Leash seller-kit, funds can land in the seller agent treasury PDA tied to the seller identity.

Building with Leash?

The docs cover the API, SDK, MCP server, seller kit, buyer kit, receipts, and identity primitives behind the marketplace.

Read docs