x402 on Solana: Your AI Agent Can Pay for Its Own Data
Published on 2026-02-28
AI agents can now pay for premium APIs, web scraping, and market data per-request using USDC on Solana. No API keys, no subscriptions — just sol fetch and a wallet.
Why AI Agents Need x402 Instead of API Keys
Every premium API starts the same way: create an account, generate an API key, store it somewhere, rotate it periodically, manage billing separately. For humans, this is tedious. For autonomous AI agents, it's a fundamental design problem.
An agent running autonomously needs data — market prices, social sentiment, web content, news. Each data source requires its own API key, its own billing arrangement, its own credential management. Scale that to dozens of sources and you have a credential management nightmare that someone has to maintain manually. The agent can't sign up for services itself.
x402 replaces all of this with a single mechanism: per-request payment in USDC. Your agent makes an HTTP request to any x402-enabled endpoint. If the server requires payment, it responds with HTTP 402 and a price. The agent signs a USDC transfer, retries the request with the signed payment attached, and gets its data. No accounts, no keys, no subscriptions. The wallet is the credential.
How x402 Payments Work with sol fetch
sol fetch is curl for paid APIs. The syntax is identical to what you'd expect:
sol fetch https://api.example.com/data
If the server responds with 402 Payment Required, sol fetch automatically parses the payment requirements, builds a USDC transfer, signs it, and retries with the payment attached. If the server doesn't require payment, it works like a normal HTTP request.
Payment info goes to stderr, the response body goes to stdout — so you can pipe it directly to jq or into another command:
sol fetch https://pro-api.coingecko.com/api/v3/x402/simple/price?ids=solana\&vs_currencies=usd | jq '.solana.usd'
Check the cost before paying
sol fetch https://api.example.com/data --dry-run
Payment Required (x402)
Amount: $0.010000 USDC
Recipient: GkX...abc
Network: solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp
Run without --dry-run to pay and fetch the resource.
Set a spending cap
sol fetch https://api.example.com/data --max 0.05
If the price exceeds $0.05, the request is rejected before any payment is signed.
Full options
| Flag | What it does |
|---|---|
-X, --method <method> |
HTTP method — GET, POST, etc. |
-d, --body <data> |
Request body (for POST endpoints) |
-H, --header <header> |
Custom headers (repeatable) |
--max <amount> |
Maximum USDC to spend per request |
--dry-run |
Show cost without paying |
--wallet <name> |
Which wallet to pay from |
--json |
Structured JSON output |
The JSON output follows the same CommandResult<T> envelope as every other Sol CLI command, with elapsed_ms in the metadata.
x402 Services Available on Solana Today
x402 is live on Solana with real services accepting USDC micropayments. Here's what's available right now, verified against live endpoints.
x402 market data: CoinGecko, Syraa, and more
The most immediately useful category for trading agents. Get token prices, trending pools, and DEX analytics — all without an API key.
CoinGecko — the same CoinGecko data you know, paid per-request instead of per-month:
# Get SOL price — $0.01
sol fetch "https://pro-api.coingecko.com/api/v3/x402/simple/price?ids=solana&vs_currencies=usd"
# Trending pools on Solana DEXes — $0.01
sol fetch "https://pro-api.coingecko.com/api/v3/x402/onchain/networks/solana/trending_pools"
# Search for specific pools — $0.01
sol fetch "https://pro-api.coingecko.com/api/v3/x402/onchain/search/pools?query=bonk"
x402engine — lightweight crypto price API:
# SOL price — $0.001
sol fetch "https://x402engine.app/api/crypto/price?symbol=SOL"
Syraa — DEX analytics and trending token detection across 20+ endpoints:
# DEX screener data — $0.10
sol fetch "https://api.syraa.fun/dexscreener"
# What's trending on Jupiter right now — $0.10
sol fetch "https://api.syraa.fun/trending-jupiter"
Social data APIs via x402
Agents that trade based on sentiment need social data. Portals Protocol offers 29 endpoints for scraping social platforms — Twitter, Instagram, and more.
# Get a Twitter user's profile and stats — $0.001
sol fetch "https://api.portalsprotocol.com/twitter/user" -X POST \
-d '{"username": "solaboratory"}' -H "Content-Type: application/json"
# Search Twitter for mentions of a token — $0.01
sol fetch "https://api.portalsprotocol.com/twitter/search" -X POST \
-d '{"query": "solana breakpoint"}' -H "Content-Type: application/json"
# Instagram profile data — $0.005
sol fetch "https://api.portalsprotocol.com/instagram/profile" -X POST \
-d '{"username": "solana"}' -H "Content-Type: application/json"
Web scraping with x402
Turn any URL into structured content. Useful for agents that need to read documentation, articles, or product pages.
# Scrape any webpage — $0.005
sol fetch "https://x402engine.app/api/web/scrape?url=https://solana.com"
Crypto news and intelligence
Beyond raw price data — news, smart money tracking, and market sentiment:
# Breaking crypto news — $0.10
sol fetch "https://api.syraa.fun/news" -X POST \
-d '{"query": "solana defi"}' -H "Content-Type: application/json"
Syraa offers around 20 endpoints covering news aggregation, smart money wallet tracking, sentiment analysis, and token screening. All follow the same pattern — POST with a JSON query body, $0.10 per request.
Premium content and AI services via x402
# Premium articles — $0.01
sol fetch "https://v402pay.onvoyage.ai/api/pay/article-slug"
# AI agent runtime access — $0.10
sol fetch "https://tropir.xyz/api/cortex/access"
The broader x402 ecosystem on Solana
These are the endpoints we've tested and verified. The full ecosystem is significantly larger. x402list.fun tracks 54 providers on Solana alone, offering 522+ endpoints across categories including web scraping, AI inference, social data, and developer tools.
Services like Browserbase (browser automation), Firecrawl (web crawling), Pinata (IPFS pinning), and Neynar (Farcaster data) are available on other chains and may add Solana support as the protocol matures. The ecosystem has processed over 120 million x402 transactions to date, with Solana handling roughly 77% of the volume.
x402 in Action: End-to-End AI Agent Workflows
The real power of sol fetch isn't any single endpoint — it's what happens when an agent chains paid data sources together with Sol CLI's trading and portfolio commands. Here are two complete workflows.
Research a token and decide whether to buy
An agent is tasked with finding promising tokens and making small trades. Here's the full command sequence:
# 1. Check what we're working with
sol portfolio --json
# 2. Find trending pools on Solana — $0.01
sol fetch "https://pro-api.coingecko.com/api/v3/x402/onchain/networks/solana/trending_pools" --json
# 3. A pool catches the agent's eye — check the token price — $0.01
sol fetch "https://pro-api.coingecko.com/api/v3/x402/simple/price?ids=bonk&vs_currencies=usd" --json
# 4. Check Twitter sentiment before committing — $0.01
sol fetch "https://api.portalsprotocol.com/twitter/search" -X POST \
-d '{"query": "BONK solana"}' -H "Content-Type: application/json" --json
# 5. Sentiment is positive, volume is up — buy
sol token swap 20 usdc bonk --json
# 6. Record the portfolio state
sol portfolio snapshot --label "bonk-entry"
The agent gathered market data, cross-referenced with social sentiment, made a decision, executed a trade, and recorded its state. Total x402 cost: $0.03.
React to macro news and rebalance
An agent monitors news and rebalances a portfolio across asset classes — including tokenized equities and commodities available on Solana:
# 1. Check breaking news — $0.10
sol fetch "https://api.syraa.fun/news" -X POST \
-d '{"query": "tariffs trade war"}' -H "Content-Type: application/json" --json
# 2. The agent reads the response: new tariffs announced, risk-off sentiment likely
# 3. Check current portfolio exposure
sol portfolio --json
# 4. Reduce equity exposure — sell tokenized Nasdaq ETF for USDC
sol token swap 100 qqqx usdc --json
# 5. Increase gold allocation — buy tokenized gold
sol token swap 150 usdc xaux --json
# 6. Snapshot the new state
sol portfolio snapshot --label "tariff-rebalance"
The agent read the news, reasoned about macro implications, and rebalanced across asset classes — from a tokenized Nasdaq ETF to tokenized gold — in under a minute. Total x402 cost: $0.10.
Instructing Your AI Agent to Use x402 APIs
If you're running an AI agent with shell access (Claude Code, OpenClaw, or similar), you can point it at x402 endpoints with natural language. Here are example prompts:
Research trending Solana pools on CoinGecko, find the highest-volume one, check the token's price, and buy $20 worth.
Check Twitter sentiment around BONK using Portals Protocol, get the current pool data from CoinGecko, and tell me if it looks like a good entry point.
Scrape the Raydium docs page using x402engine and summarise what yield strategies are available.
Monitor crypto news every 30 minutes. If anything mentions Solana regulatory action, immediately sell all non-stablecoin positions and snapshot the portfolio.
The agent uses sol fetch for the paid data and the rest of Sol CLI for trading, portfolio management, and record-keeping. All commands support --json for structured output the agent can parse.
Controlling x402 Spending: Caps, Permissions, and Wallets
Giving an agent access to a wallet that can pay for things requires guardrails.
Check before you pay. --dry-run shows exactly what a request will cost before any money moves:
sol fetch "https://pro-api.coingecko.com/api/v3/x402/onchain/networks/solana/trending_pools" --dry-run
Cap per-request spending. --max sets a hard limit. If the endpoint charges more than your cap, the request is rejected before any payment is signed:
sol fetch "https://api.syraa.fun/news" -X POST -d '{"query":"solana"}' --max 0.05
This would reject the request — Syraa charges $0.10, which exceeds the $0.05 cap.
Disable the command entirely. In Sol CLI's config, set canFetch = false to prevent the agent from making any x402 payments:
[permissions]
canFetch = false
When canFetch is disabled, the sol fetch command doesn't even register — it's not hidden behind a flag, it's absent from the CLI entirely.
Use a dedicated wallet. Fund a separate wallet with a limited USDC balance for agent operations. The agent can only spend what's in that wallet:
sol wallet create agent-wallet
sol token send 10 usdc agent-wallet
sol fetch "https://api.example.com/data" --wallet agent-wallet
Note on transaction flow: When you use sol fetch, your wallet signs the payment transaction but does not submit it to the network. The server (or its facilitator service) handles submission and confirmation. This is by design in the x402 protocol — the server needs to verify payment before releasing the data.
All Verified x402 Endpoints on Solana
Every endpoint below has been tested with sol fetch --dry-run and confirmed to return x402 payment requirements on Solana.
Market Data & Crypto Intelligence
| Service | Cost | Endpoint |
|---|---|---|
| CoinGecko | $0.01 | GET https://pro-api.coingecko.com/api/v3/x402/simple/price?ids=solana&vs_currencies=usd |
| CoinGecko | $0.01 | GET https://pro-api.coingecko.com/api/v3/x402/onchain/networks/solana/trending_pools |
| CoinGecko | $0.01 | GET https://pro-api.coingecko.com/api/v3/x402/onchain/search/pools?query=bonk |
| x402engine | $0.001 | GET https://x402engine.app/api/crypto/price?symbol=SOL |
| Syraa | $0.10 | GET https://api.syraa.fun/dexscreener |
| Syraa | $0.10 | GET https://api.syraa.fun/trending-jupiter |
| Syraa | $0.10 | POST https://api.syraa.fun/news |
Social Data
| Service | Cost | Endpoint |
|---|---|---|
| Portals Protocol | $0.001 | POST https://api.portalsprotocol.com/twitter/user |
| Portals Protocol | $0.01 | POST https://api.portalsprotocol.com/twitter/search |
| Portals Protocol | $0.005 | POST https://api.portalsprotocol.com/instagram/profile |
Web Scraping & Content
| Service | Cost | Endpoint |
|---|---|---|
| x402engine | $0.005 | GET https://x402engine.app/api/web/scrape?url=https://example.com |
| OnVoyage | $0.01 | GET https://v402pay.onvoyage.ai/api/pay/<articleId> |
AI & Infrastructure
| Service | Cost | Endpoint |
|---|---|---|
| Tropir | $0.10 | GET https://tropir.xyz/api/cortex/access |
Prices range from $0.001 to $0.10 per request. For most use cases, an agent can do meaningful research for well under a dollar.
Further Reading
- x402 Protocol specification — the full protocol spec, maintained by Coinbase and the x402 Foundation
- x402list.fun — directory of all x402-enabled services, filterable by chain and category
- Sol CLI Complete Guide — full documentation for all Sol CLI commands
- Agent Permissions & Security — how to configure spending limits, allowlists, and permission flags
x402 endpoints, pricing, and availability may change without notice. Always use --dry-run to verify current costs before authorising agent spending. The services listed here are third-party providers — Sol CLI facilitates the payment but does not control the data they return.
On this page
- Why AI Agents Need x402 Instead of API Keys
- How x402 Payments Work with `sol fetch`
- x402 Services Available on Solana Today
- x402 in Action: End-to-End AI Agent Workflows
- Instructing Your AI Agent to Use x402 APIs
- Controlling x402 Spending: Caps, Permissions, and Wallets
- All Verified x402 Endpoints on Solana
- Further Reading
Related Content
The Rise Of AI Agents | Jeffy Yu & Yash Agarwal
Dive into the world of AI agents on Solana with Jeffy Yu and Yash Agarwal. Discover the potential of decentralized AI, DeFi agents, and Solana's competitive advantages in this emerging space.
Sol CLI: A Solana Skill for AI Agents
A Solana skill for OpenClaw, Claude Code, and AI agents. Trade tokens, manage wallets, stake SOL, earn yield, and track portfolios — no API keys, no code.
Ship or Die at Accelerate 2025: Time Is Money (Kawz - Time.fun)
Kawz introduces Time.fun, a platform that tokenizes time and creates new capital markets on Solana
Ship or Die at Accelerate 2025: Capital Market Fit
Venture capitalists Breck Stodghill and Clay Robbins discuss the importance of capital market fit for startups in the Solana ecosystem
Collector Crypt: Onchain Capital Markets On Solana | Tuomas Holmberg
Discover how Collector Crypt is revolutionizing the $10B+ trading card industry by bringing physical collectibles on-chain with positive EV mechanics, AI pricing oracles, and deep Solana integration.
A Guide to Solana's New Paradigm | Mert Mumtaz, Garrett Harper
Explore Solana's recent surge, the Jito airdrop's impact, and how integrated chains are reshaping the blockchain landscape. Learn about client diversity, ecosystem growth, and exciting projects in the Solana space.
The Solana Ecosystem Call [December 2024]
Explore Solana's explosive growth in DeFi, AI integration, and meme coin impact. Learn about new projects and the future of decentralized science on Solana.
WTF RPC? w/ Brian Long (Triton One)
Dive deep into the world of RPC services with Brian Long from Triton One. Explore how RPCs enhance blockchain usability, data retrieval, and transaction processing on Solana and beyond.
Solana DeFi Summer Is Coming | Sang Kim
Fragmetric co-founder Sang Kim explains how Solana DATs could drive restaking adoption, generate sustainable DeFi yields, and why he's more bullish on Solana restaking than Eigenlayer.
TOP 5 Books Every Founder Needs With Cris Heaney from Drift Protocol | ep. 23
Discover the must-read books for aspiring founders in crypto and tech, as recommended by Drift Protocol's CTO. Gain insights on marketing, community building, and entrepreneurship in the Solana ecosystem.
Ship or Die at Accelerate 2025: Tokenization of Capital Markets (Nathan Allman - Ondo Finance)
Nathan Allman of Ondo Finance discusses the future of tokenization and its impact on capital markets
Solana Changelog - April 9 - Flare and GetEpochStake
Discover the latest Solana upgrades including GetEpochStake, improved indexing, and the Flare CLI tool. Learn how these changes enhance performance and developer experience on Solana.
SOL Needs More Than DAT | Anna Yuan
Anna Yuan discusses why Solana is falling behind in the DAT race, what the ecosystem can learn from Bitcoin and Ethereum, and her vision for a Solana DAT strategy.
The Lack of Bold Bets in Crypto | Weekly Roundup
Explore the challenges facing crypto innovation, the potential of DePIN projects on Solana, and the evolving landscape of SocialFi in this insightful podcast discussion.
Solana Changelog April 18 - Automatic Repair, Saga, and Helium
Explore Solana's recent advancements including the Saga phone launch, Helium's migration to Solana, and a groundbreaking proposal for automatic cluster repair and restart.
- Borrow / Lend
- Liquidity Pools
- Token Swaps & Trading
- Yield Farming
- Solana Explained
- Is Solana an Ethereum killer?
- Transaction Fees
- Why Is Solana Going Up?
- Solana's History
- What makes Solana Unique?
- What Is Solana?
- How To Buy Solana
- Agent Permissions & Security
- AI Agent Financial Markets
- Solana Agent Skill
- Complete Sol CLI Guide
- AI Agent Prediction Markets
- x402 Agent API Payments
- Solana's Best Projects: Dapps, Defi & NFTs
- Choosing The Best Solana Validator
- Staking Rewards Calculator
- Liquid Staking
- Can You Mine Solana?
- Solana Staking Pools
- Stake with us
- How To Unstake Solana
- How validators earn
- Best Wallets For Solana
