Back to Crypto

x402: For AI Agents

Agent-Native
From $0.05 USDC / Request
No Account Required
No Third-Party Facilitator
Solana Mainnet

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.

Instant Access
The agent doesn't register, log in, or manage API keys. It just needs a Solana wallet with USDC, plus a little SOL for the network fee. Send payment, attach proof, get data.
Fast Settlement
Solana slots last well under a second, so a USDC transfer usually confirms within seconds. The agent sends USDC, waits for confirmation, then retries the request.
Pay Per Request
Most endpoints cost $0.05; the full scanner snapshot costs $0.50. You also pay the Solana network fee: 5,000 lamports per signature. No subscription, no billing dashboard. Rate-limited per payer; a 429 never charges you.
1
Agent
Request Market Data

Agent needs asset scanner data for BTCUSDT. No API key, no account, no session.

https://www.tetrac.xyz/api/v1/markets/ttc-scanner?symbol=BTCUSDT&timeframe=1h
2
TTC Server
402 Payment Required

No payment header found. Server responds with HTTP 402 and a canonical x402 v2 body: accepts[0] asks for 50000 microUSDC ($0.05) of USDC, sent to the treasury on Solana mainnet. The legacy paymentRequired block repeats the same terms.

{ "success": false, "status": 402, "error": "Payment Required - X402 payment header required", "code": 402, "x402Version": 2, "accepts": [ { "scheme": "exact", "network": "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp", "amount": "50000", "asset": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", "payTo": "2uSZu6jhF7ZT7bREmQZeiJCEgynN2Qwpqa3BtaxhxxBM", "maxTimeoutSeconds": 300, "resource": "https://www.tetrac.xyz/api/v1/markets/ttc-scanner", "extra": { "name": "USDC" } } ], "resource": { "url": "https://www.tetrac.xyz/api/v1/markets/ttc-scanner", "description": "Access to /api/v1/markets/ttc-scanner endpoint", "mimeType": "application/json" }, "paymentRequired": { "accepts": { "scheme": "exact", "network": "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp", "payTo": "2uSZu6jhF7ZT7bREmQZeiJCEgynN2Qwpqa3BtaxhxxBM", "price": { "amount": "50000", "asset": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v" }, "maxTimeoutSeconds": 300, "description": "Access to /api/v1/markets/ttc-scanner endpoint", "mimeType": "application/json" }, "paymentUrl": "solana:2uSZu6jhF7ZT7bREmQZeiJCEgynN2Qwpqa3BtaxhxxBM?amount=0.05&spl-token=EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v&reference=kgERWXbLfq6MHcWLd86a5dpmSvM86QhQrQjL2gGPbnD&label=Tetrac+API&message=Access+to+%2Fapi%2Fv1%2Fmarkets%2Fttc-scanner+endpoint", "expiresIn": 300 } }
3
Agent
Parse 402 Response

Agent reads accepts[0]: payTo, amount (50000 microUSDC), asset (the USDC mint) and network (Solana mainnet). That is everything it needs to construct a payment.

{ "scheme": "exact", "network": "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp", "amount": "50000", "asset": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", "payTo": "2uSZu6jhF7ZT7bREmQZeiJCEgynN2Qwpqa3BtaxhxxBM", "maxTimeoutSeconds": 300, "resource": "https://www.tetrac.xyz/api/v1/markets/ttc-scanner", "extra": { "name": "USDC" } }
4
Agent
Send $0.05 USDC on Solana

Agent creates a Solana SPL token transfer: accepts[0].amount (50000 microUSDC) from its wallet to the payTo address, signs it as fee payer with its own key, and sends it via Solana RPC. Gets back a transaction signature.

5
Agent
Retry with Payment Proofx-x402-payment

Agent base64-encodes { signature, payer, amount, timestamp } (timestamp in epoch milliseconds), prefixes it with "x402:", and re-sends the original request with the x-x402-payment header.

6
TTC Server
Verify On-Chain (No Third-Party Facilitator)

Server checks the payer's rate limit first (a 429 never charges you), leases the signature so it can be redeemed only once, then fetches the transaction from Solana RPC: it must have succeeded, landed within the last 300 s, and paid the treasury at least the quoted amount. No third-party facilitator involved.

7
TTC Server
Return Scanner Data

Payment verified. Server returns 200 OK with asset analysis, scoring data, and current price. Agent has its data. Total cost: $0.05 USDC plus the Solana network fee (5,000 lamports per signature).

Complete HTTP Exchange
Exactly what the agent sends and receives

1. Agent requests data (no credentials)

GET /api/v1/markets/ttc-scanner?symbol=BTCUSDT&timeframe=1h HTTP/1.1
Host: www.tetrac.xyz

2. Server tells agent how to pay

HTTP/1.1 402 Payment Required
WWW-Authenticate: x402 realm="https://www.tetrac.xyz/api/v1/markets/ttc-scanner"
payment-required: eyJ4NDAyVmVyc2lvbiI6MiwiYWNjZXB0cyI6W3si...

{
  "success": false,
  "status": 402,
  "error": "Payment Required - X402 payment header required",
  "code": 402,
  "x402Version": 2,
  "accepts": [
    {
      "scheme": "exact",
      "network": "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",
      "amount": "50000",
      "asset": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
      "payTo": "2uSZu6jhF7ZT7bREmQZeiJCEgynN2Qwpqa3BtaxhxxBM",
      "maxTimeoutSeconds": 300,
      "resource": "https://www.tetrac.xyz/api/v1/markets/ttc-scanner",
      "extra": {
        "name": "USDC"
      }
    }
  ],
  "resource": {
    "url": "https://www.tetrac.xyz/api/v1/markets/ttc-scanner",
    "description": "Access to /api/v1/markets/ttc-scanner endpoint",
    "mimeType": "application/json"
  },
  "paymentRequired": {
    "accepts": {
      "scheme": "exact",
      "network": "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",
      "payTo": "2uSZu6jhF7ZT7bREmQZeiJCEgynN2Qwpqa3BtaxhxxBM",
      "price": {
        "amount": "50000",
        "asset": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"
      },
      "maxTimeoutSeconds": 300,
      "description": "Access to /api/v1/markets/ttc-scanner endpoint",
      "mimeType": "application/json"
    },
    "paymentUrl": "solana:2uSZu6jhF7ZT7bREmQZeiJCEgynN2Qwpqa3BtaxhxxBM?amount=0.05&spl-token=EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v&reference=kgERWXbLfq6MHcWLd86a5dpmSvM86QhQrQjL2gGPbnD&label=Tetrac+API&message=Access+to+%2Fapi%2Fv1%2Fmarkets%2Fttc-scanner+endpoint",
    "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: www.tetrac.xyz
x-x402-payment: x402:eyJzaWduYXR1cmUiOiI1VnFCZ2...base64...// Decoded x-x402-payment payload:
{
  "signature": "5VqBgkR9xH7...",   // Solana tx signature
  "payer": "7xKXtg2CW87a...",      // Agent's wallet
  "amount": "50000",                // accepts[0].amount ($0.05 USDC)
  "timestamp": 1711152000000        // epoch milliseconds (Date.now())
}

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"
    }
  }
}