x402 SDK for AI agent payments. Accept USDC on Base and Solana.
| Package | Description |
|---|---|
@proxies-sx/x402-core |
Core types and utilities |
@proxies-sx/x402-hono |
Hono middleware (Lucid compatible) |
@proxies-sx/x402-solana |
Solana payment verification |
npm install @proxies-sx/x402-honoimport { Hono } from 'hono'
import { x402 } from '@proxies-sx/x402-hono'
const app = new Hono()
// Free endpoint
app.get('/health', (c) => c.json({ status: 'ok' }))
// Paid endpoint - $0.10 per request
app.get('/data', x402({
amount: 0.10,
network: 'base',
recipient: '0xYourWallet',
description: 'Premium data endpoint'
}), async (c) => {
const payment = c.get('x402Payment')
console.log(`Paid by: ${payment.walletAddress}`)
return c.json({ data: 'Premium content!' })
})
export default app- Agent calls your endpoint without payment
- Your server returns 402 with payment requirements
- Agent sends USDC on Base or Solana
- Agent retries with
Payment-Signatureheader - Your server verifies payment and returns data
| Network | USDC Address | Speed | Cost |
|---|---|---|---|
| Base | 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913 |
~2s | ~$0.01 |
| Solana | EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v |
~400ms | ~$0.0001 |
import { verifySolanaPayment } from '@proxies-sx/x402-solana'
const result = await verifySolanaPayment(
txSignature,
'YourSolanaWalletAddress'
)
if (result.valid) {
console.log(`Received $${result.amount} from ${result.payer}`)
}railway login
railway init
railway upAfter deploying, register your agent on xgate.run for discovery.
MIT