Requirements
- A Vercel project (or any Node.js 20+ host that supports Next.js app router).
- An Upstash Redis database (REST URL + REST token).
- A CDP (Coinbase Developer Platform) API key with access to the x402 facilitator.
- Upstream provider URLs for Alchemy and Helius (mainnet + devnet).
- A Tokens API key (for auth-only Tokens routes).
- A Solana mainnet wallet to receive settled USDC (the gateway
payTowallet).
Environment variables
Copy.env.example and fill in the values below.
Core
| Variable | Required | Notes |
|---|---|---|
PORT | Optional | Defaults to 8080 for local dev. Ignored on Vercel. |
AGON_GATEWAY_BASE_URL | Required | Fully-qualified base URL, e.g. https://gateway.agonx402.com. Used when building resource fields and catalog hrefs. |
CDP_API_KEY_ID | Required | CDP API key id for the facilitator. |
CDP_API_KEY_SECRET | Required | CDP API key secret. |
Payment rail
| Variable | Required | Notes |
|---|---|---|
AGON_X402_PAY_TO_WALLET | Required | Solana address that receives USDC settlement. |
AGON_X402_USDC_MINT | Optional | Defaults to mainnet USDC (EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v). |
SOLANA_MAINNET_RPC_URL | Optional | Defaults to https://api.mainnet-beta.solana.com. Use a private RPC to avoid throttling when constructing payment payloads. |
Rate limits (all optional, sensible defaults)
| Variable | Default | Meaning |
|---|---|---|
AGON_RATE_LIMIT_RPC_RPS | 50 | RPC requests per second per provider:cluster:rpc scope. |
AGON_RATE_LIMIT_DAS_RPS | 10 | DAS requests per second per provider:cluster:das scope. |
AGON_RATE_LIMIT_TOKENS_PER_MINUTE | 30 | Shared Tokens API rpm. |
AGON_RATE_LIMIT_CHALLENGE_PER_MINUTE | 120 | Unpaid 402 challenges per minute per IP. |
Provider upstreams
| Variable | Required | Notes |
|---|---|---|
ALCHEMY_MAINNET_RPC_URL | Required | Alchemy mainnet RPC URL (includes API key). |
ALCHEMY_DEVNET_RPC_URL | Required | Alchemy devnet RPC URL. |
HELIUS_MAINNET_RPC_URL | Required | Helius mainnet RPC URL. |
HELIUS_DEVNET_RPC_URL | Required | Helius devnet RPC URL. |
TOKENS_API_BASE_URL | Optional | Defaults to https://api.tokens.xyz. |
TOKENS_API_KEY | Required | Server-side Tokens API key. Never returned to clients. |
Upstash Redis (required for hosted safety)
| Variable | Required | Notes |
|---|---|---|
UPSTASH_REDIS_REST_URL | Required | Upstash REST URL. |
UPSTASH_REDIS_REST_TOKEN | Required | Upstash REST token. |
Internal facilitator (optional)
See Facilitator for when to enable these.| Variable | Required | Notes |
|---|---|---|
AGON_INTERNAL_SETTLEMENT_SECRET | Optional | Shared secret required by internal facilitator routes. |
AGON_FACILITATOR_WALLET_BASE58 | Optional | Base58-encoded 64-byte secret key for the internal facilitator wallet. Do not paste a JSON array here. |
Local development
Vercel deploy
The repo builds as a standard Next.js app-router backend on Vercel. Recommended rollout:- Deploy to the default
*.vercel.appdomain first. - Verify
GET /healthzreturns{ "ok": true, ... }. - Verify
GET /v1/catalogreturns a non-emptyrouteslist with real env values. - Test one unpaid
402challenge against a paid route (noPAYMENT-SIGNATUREheader). - Test one successful paid request end-to-end.
- Point your production domain (for example,
gateway.agonx402.com) at the Vercel project.
vercel.json
The repo ships a minimalvercel.json that keeps the default Next.js app router behavior.
Regions
Hot-path routes are pinned toiad1 (preferredRegion). Any single Vercel region works; the stateful layer lives in Upstash so there is no session pinning required for correctness.
Docker (self-hosting)
ADockerfile is provided for self-hosting. The image is a standard Node.js 20 container running next start against port 8080. All environment variables above apply unchanged.

