x402: For AI Agents
Every agent has a wallet. Send a transaction, get data. No account, no API key, no KYT , or x402 facilitator — just $0.05 USDC on Solana per request, verified directly on-chain.
How an Agent Pays for Data
An AI agent wants to call /api/v1/markets/ttc-scanner. Here's the complete flow from the agent's perspective — pure HTTP, one Solana transfer, zero intermediaries.
Agent needs asset scanner data for BTCUSDT. No API key, no account, no session.
https://ttc.box/api/v1/markets/ttc-scanner?symbol=BTCUSDT&timeframe=1hNo payment header found. Server responds with HTTP 402 containing payment instructions: send 50000 microUSDC ($0.05) to the treasury wallet on Solana mainnet.
{
"success": false,
"status": 402,
"error": "Payment Required - X402 payment header required",
"code": 402,
"paymentRequired": {
"accepts": {
"scheme": "exact",
"network": "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",
"payTo": "5GqzwqFNJig39qkVoPRuH9nKfndUs16x2QP62YoVC9uK",
"price": {
"amount": "50000",
"asset": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"
},
"maxTimeoutSeconds": 300,
"description": "Access to /api/v1/markets/ttc-scanner endpoint",
"mimeType": "application/json"
},
"paymentUrl": "solana:5GqzwqFNJig39qkVoPRuH9nKfndUs16x2QP62YoVC9uK?recipient=5GqzwqFNJig39qkVoPRuH9nKfndUs16x2QP62YoVC9uK&amount=50000&spl-token=EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v&reference=x402_1774241343379_330dd38ee594&label=TTC+Box+API&message=Access+to+%2Fapi%2Fv1%2Fmarkets%2Fttc-scanner+endpoint",
"expiresIn": 300
}
}Agent reads the paymentRequired object: extracts payTo address, amount (50000), USDC mint address, and the Solana network identifier. All the agent needs to construct a payment.
{
"success": false,
"status": 402,
"error": "Payment Required - X402 payment header required",
"code": 402,
"paymentRequired": {
"accepts": {
"scheme": "exact",
"network": "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",
"payTo": "5GqzwqFNJig39qkVoPRuH9nKfndUs16x2QP62YoVC9uK",
"price": {
"amount": "50000",
"asset": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"
},
"maxTimeoutSeconds": 300,
"description": "Access to /api/v1/markets/ttc-scanner endpoint",
"mimeType": "application/json"
},
"paymentUrl": "solana:5GqzwqFNJig39qkVoPRuH9nKfndUs16x2QP62YoVC9uK?recipient=5GqzwqFNJig39qkVoPRuH9nKfndUs16x2QP62YoVC9uK&amount=50000&spl-token=EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v&reference=x402_1774241343379_330dd38ee594&label=TTC+Box+API&message=Access+to+%2Fapi%2Fv1%2Fmarkets%2Fttc-scanner+endpoint",
"expiresIn": 300
}
}Agent creates a Solana SPL token transfer: 50000 microUSDC from its wallet to payTo address, signs with its private key, sends via Solana RPC. Gets back a transaction signature.
x-x402-paymentAgent base64-encodes { signature, payer, amount, timestamp } and re-sends the original request with the x-x402-payment header.
Server calls connection.getTransaction(signature) directly on Solana RPC. Checks: tx succeeded, tx is within 300s, treasury received >= 50000 microUSDC. Checks DB for replay. No facilitator involved.
Payment verified. Server returns 200 OK with asset analysis, scoring data, and current price. Agent has its data. Total cost: $0.05 + ~$0.00025 Solana gas.
1. Agent requests data (no credentials)
GET /api/v1/markets/ttc-scanner?symbol=BTCUSDT&timeframe=1h HTTP/1.1 Host: ttc.box
2. Server tells agent how to pay
HTTP/1.1 402 Payment Required
{
"success": false,
"code": 402,
"error": "Payment Required",
"paymentRequired": {
"accepts": {
"scheme": "exact",
"network": "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",
"payTo": "5GqzwqFNJig39qkVoPRuH9nKfndUs16x2QP62YoVC9uK",
"price": {
"amount": "50000",
"asset": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"
},
"maxTimeoutSeconds": 300,
"description": "Access to /api/v1/markets/ttc-scanner"
},
"paymentUrl": "solana:6JhyWcR...?amount=50000&spl-token=EPjFWdd5...",
"expiresIn": 300
}
}3. Agent pays $0.05 USDC on Solana, retries with proof
GET /api/v1/markets/ttc-scanner?symbol=BTCUSDT&timeframe=1h HTTP/1.1
Host: ttc.box
x-x402-payment: x402:eyJzaWduYXR1cmUiOiI1VnFCZ2...base64...// Decoded x-x402-payment payload:
{
"signature": "5VqBgkR9xH7...", // Solana tx signature
"payer": "7xKXtg2CW87a...", // Agent's wallet
"amount": "50000", // $0.05 USDC
"timestamp": 1711152000000
}4. Server verifies on Solana, returns data
HTTP/1.1 200 OK
{
"success": true,
"timestamp": 1711152001234,
"params": {
"symbol": "BTCUSDT",
"timeframe": "1h",
"bars": 1000,
"swingStrength": 10
},
"data": {
"symbol": "BTCUSDT",
"price": 67432.50,
"scans": [
{
"symbol": "BTCUSDT",
"currentPrice": 67432.50,
"pivotType": "low",
"pivot": {
"index": 847,
"price": 59180.00,
"time": 1710892800000,
"type": "low"
},
"fanDirection": "ascending",
"angles": [
{ "label": "1x8", "ratio": 0.125, "priceAtNow": 61073.12 },
{ "label": "1x4", "ratio": 0.25, "priceAtNow": 62966.25 },
{ "label": "1x2", "ratio": 0.5, "priceAtNow": 66752.50 },
{ "label": "1x1", "ratio": 1.0, "priceAtNow": 74325.00 },
{ "label": "2x1", "ratio": 2.0, "priceAtNow": 89470.00 }
],
"aboveAngle": { "label": "1x2", "priceAtNow": 66752.50 },
"belowAngle": { "label": "1x1", "priceAtNow": 74325.00 },
"zone": "Between 1x2 and 1x1",
"zoneStrength": 6,
"priceTimeRatio": 98.82,
"barsFromPivot": 153,
"timeframe": "1h",
"momentum": {
"rsi": 58.3,
"trend": "bullish",
"strength": 0.64
},
"riskRewardLong": {
"entry": 67432.50,
"stopLoss": 66752.50,
"target": 74325.00,
"riskReward": 10.13
},
"riskRewardShort": {
"entry": 67432.50,
"stopLoss": 74325.00,
"target": 66752.50,
"riskReward": 0.10
}
},
{
"symbol": "BTCUSDT",
"currentPrice": 67432.50,
"pivotType": "high",
"pivot": {
"index": 912,
"price": 71890.00,
"time": 1711036800000,
"type": "high"
},
"fanDirection": "descending",
"angles": [
{ "label": "1x8", "ratio": 0.125, "priceAtNow": 70821.50 },
{ "label": "1x4", "ratio": 0.25, "priceAtNow": 69765.00 },
{ "label": "1x2", "ratio": 0.5, "priceAtNow": 67640.00 },
{ "label": "1x1", "ratio": 1.0, "priceAtNow": 63390.00 },
{ "label": "2x1", "ratio": 2.0, "priceAtNow": 54890.00 }
],
"aboveAngle": { "label": "1x2", "priceAtNow": 67640.00 },
"belowAngle": { "label": "1x4", "priceAtNow": 69765.00 },
"zone": "Between 1x2 and 1x4",
"zoneStrength": 4,
"priceTimeRatio": 98.82,
"barsFromPivot": 88,
"timeframe": "1h"
}
],
"scoring": {
"symbol": "BTCUSDT",
"currentPrice": 67432.50,
"timestamp": 1711152001234,
"pivotHigh": {
"index": 912,
"price": 71890.00,
"time": 1711036800000
},
"pivotLow": {
"index": 847,
"price": 59180.00,
"time": 1710892800000
},
"long": {
"score": 68,
"proximity": 24,
"respect": 18,
"trend": 16,
"harmony": 10
},
"short": {
"score": 35,
"proximity": 12,
"respect": 8,
"trend": 9,
"harmony": 6
},
"preferredDirection": "long"
}
}
}