L2 gas comparison
POST /api/l2-gas-comparisonCurrent 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.
Input
| Field | Type | Description |
|---|---|---|
networks | array | Subset of networks to query. Default = all 5. Supported: ethereum, base, polygon, arbitrum, optimism. |
Example output
{
"queriedAt": "2026-06-22T19:00:00.000Z",
"networks": [
{
"network": "base",
"chainId": 8453,
"isL2": true,
"gasPriceWei": "100000000",
"gasPriceGwei": 0.1,
"blockNumber": 22000000
},
{
"network": "arbitrum",
"chainId": 42161,
"isL2": true,
"gasPriceWei": "100000000",
"gasPriceGwei": 0.1,
"blockNumber": 300000000
},
{
"network": "ethereum",
"chainId": 1,
"isL2": false,
"gasPriceWei": "15000000000",
"gasPriceGwei": 15,
"blockNumber": 22000000
}
],
"cheapest": "base",
"source": "alchemy"
}
Try it - see the 402 challenge (free)
curl -i -X POST https://agent402.tools/api/l2-gas-comparison \
-H "Content-Type: application/json" \
-d '{"networks":["ethereum","base","arbitrum","optimism","polygon"]}'
The response is HTTP 402 Payment Required with exact payment requirements. Any x402 v2 client pays automatically and retries:
Paid call (JavaScript agent)
import { wrapFetchWithPayment } from "@x402/fetch";
import { x402Client } from "@x402/core/client";
import { registerExactEvmScheme } from "@x402/evm/exact/client";
import { privateKeyToAccount } from "viem/accounts";
const client = new x402Client();
registerExactEvmScheme(client, { signer: privateKeyToAccount(KEY) });
const payFetch = wrapFetchWithPayment(fetch, client);
const res = await payFetch("https://agent402.tools/api/l2-gas-comparison", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
"networks": [
"ethereum",
"base",
"arbitrum",
"optimism",
"polygon"
]
}),
});
Part of these workflows
This tool is one step in a curated multi-tool workflow - agents can fetch the whole sequence as an MCP prompt or call https://agent402.tools/api/skill-packs/{slug}/prompt.
- 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.
Related tools
Crypto order book
GET /api/crypto-orderbookL2 order-book snapshot for a spot pair: best bid/ask, mid price, spread (absolute + %), and the top N aggregated price l…
Stablecoin peg monitor
GET /api/stablecoin-pegLive $1-peg deviation for the top USD stablecoins (USDT, USDC, USDS, DAI, USDe, PYUSD, USDD, TUSD, FDUSD by default, or …
Wallet balance (native + ERC-20)
POST /api/wallet-balanceLook up the native coin balance (ETH/MATIC) plus every ERC-20 holding for a wallet address on Ethereum, Base, Polygon, A…