x402 crypto data gateway on Stellar for AI agents
AgentPay — your agent is only as smart as its data.
AgentPay is an open x402 payment gateway that lets AI agents autonomously access real crypto data tools using USDC on Stellar or Base.
No subscriptions. No API keys. No human in the loop. Agents discover tools, pay per call ($0.001–$0.005), and get real data back — all within a hard budget cap.
→ 12 live tools: token prices, whale activity, gas tracker, DeFi TVL, Fear & Greed, yield scanner, funding rates, token security, Dune queries and more → Budget-aware Session: agents estimate costs, track spend, never exceed budget → x402 protocol: works with any x402-compatible agent → Two payment networks: Stellar (5s, $0.00001 fee) or Base mainnet USDC (2s, $0.0001 fee)
Try it in 60 seconds:
curl https://gateway-production-2cc2.up.railway.app/faucet
Or open the browser faucet: https://gateway-production-2cc2.up.railway.app/faucet/ui
Live gateway: https://gateway-production-2cc2.up.railway.app
Quickstart — 3 steps
Step 1: Get a funded test wallet
One call gives you a ready-to-use Stellar testnet wallet with 5 USDC pre-loaded:
curl https://gateway-production-2cc2.up.railway.app/faucet
Or use the browser faucet — click "Get Test Wallet", copy the snippet, run it.
Step 2: Create a Session with a budget
from agent.wallet import AgentWallet, Session, BudgetExceeded
wallet = AgentWallet(
secret_key="S...", # your Stellar secret key
network="testnet", # or "mainnet"
)
GATEWAY = "https://gateway-production-2cc2.up.railway.app"
with Session(wallet=wallet, gateway_url=GATEWAY, max_spend="0.05") as session:
print(f"Balance: {wallet.get_usdc_balance()} USDC")
print(f"Budget: {session.remaining()} remaining")
The Session enforces a hard USDC cap across all calls. It raises BudgetExceeded before any payment goes out if a tool would push you over, and automatically falls back to the next-cheapest tool in the same category when the preferred one is too expensive.
Step 3: Call tools — payment is automatic
with Session(wallet=wallet, gateway_url=GATEWAY, max_spend="0.05") as session:
# Token price — $0.001
r = session.call("token_price", {"symbol": "ETH"})
print(f"ETH: ${r['price_usd']:,.2f} ({r['change_24h_pct']:+.2f}% 24h)")
# Fear & Greed Index — $0.001
r = session.call("fear_greed_index", {"limit": 1})
print(f"Sentiment: {r['value']}/100 — {r['value_classification']}")
# DeFi TVL — $0.002
r = session.call("defi_tvl", {"protocol": "aave"})
print(f"Aave TVL: ${r['tvl'] / 1e9:.1f}B ({r['change_1d']:+.1f}% 24h)")
# Crypto news — $0.003
r = session.call("crypto_news", {"currencies": "ETH", "filter": "hot"})
for h in r["headlines"][:3]:
print(f" [{h['sentiment']:>7}] {h['title'][:55]}")
print(f"\nTotal spent: {session.spent()}")
print(f"Remaining: {session.remaining()}")
Each session.call() handles the full x402 flow internally:
- Checks your remaining budget against the tool's price (pre-flight, no payment yet)
- POSTs to the gateway, receives a
402with{payment_id, amount_usdc, pay_to} - Sends USDC on Stellar — ~2–3 seconds on testnet
- Retries the request with
X-Payment: tx_hash=<hash>,from=<addr>,id= - Returns the data
Available Tools
| Tool | Price | Parameters | Returns |
|---|---|---|---|
token_price |
$0.001 | symbol (BTC, ETH, SOL…) |
price_usd, change_24h_pct, market_cap_usd |
gas_tracker |
$0.001 | — | slow/standard/fast gwei, base_fee_gwei |
fear_greed_index |
$0.001 | limit (days of history, default 1) |
value 0–100, value_classification, history[ ] |
wallet_balance |
$0.002 | address, chain (ethereum/stellar) |
token balances |
whale_activity |
$0.002 | token, min_usd (default 100k) |
large_transfers[ ], total_volume_usd |
defi_tvl |
$0.002 | protocol (optional, e.g. "uniswap") |
tvl, change_1d, change_7d, chains[ ] |
token_security |
$0.002 | contract_address, chain (ethereum/bsc) |
risk_level, is_honeypot, buy_tax, sell_tax, holder_count |
yield_scanner |
$0.004 | token, chain (optional), min_tvl (default $1M) |
top 10 pools by APY with protocol, tvl_usd, risk_level |
dex_liquidity |
$0.003 | token_a, token_b |
volume_24h_usd, market_cap_usd, ath_usd |
funding_rates |
$0.003 | asset (optional, e.g. "BTC") |
funding_rate_pct, annualized_rate_pct, sentiment per exchange |
crypto_news |
$0.003 | currencies (e.g. "ETH,BTC"), filter (hot/new/rising) |
headlines[ ] with title, url, sentiment, score |
dune_query |
$0.005 | query_id, limit (default 25) |
rows[ ], columns[ ], row_count from Dune Analytics |
Discover all tools dynamically:
import httpx
tools = httpx.get(f"{GATEWAY}/tools").json()["tools"]
for t in tools:
prin
Tools (12)
token_priceGet current price, 24h change, and market cap for a token.gas_trackerGet current gas fees.fear_greed_indexGet the current crypto fear and greed index.wallet_balanceCheck token balances for a specific address.whale_activityTrack large token transfers.defi_tvlGet total value locked for a protocol.token_securityCheck security risks for a contract address.yield_scannerFind top liquidity pools by APY.dex_liquidityGet liquidity and volume data for token pairs.funding_ratesGet funding rates for crypto assets.crypto_newsGet recent crypto news headlines.dune_queryExecute queries on Dune Analytics.Environment Variables
STELLAR_SECRET_KEYrequiredThe secret key for the Stellar wallet used to pay for tool calls.Configuration
{"mcpServers": {"agentpay": {"command": "npx", "args": ["-y", "@romudille-bit/agentpay"], "env": {"STELLAR_SECRET_KEY": "YOUR_SECRET_KEY"}}}}