Cheapest rail right now
Where should an agent transact this minute? Live gas on Ethereum + every major L2 side by side, Base gas tiers, a fee estimate for your transaction type, and ETH spot to price it all in dollars.
4 tools run server-side in one request. You pay once, settle once, and get a single response - no orchestration, no per-step payments, and a partial-success envelope if any step fails. USDC over x402 on any supported chain.
When to use this pack
An agent about to do REAL onchain work - deploy a contract, move funds, batch-settle, mint - wants to pick the chain and the moment. Gas varies 10-100x between Ethereum and its L2s and swings hour to hour; eyeballing four gas trackers is human work. One call returns the cross-chain comparison, the chosen chain's slow/standard/fast tiers, a per-transaction-type estimate, and the ETH price to convert gwei into dollars. (x402 tool payments themselves are gasless - this pack is for everything else an agent does on-chain.)
Tools in this pack
All 4 run inside the single $0.050 call above. Each is also callable on its own if you only need one part.
- L2 gas comparison POST /api/l2-gas-comparison Current gas snapshot across Ethereum + supported L2s (Base, Polygon, Arbitrum, Optimism), sorted cheapest-first. Returns gas price in gwei, latest block number, chain id, and an isL2 flag per chain. Use to route a transaction to the cheapest viable L2 or to track L1→L2 gas spread.
- Gas snapshot (slow / standard / fast) POST /api/gas-snapshot Live gas price snapshot for a chain - slow / standard / fast tiers in gwei, plus the latest base fee. Sampled from eth_feeHistory (last 4 blocks, 25th/50th/90th percentile priority fees). Use to estimate before broadcasting a transaction from another tool.
- Gas price GET /api/gas-estimate Current gas price (gwei and wei) on Base, Polygon, Arbitrum, Optimism, Ethereum, Monad, Celo, Avalanche, Sei, or Robinhood Chain - for an agent budgeting a transaction. Read-only. ?network=base
- Crypto price GET /api/crypto-price Live crypto prices for one or many coins in any vs_currency (usd, eur, btc, eth, etc). Returns last price, 24h change %, 24h volume, and market cap per coin. The simplest crypto price read - for ranked market-cap tables use crypto-market, for candles use crypto-history, and when you need an oracle-grade price with a confidence interval use price-pyth. Accepts ticker symbols (BTC, ETH, SOL) for the top ~50 by market cap, or canonical CoinGecko ids (e.g. "render-token") for any of the ~15k tracked coins. Batched: up to 25 coins per call. Backed by CoinGecko's public API - keyless.
Workflow
- l2-gas-comparison with {networks: ["ethereum", "base", "arbitrum", "optimism", "polygon"]} - one row per chain with current gas. This is the headline: sort ascending and you have the cheapest venue.
- gas-snapshot with {network: <the winner>} - slow/standard/fast tiers on the chosen chain. If your action is deferrable, the slow tier is often half the fast tier; note the spread.
- gas-estimate for your transaction type on that chain - a simple transfer, an ERC-20 transfer, and a contract deploy differ by an order of magnitude in gas units; this converts 'gwei is low' into 'this action costs N'.
- crypto-price with {coins: "ETH", currency: "usd"} - multiply units × price × ETH spot to state the cost in dollars, which is the number a budget check actually wants.
- Report: { cheapest: <chain>, comparison: [...], tiers: {...}, estimatedCostUsd, decision: 'act now on <chain>' | 'defer - spread suggests off-peak in a few hours' }.
Call it directly
Any x402 client pays the 402 and gets the whole workflow back in one response:
npx agent402-client call cheapest-rail {"networks":"ethereum,base,arbitrum,optimism,polygon"}
Run it in Claude
claude mcp add agent402 -s user -- npx -y agent402-mcp@latest
Then paste this prompt into Claude:
Find the cheapest chain for an ERC-20 transfer right now using Agent402 (networks: ethereum,base,arbitrum,optimism,polygon): (1) l2-gas-comparison with that network list - sort by gas ascending. (2) gas-snapshot {network: <cheapest>} - read the standard tier. (3) gas-estimate on that network for an ERC-20 transfer. (4) crypto-price {coins: "ETH", currency: "usd"} - express the final cost in USD. Return {cheapest, gasStandard, estimatedCostUsd, comparison}.