# L2 Gas Price Comparison (Ethereum + Base + Polygon + Arbitrum + Optimism)

> L2 Gas Price Comparison (Ethereum + Base + Polygon + Arbitrum + Optimism) is a paid API for AI agents from agent402.tools, paid per call via x402, $0.002/call, status unknown (last checked 2026-09-14).

Returns a real-time gas price snapshot across Ethereum and major L2 networks, sorted cheapest-first, to help route transactions to the most cost-effective chain.

## Facts

- Endpoint: POST https://agent402.tools/api/l2-gas-comparison
- Price: $0.002/call
- Payment: x402
- Status: unknown
- Last checked: 2026-09-14
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/l2-gas-price-comparison-ethereum-base-polygon-arbitrum-optimism-69f2d682
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_G_KXO7ibXwwl6kHanv1De

Status and success rate cover calls made through Zero and Zero's own probes. Third-party monitors may report differently.

## How to call it through Zero

Zero handles the 402 payment challenge and records the run. With the Zero CLI installed (`npm i -g @zeroxyz/cli`):

```sh
zero fetch --capability l2-gas-price-comparison-ethereum-base-polygon-arbitrum-optimism-69f2d682 -d '<json body>'
```

Example prompt: Before I send this transaction, check the current gas prices across Ethereum, Base, Arbitrum, Optimism, and Polygon and tell me which chain is cheapest right now.

## When to prefer this

Use this endpoint when an agent needs to dynamically route a transaction to the cheapest EVM-compatible chain, or when a user wants a real-time, cross-chain gas fee comparison before committing to a network. Prefer this over manually querying individual chain RPCs or static fee tables.

## Known failure modes

- Network RPC unreachable for one or more chains — partial results may be returned
- Invalid network name in the 'networks' array — endpoint may ignore unknown values or return an error
- All networks unavailable — empty results or timeout
- Payment failure (x402) — call rejected before execution

## How this service works

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.

## Output

A ranked list of networks (cheapest-first) each with: gas price in gwei, latest block number, chain ID, and an isL2 boolean flag. Covers up to 5 networks: Ethereum mainnet, Base, Polygon, Arbitrum, and Optimism.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "properties": {
  "networks": {
   "type": "array",
   "description": "Subset of networks to query. Default = all 5. Supported: ethereum, base, polygon, arbitrum, optimism."
  }
 }
}
```

## Response schema (JSON Schema)

```json
{
 "type": "json",
 "example": {
  "source": "alchemy",
  "cheapest": "base",
  "networks": [
   {
    "isL2": true,
    "chainId": 8453,
    "network": "base",
    "blockNumber": 22000000,
    "gasPriceWei": "100000000",
    "gasPriceGwei": 0.1
   },
   {
    "isL2": true,
    "chainId": 42161,
    "network": "arbitrum",
    "blockNumber": 300000000,
    "gasPriceWei": "100000000",
    "gasPriceGwei": 0.1
   },
   {
    "isL2": false,
    "chainId": 1,
    "network": "ethereum",
    "blockNumber": 22000000,
    "gasPriceWei": "15000000000",
    "gasPriceGwei": 15
   }
  ],
  "queriedAt": "2026-06-22T19:00:00.000Z"
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/l2-gas-price-comparison-ethereum-base-polygon-arbitrum-optimism-69f2d682/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from agent402.tools](https://www.zero.xyz/host/agent402.tools/llms.txt)
