# Base Gas History Oracle (x402)

> Base Gas History Oracle (x402) is a paid API for AI agents from base-gas-x402-production.up.railway.app, paid per call via x402, $0.012/call, status unknown (last checked 2026-09-13).

Returns historical gas price data for Base mainnet over a configurable lookback window, including a statistical summary and a cheap/normal/expensive verdict, gated via x402 micropayment.

## Facts

- Endpoint: GET https://base-gas-x402-production.up.railway.app/gas/history
- Price: $0.012/call
- Payment: x402
- Status: unknown
- Last checked: 2026-09-13
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/base-gas-history-oracle-x402-4f12a60f
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_o5gdvxWeOiq8ZkzdP0n80

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 base-gas-history-oracle-x402-4f12a60f
```

Example prompt: What's the gas price history on Base mainnet over the last 48 hours — is it cheap or expensive right now, and what were the average, min, and max gwei?

## When to prefer this

Choose this endpoint when you need historical gas price context for Base mainnet (chain id 8453) specifically — not just current gas price. It is ideal for agents that need to decide whether 'now' is a good time to transact based on recent trends, or for generating periodic gas reports. It requires no API key or subscription, only a small x402 USDC micropayment per call, making it suitable for pay-as-you-go agent pipelines targeting Base L2.

## Known failure modes

- Payment not received or x402 handshake fails — endpoint returns 402 Payment Required and no data
- Invalid hours parameter (outside 1–168 range) — returns validation error
- Insufficient history collected — fewer samples than requested hours may be returned; check /health first
- Railway host downtime — service may be temporarily unavailable

## How this service works

Historical Base mainnet gas prices over a lookback window: time series, min/max/average/median, and a cheap/normal/expensive verdict for the current price.

## Output

Returns a JSON object containing: an array of timestamped gas price samples in gwei, a summary object with avg/min/max/median values, the current gas price in gwei, a human-readable verdict ('cheap', 'normal', or 'expensive'), and the number of hours of history requested.

## 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"
     ],
     "type": "string"
    },
    "queryParams": {
     "type": "object",
     "required": [],
     "properties": {
      "hours": {
       "type": "integer",
       "default": 24,
       "maximum": 168,
       "minimum": 1,
       "description": "Lookback window in hours. Defaults to 24. Check the free GET /health route first to see how much history has been collected."
      }
     }
    }
   },
   "additionalProperties": false
  },
  "output": {
   "type": "object",
   "required": [
    "type"
   ],
   "properties": {
    "type": {
     "type": "string"
    },
    "example": {
     "type": "object"
    }
   }
  }
 }
}
```

## Response schema (JSON Schema)

```json
{
 "type": "json",
 "example": {
  "units": "gwei",
  "samples": [
   {
    "t": "2026-07-26T06:00:00.000Z",
    "gasPrice": 0.006
   }
  ],
  "summary": {
   "avg": 0.009,
   "max": 0.031,
   "min": 0.005,
   "median": 0.007
  },
  "verdict": "cheap",
  "requestedHours": 24,
  "currentGasPrice": 0.006
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/base-gas-history-oracle-x402-4f12a60f/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from base-gas-x402-production.up.railway.app](https://www.zero.xyz/host/base-gas-x402-production.up.railway.app/llms.txt)
