x402 for TRON

April 4, 2026 ยท View on GitHub

The first x402 payment protocol facilitator for the TRON network. Accept USDT, USDC, and USDD payments from AI agents and humans with a single HTTP header.

Live at: x402.merx.exchange

What is x402?

x402 is an open HTTP payment protocol created by Coinbase and Cloudflare. When a server requires payment, it returns HTTP 402 with payment instructions. The client pays on-chain, receives a JWT authorization, and retries the request. No accounts, no API keys, no credit cards.

x402 has processed 161M+ transactions and $43.57M+ in volume across Base, Solana, Stellar, and Ethereum. TRON was missing from this list -- until now.

TRON carries $85B+ in USDT -- 63% of the global stablecoin supply. This facilitator connects that liquidity to the x402 ecosystem.

Quick Start

For API Sellers (accept TRON payments)

npm install merx-x402
import express from 'express'
import { requirePayment } from 'merx-x402'

const app = express()

app.get('/premium-data', requirePayment({
  amount: '0.10',
  recipient: 'TYourTronAddress',
}), (req, res) => {
  res.json({ data: 'premium content' })
})

app.listen(3000)

That's it. Any agent with USDT on TRON can now pay for your API.

For AI Agents (pay for APIs)

// Agent encounters a 402 response
const res = await fetch('https://api.example.com/premium-data')
// res.status === 402
// res.headers['x-payment-required'] contains payment details

// Agent pays on TRON (using any TRON wallet/SDK)
const txid = await tronWeb.trx.sendTransaction(...)

// Agent gets authorization from MERX facilitator
const auth = await fetch('https://x402.merx.exchange/facilitate', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({ txid, amount: 100000, to: 'TRecipient' })
})
const { authorization } = await auth.json()

// Agent retries with authorization
const data = await fetch('https://api.example.com/premium-data', {
  headers: { 'X-Payment-Authorization': `${txid}:${authorization}` }
})
// 200 OK - content served

How It Works

Agent                     Server                    MERX Facilitator
  |                         |                            |
  |--- GET /api/data ------>|                            |
  |<-- 402 Payment Required |                            |
  |    (amount, recipient,  |                            |
  |     facilitator URL)    |                            |
  |                         |                            |
  |--- TRON: send USDT ----|------- on-chain TX -------->|
  |                         |                            |
  |--- POST /facilitate ----|-------------------------->|
  |    { txid }             |                            |
  |<-- { authorization } ---|<--------------------------|
  |                         |                            |
  |--- GET /api/data ------>|                            |
  |    + X-Payment-Auth     |                            |
  |                         |--- GET /verify/:txid ----->|
  |                         |<-- { valid: true } --------|
  |<-- 200 OK + content ----|                            |

API Reference

POST /facilitate

Verify a TRON payment and issue a JWT authorization.

curl -X POST https://x402.merx.exchange/facilitate \
  -H "Content-Type: application/json" \
  -d '{
    "txid": "7a92e577b3f44faa97204983af3e74a71cac5a88732af54fca9c2464d9285ca4",
    "amount": 100000,
    "to": "TRecipientAddress"
  }'

Response:

{
  "authorization": "eyJhbGciOiJIUzI1NiIs...",
  "expires_at": "2026-04-05T12:00:00.000Z"
}

Confirmation speed:

  • Amounts < $100: ~3 seconds (block confirmation)
  • Amounts >= $100: ~54 seconds (irreversible confirmation)

GET /verify/:txid

Verify an authorization is valid (called by the API seller).

curl https://x402.merx.exchange/verify/7a92e577b3f44faa97204983af3e74a71cac5a88732af54fca9c2464d9285ca4
{
  "valid": true,
  "used": false,
  "expires_at": "2026-04-05T12:00:00.000Z"
}

POST /invalidate

Mark an authorization as used (prevents replay).

curl -X POST https://x402.merx.exchange/invalidate \
  -H "Content-Type: application/json" \
  -d '{"txid": "7a92e577..."}'
{ "invalidated": true }

GET /health

Service status and confirmation parameters.

curl https://x402.merx.exchange/health
{
  "status": "ok",
  "service": "x402-facilitator",
  "network": "tron",
  "asset": "USDT",
  "contract": "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t",
  "confirmation": {
    "fast": { "threshold_usdt": 100, "latency_ms": 3000 },
    "safe": { "threshold_usdt": null, "latency_ms": 54000 }
  }
}

GET /.well-known/x402

Discovery document for automatic facilitator detection.

curl https://x402.merx.exchange/.well-known/x402

Supported Tokens

TokenContractDecimals
USDTTR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t6
USDCTEkxiTehnzSmSe2XqrBj4w32RUN966rdz86
USDDTPYmHEhy5n8TCEfYGqW2rPxsghSfzghPDn18

Express Middleware

The merx-x402 npm package provides drop-in Express middleware:

npm install merx-x402
import { requirePayment, invalidatePayment } from 'merx-x402'

// Require payment on any route
app.get('/api/premium', requirePayment({
  amount: '0.10',        // USDT amount
  recipient: 'TYour...', // Your TRON address
  // Optional:
  asset: 'USDT',         // default: USDT
  network: 'tron',       // default: tron
  facilitator: 'https://x402.merx.exchange', // default
  description: 'Access to premium data',
}), handler)

// After serving content, invalidate to prevent replay
app.get('/api/premium', requirePayment({...}), async (req, res) => {
  res.json({ data: '...' })
  await invalidatePayment(req.payment.txid)
})

Pricing

UsageCost
First 50 settlements/monthFree
Additional settlements$0.01 each

Billing requires an API key from merx.exchange. Without an API key, facilitation still works but is rate-limited.

Mainnet Verification

This facilitator is live on TRON mainnet. Verified transaction:

TX 7a92e577... - USDT payment verified on-chain, JWT authorization issued.

Why TRON for x402?

  • $85B+ USDT in circulation on TRON (63% of global supply)
  • $21.5B daily transfer volume
  • 56% of global retail USDT transfers (< $1,000)
  • 3-second block time (vs 12s Ethereum, 0.4s Solana)
  • Sub-cent transaction costs with energy delegation

TRON is where stablecoins live. x402 on TRON connects AI agents to the largest USDT liquidity pool in crypto.

Architecture

MERX operates a dedicated TRON Lite FullNode in the same datacenter as the facilitator. Payment verification happens directly on our node -- no TronGrid dependency, no API rate limits, sub-5ms latency.

For amounts under $100 (99% of x402 use cases), we confirm via block inclusion (~3 seconds). For larger amounts, we wait for irreversible confirmation (~54 seconds, 18 blocks). TRON's DPoS consensus with 27 known validators makes block-level confirmation safe for micropayments.

License

MIT