[Hackathon winner]A production-ready micropayment gateway that implements HTTP 402 (Payment Required) to monetize access to historical Solana blockchain data via Old Faithful. Users pay micro-amounts in USDC to query historical transactions and blocks.
x402-Triton-Gateway is a growing TypeScript project in the AI payments / x402 ecosystem, focused on solana, triton, x402. It currently has 22 GitHub stars and 3 forks, and sits alongside related tools like CloddsBot, x402-openai-python, x402-client.
Hackathon Submission: Best x402 Integration with Old Faithful
A production-ready micropayment gateway that implements HTTP 402 (Payment Required) to monetize access to historical Solana blockchain data via Old Faithful. Users pay micro-amounts in USDC to query historical transactions and blocks.
Video Implementation
https://github.com/user-attachments/assets/f31c9245-ea00-4e6c-8645-b4b22504cb93
This gateway enables monetization of Solana historical data access through:
Historical blockchain data is valuable but expensive to maintain. This system:
┌─────────────┐
│ Client │ 1. Connect wallet & sign USDC payment
│ Dashboard │ 2. Request historical data + payment proof
└──────┬──────┘
│
▼
┌─────────────┐
│ Gateway │ 3. Enforce HTTP 402 Payment Required
│ (Port 4021)│ 4. Verify payment with facilitator
└──────┬──────┘
│
▼
┌─────────────┐
│ Facilitator │ 5. Validate transaction structure
│ (Port 3000)│ 6. Broadcast to Solana mainnet
└──────┬──────┘ 7. Return confirmation
│
├───────────────┐
│ │
▼ ▼
┌─────────────┐ ┌─────────────┐
│ Solana │ │ Old Faithful│
│ Mainnet │ │ (Epoch 800)│
│ (Helius) │ │ Port 8899 │
└─────────────┘ └─────────────┘
│ │
└───────┬───────┘
▼
┌─────────────┐
│ Receipt │ Transaction signature
│ Generation │ + data returned to user
└─────────────┘
getTransaction, getBlock, and other RPC methodsYou can run this project in two ways:
/tmp/faithful-cli)Terminal 1 - Start Old Faithful:
/tmp/faithful-cli rpc --listen :8899 old-faithful-epoch-800.yml
Terminal 2 - Start All Services:
docker-compose up --build
Access the Application:
# View logs
docker-compose logs -f
# View specific service logs
docker-compose logs -f gateway
# Stop services
docker-compose down
# Rebuild after changes
docker-compose up --build
# Remove everything
docker-compose down -v
See DOCKER.md for detailed Docker documentation.
.env.example to .env:cp .env.example .env
# Network
NETWORK=mainnet-beta
SOLANA_RPC_URL=https://mainnet.helius-rpc.com/?api-key=YOUR_KEY
# Old Faithful
UPSTREAM_RPC_URL=http://localhost:8899
# Pricing (USD per query)
PRICE_GET_TRANSACTION=0.00002
PRICE_GET_BLOCK=0.00005
PRICE_GET_SIGNATURES=0.0001
# Install dependencies
pnpm install
# Build shared types
pnpm --filter @x402-gateway/types build
/tmp/faithful-cli rpc --listen :8899 old-faithful-epoch-800.yml
# Runs on localhost:8899
cd backend/facilitator
pnpm dev
# Runs on localhost:3000
cd backend/gateway
pnpm dev
# Runs on localhost:4021
cd frontend/dashboard
pnpm build && pnpm start
# Runs on localhost:3001 (production mode for best performance)
http://localhost:3001Example Transactions (from Epoch 800):
3G8fVhYvVrHDoUQdckWsMF8EDgEpXvkzrm98EE34VHW6LFUyX8fASdoGKhCQX9zz1xLm5zjwi3DoE7FEbm4RHRSU2Zwfm3NHJyeEbnCb3sfkaLmhtrM5LS4yJWUjLYrJ824SXfPcAfrjWJePyVZC21aFhRcPtcn6vDnMY5wXrq5vbVZ5eYfNeABJGRwVkvLdsTGLHqi2UGAuoESbGUt9SvQTdt92DSzDR2Jd5iryDEyzth4AZsWEJDHV64UAgaA16ZGFRFahttps://solscan.io/tx/[signature]curl -X POST http://localhost:4021/rpc \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "getTransaction",
"params": ["3G8fVhYvVrHDoUQdckWsMF8EDgEpXvkzrm98EE34VHW6LFUyX8fASdoGKhCQX9zz1xLm5zjwi3DoE7FEbm4RHRSU"]
}'
Response: 402 Payment Required
{
"error": "Payment required",
"amount": "20",
"currency": "USDC",
"recipient": "62pyPYsdSLah2vDSeenEep2R2hP9jz98eDbnz4Zyb1Lf",
"mint": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"
}
curl -X POST http://localhost:4021/rpc \
-H "Content-Type: application/json" \
-H "X-Payment-Signature: <base64-signed-transaction>" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "getTransaction",
"params": ["3G8fVhYvVrHDoUQdckWsMF8EDgEpXvkzrm98EE34VHW6LFUyX8fASdoGKhCQX9zz1xLm5zjwi3DoE7FEbm4RHRSU"]
}'
Response: Data + Receipt
{
"jsonrpc": "2.0",
"id": 1,
"result": { /* transaction data */ },
"receipt": {
"signature": "5xK3...",
"timestamp": 1731434562000,
"payment": { /* payment details */ }
}
}
User creates transaction in browser wallet:
User signs transaction with wallet private key
Frontend sends base64-encoded signed transaction to gateway
Gateway forwards to facilitator for verification
Facilitator validates:
Facilitator broadcasts to Solana mainnet via Helius RPC
Facilitator waits for confirmation
Gateway returns data + receipt with real transaction signature
All historical data queries require micropayments in USDC:
| RPC Method | Price (USDC) | Description |
|---|---|---|
| getTransaction | 0.00002 | Fetch historical transaction details |
| getBlock | 0.00005 | Fetch complete block data |
| getSignaturesForAddress | 0.0001 | Fetch transaction history for address |
| getBlockTime | 0.00001 | Retrieve block time for a slot |
| getBlocks | 0.00002 | Retrieve blocks in a slot range |
| getBlocksWithLimit | 0.00002 | Retrieve blocks with limit |
| getConfirmedBlock | 0.00005 | Retrieve confirmed block (deprecated) |
| getConfirmedTransaction | 0.00002 | Retrieve confirmed transaction (deprecated) |
Prices are configured in .env and can be adjusted based on:
All example transactions have been tested and verified to return data from Old Faithful:
# Test getTransaction
echo '{"jsonrpc":"2.0","id":1,"method":"getTransaction","params":["3G8fVhYvVrHDoUQdckWsMF8EDgEpXvkzrm98EE34VHW6LFUyX8fASdoGKhCQX9zz1xLm5zjwi3DoE7FEbm4RHRSU",{"encoding":"json","maxSupportedTransactionVersion":0}]}' | curl -X POST http://localhost:8899 -H "Content-Type: application/json" -d @-
x402-solana-hackathon/
├── backend/
│ ├── facilitator/ # Payment verification & settlement
│ │ └── src/
│ │ ├── index.ts # Main server
│ │ ├── verify.ts # Transaction validation
│ │ ├── settle.ts # Solana broadcast
│ │ └── config.ts # Configuration
│ └── gateway/ # HTTP 402 enforcement
│ └── src/
│ ├── index.ts # Main server
│ ├── middleware.ts # Payment verification
│ ├── pricing.ts # Dynamic pricing
│ └── proxy.ts # Old Faithful proxy
├── frontend/
│ └── dashboard/ # Next.js client
│ └── app/
│ ├── page.tsx # Main dashboard
│ └── client/ # Client-side payment UI
├── shared/
│ └── types/ # Shared TypeScript types
├── data/
│ └── receipts.json # Payment receipts storage
└── scripts/ # Utility scripts
└── setup.sh # Environment setup
curl http://localhost:8899backend/gateway/src/index.ts for CORS configurationNEW FEATURE: Pay once for a range of blocks, query freely within that range.
Instead of paying for each individual query, purchase access to a range of slots (e.g., 345,600,000 - 345,610,000) and make unlimited queries within that range for a specified time period.
Benefits:
Pay Once ($0.10 for 10k blocks) → Get JWT Token → Query Freely in Range
X-Range-Token header, no payment neededPOST /purchase-range
Content-Type: application/json
{
"startSlot": 345600000,
"endSlot": 345610000,
"duration": 3600,
"paymentTxSignature": "5xK3...",
"payer": "7xKw..."
}
Response:
{
"success": true,
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"range": {
"startSlot": 345600000,
"endSlot": 345610000,
"blockCount": 10001
},
"pricing": {
"totalPrice": 0.10001,
"priceUSD": "$0.10001000",
"priceInLamports": 100010
},
"access": {
"duration": 3600,
"expiresAt": 1731523200000
}
}
POST /rpc
Content-Type: application/json
X-Range-Token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
{
"jsonrpc": "2.0",
"id": 1,
"method": "getBlock",
"params": [345605000]
}
| Scenario | Pay-per-Query | Range Batching |
|---|---|---|
| 1 query | $0.00002 | $0.10001 |
| 100 queries | $0.002 | $0.10001 |
| 10,000 queries | $0.20 | $0.10001 ✅ |
| Tx overhead | High (10k txs) | Low (1 tx) ✅ |
| Best for | Occasional queries | Bulk analysis |
Research & Analysis
// Purchase range for the epoch you're researching
const range = await purchaseRange({
startSlot: 345600000,
endSlot: 345610000,
duration: 86400 // 24 hours
});
// Query freely for the next 24 hours
for (let slot = 345600000; slot <= 345610000; slot += 100) {
const block = await getBlock(slot, { token: range.token });
}
Historical Audits
MIT
Built for the Solana x402 hackathon targeting the "Best x402 Integration with Old Faithful" bounty by Triton One.
Open Source AI trading agent that operates autonomously across 1000+ markets - Polymarket, Kalshi, Binance, Hyperliquid, Solana DEXs, 5 EVM chains. Scans for edge, executes instantly, manages risk while you sleep. Agent commerce protocol for machine-to-machine payments. Self-hosted. Built on Claude.
Drop-in OpenAI Python client with transparent x402 payment support.
Client SDK for the Vybe x402 API. Pay-per-call USDC over HTTP and prepaid-credit WebSocket streaming for Vybe's Solana analytics API. Built for AI agents.