Agents that pay their own way.
A Next.js demo showing LLM agents that autonomously handle HTTP 402 Payment Required responses using real Solana transactions - no API keys, no billing, no humans in the loop.
Live at agent.mpptestkit.com
- Agent generates an ephemeral Solana keypair
- Requests an airdrop from the devnet/testnet faucet
- Hits a premium API endpoint → receives
402 Payment Required - Parses the
Payment-Requestheader, sends a real SOL transfer on-chain - Retries the request with a
Payment-Receiptheader → receives200 OK+ data - Every step streams live to the terminal UI via SSE
The payment transaction is real - you can verify it on Solana Explorer.
- Next.js 14 (App Router)
- @solana/web3.js - real devnet/testnet transactions
- Tailwind CSS
- SSE (Server-Sent Events) for real-time streaming
npm install
npm run dev # http://localhost:5174POST /api/agent accepts:
{ "query": "Get current SOL market data", "network": "devnet" }It streams SSE events:
| type | description |
|---|---|
init |
Keypair generation started |
wallet |
Keypair ready, public key included |
fund |
Airdrop request / confirmation |
request |
Initial GET to premium endpoint |
payment_required |
402 received, Payment-Request header parsed |
payment |
SOL transfer being built and sent |
confirmed |
On-chain confirmation + real tx signature |
retry |
Request retried with Payment-Receipt |
success |
200 OK received |
result |
Premium data payload |
done |
Stream complete |
error |
Agent error with message |
| Query | Endpoint |
|---|---|
| SOL market data | /premium/market/sol |
| Analytics report | /premium/analytics |
| ML inference | /premium/ml/inference |
| Research data | /premium/research |
devnet- default, fastest airdrop availabilitytestnet- also supported, same flow