# Base Gas Cheapest Window Oracle (x402)

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

Returns hourly gas price averages for Base mainnet over a configurable lookback window to identify the cheapest and most expensive hours to transact.

## Facts

- Endpoint: GET https://base-gas-x402-production.up.railway.app/gas/cheapest-window
- Price: $0.02/call
- Payment: x402
- Status: unknown
- Last checked: 2026-09-14
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/base-gas-cheapest-window-oracle-x402-cf83f6ac
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_pbwRRd5B6e6gPg01uSzkh

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-cheapest-window-oracle-x402-cf83f6ac
```

Example prompt: What's the cheapest hour to submit transactions on Base mainnet? Look back over the last 7 days of gas data so I can schedule my contract calls to minimize fees.

## When to prefer this

Use this endpoint when you need to optimize the timing of Base mainnet transactions by identifying the historically cheapest gas windows. It is ideal for agents scheduling batch operations, treasury transfers, or DeFi interactions on Base (chain ID 8453) where gas timing matters. Prefer it over raw gas price endpoints when you want multi-hour trend analysis and built-in savings calculations rather than a single current gas price snapshot.

## Known failure modes

- hours parameter out of range (must be 1–168) returns a validation error
- insufficient historical data collected (check /health first) may return fewer hours than requested
- railway.app service downtime returns a 5xx or connection error
- x402 payment not included or incorrect USDC amount results in 402 Payment Required response

## How this service works

Cheapest hours of day to transact on Base, from collected gas history: hourly averages in UTC ranked cheapest first, plus the savings percent.

## Output

Returns a JSON object with the chain name and ID, the requested and actual hours observed, hourly average gas prices (in gwei) keyed by UTC hour, the cheapest and priciest UTC hours, estimated savings percentage between those extremes, total sample count, and a timestamp of when the data was fetched.

## 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": 168,
       "maximum": 168,
       "minimum": 1,
       "description": "Lookback window in hours used to compute hourly averages. Defaults to 168 (7 days). 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": {
  "chain": "base-mainnet",
  "units": "gwei",
  "chainId": 8453,
  "coverage": {
   "samples": 2016,
   "hoursCovered": 168,
   "retentionHours": 168
  },
  "fetchedAt": "2026-07-26T06:08:54.972Z",
  "hoursObserved": 24,
  "hourlyAverages": [
   {
    "hourUtc": 6,
    "samples": 84,
    "avgGasPrice": 0.005
   },
   {
    "hourUtc": 14,
    "samples": 84,
    "avgGasPrice": 0.019
   }
  ],
  "requestedHours": 168,
  "savingsPercent": 73.7,
  "cheapestHourUtc": 6,
  "priciestHourUtc": 14
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/base-gas-cheapest-window-oracle-x402-cf83f6ac/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)
