# Onchain Gas Price Lookup (Base & Ethereum)

> Onchain Gas Price Lookup (Base & Ethereum) is a paid API for AI agents from onchain.x402utils.workers.dev, paid per call via x402, $0.001/call, status unknown (last checked 2026-10-02).

Returns current gas price and base fee in gwei for Base or Ethereum, along with the latest block number.

## Facts

- Endpoint: GET https://onchain.x402utils.workers.dev/v1/gas?utm_source=zero.xyz
- Price: $0.001/call
- Payment: x402
- Status: unknown
- Last checked: 2026-10-02
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/onchain-gas-price-lookup-base-ethereum-e551619d
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_i6PT7xSOU7HD_VQFqgWH8

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 onchain-gas-price-lookup-base-ethereum-e551619d
```

Example prompt: What's the current gas price on Ethereum right now — give me the base fee in gwei and the latest block number.

## When to prefer this

Use this endpoint when you need real-time, low-latency gas price data for Base or Ethereum and want a simple pay-per-call model without API key management. Ideal for AI agents that need to make gas-aware decisions (e.g. timing transactions, estimating costs) without integrating a full node or subscribing to a gas oracle service.

## Known failure modes

- Unsupported chain value returns validation error — only 'base' or 'ethereum' are accepted
- Payment failure (x402) if USDC balance is insufficient or x402 header is missing/invalid
- Upstream RPC node unavailability may cause timeout or 503 error
- Stale data if the underlying node is behind on block sync

## How this service works

Live Base and Ethereum reads for AI agents: balances (ETH + USDC), gas, transaction status, ERC-20 metadata. $0.001 per call via x402 (USDC on Base).

## Output

Returns a JSON object with the chain name, latest block number, base fee in gwei, and gas price in gwei for the requested network (Base or Ethereum).

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "$schema": "https://json-schema.org/draft/2020-12/schema",
 "required": [
  "input"
 ],
 "properties": {
  "input": {
   "type": "object",
   "required": [
    "type",
    "method"
   ],
   "properties": {
    "type": {
     "type": "string",
     "const": "http"
    },
    "method": {
     "enum": [
      "GET",
      "HEAD",
      "DELETE"
     ],
     "type": "string"
    },
    "queryParams": {
     "type": "object",
     "properties": {
      "chain": {
       "enum": [
        "base",
        "ethereum"
       ],
       "type": "string",
       "description": "base (default) or ethereum"
      }
     }
    }
   },
   "additionalProperties": false
  },
  "output": {
   "type": "object",
   "required": [
    "type"
   ],
   "properties": {
    "type": {
     "type": "string"
    },
    "example": {
     "type": "object"
    }
   }
  }
 }
}
```

## Response schema (JSON Schema)

```json
{
 "type": "json",
 "example": {
  "block": 23000000,
  "chain": "ethereum",
  "base_fee_gwei": 1.1,
  "gas_price_gwei": 1.2
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/onchain-gas-price-lookup-base-ethereum-e551619d/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from onchain.x402utils.workers.dev](https://www.zero.xyz/host/onchain.x402utils.workers.dev/llms.txt)
