{"openapi":"3.1.0","info":{"title":"base-gas-x402","version":"1.0.0","description":"Pay-per-call gas oracle for Base mainnet (Base L2, Coinbase Base, chain id 8453), gated with the x402 payment protocol. Returns EIP-1559 base fee, low/medium/high priority fee tiers, current gas price in gwei, and an estimated transaction cost, all read live from the chain. No API keys and no subscription: agents pay 0.005 USDC per call over x402.","x-guidance":"Call GET /gas to fetch live Base mainnet gas data. All parameters are optional. Each call costs 0.005 USDC, settled on Base mainnet (eip155:8453) via x402. Use it to check gas fees before sending a transaction on Base, estimate transaction cost, budget agent gas spending, monitor Base L2 network congestion, or compare Base fees against other chains. Fees are returned in gwei. Pass the optional gasLimit query parameter to price a specific operation: 21000 for a plain ETH transfer (the default), ~65000 for an ERC-20 transfer, ~85000 for an NFT mint, ~180000 for a Uniswap swap, ~1500000 for a contract deploy. estimatedTransferCost is priced at base fee plus the medium priority tier.","contact":{"email":"mehmet.sr35@gmail.com"}},"servers":[{"url":"https://base-gas-x402-production.up.railway.app"}],"paths":{"/gas":{"get":{"summary":"Live Base mainnet gas price: base fee, priority fee tiers, and transfer cost estimate (paid via x402)","description":"Returns live Base mainnet (Base L2, Coinbase Base) gas data read directly from the chain: EIP-1559 base fee per gas, low/medium/high priority fee tiers, current gas price in gwei, and an estimated transaction cost for any gas limit. Common uses: check current gas fees on Base, get the Base network gas price before sending a transaction, estimate transaction cost on Base mainnet, price a Uniswap swap or NFT mint on Base, find a cheap time to transact on Base L2, monitor Base network congestion, budget gas spending for an on-chain agent, and compare Base gas costs to other L2 networks. Each call costs 0.005 USDC settled on Base mainnet (eip155:8453) via x402. No API key or subscription required.","operationId":"getGas","parameters":[{"name":"gasLimit","in":"query","required":false,"description":"Gas units to price the cost estimate against. Defaults to 21000 (a plain ETH transfer). Use ~65000 for an ERC-20 transfer, ~85000 for an NFT mint, ~180000 for a Uniswap swap, or ~1500000 for a contract deploy.","schema":{"type":"integer","minimum":21000,"maximum":30000000,"default":21000,"example":180000}}],"x-payment-info":{"price":{"mode":"fixed","currency":"USD","amount":"0.005000"},"protocols":[{"x402":{}}]},"responses":{"200":{"description":"Live Base mainnet gas data (payment accepted).","content":{"application/json":{"schema":{"type":"object","properties":{"chain":{"type":"string","example":"base-mainnet"},"chainId":{"type":"integer","example":8453},"blockNumber":{"type":"string","example":"12345678"},"baseFeePerGas":{"type":"string","description":"Base fee per gas, in gwei.","example":"0.012"},"priorityFeePerGas":{"type":"object","description":"Priority fee tiers, in gwei.","properties":{"low":{"type":"string","example":"0.001"},"medium":{"type":"string","example":"0.002"},"high":{"type":"string","example":"0.004"}}},"gasPrice":{"type":"string","description":"Network gas price, in gwei.","example":"0.014"},"estimatedTransferCost":{"type":"object","description":"Estimated cost of a plain ETH transfer.","properties":{"gasLimit":{"type":"integer","example":21000},"gwei":{"type":"string","example":"294"},"eth":{"type":"string","example":"0.000000294"}}},"fetchedAt":{"type":"string","format":"date-time","example":"2026-06-22T00:00:00.000Z"}}}}}},"402":{"description":"Payment Required"}}}},"/gas/compare":{"get":{"summary":"Compare live gas costs across Base, OP Mainnet, Arbitrum, and Ethereum (paid via x402)","description":"Compares live gas costs across Base, OP Mainnet, Arbitrum One, and Ethereum in a single call, ranked cheapest first. Returns each chain's EIP-1559 base fee, current gas price in gwei, and estimated cost for a given gas limit, plus which chain is cheapest right now and how many times cheaper Base is than Ethereum. Common uses: pick the cheapest chain for a transaction, decide whether bridging to Base is worth it, compare L2 fees across networks, route agent transactions to the lowest-cost chain, and monitor relative congestion between L2s. Chains that fail to respond are listed under \"unavailable\" rather than failing the whole request. Each call costs 0.01 USDC settled on Base mainnet (eip155:8453) via x402.","operationId":"compareGas","parameters":[{"name":"gasLimit","in":"query","required":false,"description":"Gas units to price each chain against. Defaults to 21000 (a plain ETH transfer).","schema":{"type":"integer","minimum":21000,"maximum":30000000,"default":21000,"example":180000}}],"x-payment-info":{"price":{"mode":"fixed","currency":"USD","amount":"0.010000"},"protocols":[{"x402":{}}]},"responses":{"200":{"description":"Multi-chain gas comparison (payment accepted).","content":{"application/json":{"schema":{"type":"object","properties":{"gasLimit":{"type":"integer","example":21000},"basis":{"type":"string","example":"current gas price x gasLimit"},"chains":{"type":"array","description":"Per-chain gas data, cheapest first.","items":{"type":"object","properties":{"chain":{"type":"string","example":"base"},"label":{"type":"string","example":"Base"},"chainId":{"type":"integer","example":8453},"blockNumber":{"type":"string","example":"49106604"},"baseFeePerGas":{"type":"string","example":"0.005"},"gasPrice":{"type":"string","example":"0.006"},"estimatedCost":{"type":"object","properties":{"gasLimit":{"type":"integer","example":21000},"gwei":{"type":"string","example":"126"},"eth":{"type":"string","example":"0.000000126"}}}}}},"cheapest":{"type":"string","description":"Key of the cheapest chain.","example":"base"},"baseRank":{"type":"integer","description":"Base's position in the ranking, 1 = cheapest.","example":1},"baseVsEthereum":{"type":"string","example":"Base is 240.5x cheaper than Ethereum"},"unavailable":{"type":"array","description":"Chains whose RPC did not respond.","items":{"type":"object","properties":{"chain":{"type":"string"},"reason":{"type":"string"}}}},"fetchedAt":{"type":"string","format":"date-time"}}}}}},"402":{"description":"Payment Required"}}}},"/gas/history":{"get":{"summary":"Historical Base gas prices with trend statistics and a cheap/normal/expensive verdict (paid via x402)","description":"Returns historical Base mainnet gas prices over a lookback window, sampled continuously from the chain, together with min, max, average, and median gas price for that window and a verdict on whether gas is currently cheap, normal, or expensive relative to it. A live RPC call reports the current price but cannot say whether it is high or low; this endpoint can, because it has been watching. Common uses: decide whether to transact now or wait, detect congestion spikes on Base, chart Base gas trends over time, set gas budgets from real observed data, and backtest agent transaction timing. Every response includes a coverage object stating exactly how much history backs it. Check the free GET /health route first to see current coverage. Each call costs 0.012 USDC settled on Base mainnet (eip155:8453) via x402.","operationId":"getGasHistory","parameters":[{"name":"hours","in":"query","required":false,"description":"Lookback window in hours. Defaults to 24.","schema":{"type":"integer","minimum":1,"maximum":168,"default":24,"example":24}}],"x-payment-info":{"price":{"mode":"fixed","currency":"USD","amount":"0.012000"},"protocols":[{"x402":{}}]},"responses":{"200":{"description":"Gas history for the window (payment accepted).","content":{"application/json":{"schema":{"type":"object","properties":{"chain":{"type":"string","example":"base-mainnet"},"chainId":{"type":"integer","example":8453},"requestedHours":{"type":"integer","example":24},"units":{"type":"string","example":"gwei"},"currentGasPrice":{"type":"number","example":0.006},"verdict":{"type":"string","enum":["cheap","normal","expensive","flat"],"description":"Where the current gas price sits within the window's range. Returns `flat` when the window's spread is under 1%, which on Base is common: the chain sits on its fee floor for hours and there is nothing to time.","example":"flat"},"verdictNote":{"type":"string","description":"Plain-language explanation of the verdict, including the observed spread.","example":"Gas has not moved meaningfully in this window (spread 0.0067%, below the 1% threshold). There is nothing to wait for."},"spreadPercent":{"type":"number","description":"Width of the window's range as a percentage of its minimum. Below 1% the verdict is reported as `flat`.","example":0.0067},"summary":{"type":"object","properties":{"min":{"type":"number","example":0.005},"max":{"type":"number","example":0.031},"avg":{"type":"number","example":0.009},"median":{"type":"number","example":0.007}}},"samples":{"type":"array","description":"Time series, oldest first.","items":{"type":"object","properties":{"t":{"type":"string","format":"date-time"},"baseFee":{"type":"number","example":0.005},"gasPrice":{"type":"number","example":0.006},"priorityMedium":{"type":"number","example":0.001}}}},"coverage":{"type":"object","description":"How much history actually backs this response.","properties":{"samples":{"type":"integer","example":288},"hoursCovered":{"type":"number","example":24},"retentionHours":{"type":"integer","example":168}}},"fetchedAt":{"type":"string","format":"date-time"}}}}}},"402":{"description":"Payment Required"}}}},"/gas/cheapest-window":{"get":{"summary":"Cheapest hours of day to transact on Base, from observed gas history (paid via x402)","description":"Identifies the cheapest hours of day to transact on Base, computed from continuously collected gas history. Returns average gas price bucketed by hour of day in UTC and ranked cheapest first, plus the cheapest hour, the priciest hour, and the percentage saved by waiting for the cheap window. Common uses: schedule batch transactions for cheap gas, time an NFT mint or airdrop, plan agent workloads around low-fee hours, cut gas spend on recurring on-chain jobs, and answer when should I send this transaction. This cannot be derived from a single RPC call at any price, because it requires historical observation. Every response includes a coverage object; with less than a full day of history the hourly ranking is provisional. Check the free GET /health route first. Each call costs 0.02 USDC settled on Base mainnet (eip155:8453) via x402.","operationId":"getCheapestWindow","parameters":[{"name":"hours","in":"query","required":false,"description":"Lookback window in hours used to compute hourly averages. Defaults to 168 (7 days).","schema":{"type":"integer","minimum":1,"maximum":168,"default":168,"example":168}}],"x-payment-info":{"price":{"mode":"fixed","currency":"USD","amount":"0.020000"},"protocols":[{"x402":{}}]},"responses":{"200":{"description":"Hourly gas ranking (payment accepted).","content":{"application/json":{"schema":{"type":"object","properties":{"chain":{"type":"string","example":"base-mainnet"},"chainId":{"type":"integer","example":8453},"requestedHours":{"type":"integer","example":168},"units":{"type":"string","example":"gwei"},"hasDailyCycle":{"type":"boolean","description":"Whether the chain actually has a usable daily gas cycle in this window. False means timing by hour of day saves nothing, and the ranking below is not actionable.","example":false},"recommendation":{"type":"string","description":"The headline answer in plain language, so the caller does not have to infer it from the ranking.","example":"No meaningful daily gas cycle on this chain: the gap between the cheapest and priciest hour is 0%. Timing a transaction by hour of day will not save anything."},"hourlyAverages":{"type":"array","description":"Hour-of-day averages, cheapest first. Only actionable when hasDailyCycle is true.","items":{"type":"object","properties":{"hourUtc":{"type":"integer","example":6},"samples":{"type":"integer","example":84},"avgGasPrice":{"type":"number","example":0.005}}}},"cheapestHourUtc":{"type":"integer","example":6},"priciestHourUtc":{"type":"integer","example":14},"savingsPercent":{"type":"number","description":"Percent saved by transacting in the cheapest hour instead of the priciest.","example":73.7},"hoursObserved":{"type":"integer","example":24},"coverage":{"type":"object","properties":{"samples":{"type":"integer","example":2016},"hoursCovered":{"type":"number","example":168},"retentionHours":{"type":"integer","example":168}}},"fetchedAt":{"type":"string","format":"date-time"}}}}}},"402":{"description":"Payment Required"}}}},"/health":{"get":{"summary":"Service health and gas history coverage (free)","description":"Free health check. Reports service uptime and, more usefully, exactly how much gas history has been collected so far: sample count, hours covered, sampling interval, and retention. Call this before paying for /gas/history or /gas/cheapest-window to confirm the coverage is deep enough for your use case. No payment required.","operationId":"getHealth","security":[],"responses":{"200":{"description":"Service status and history coverage.","content":{"application/json":{"schema":{"type":"object","properties":{"status":{"type":"string","example":"ok"},"uptimeSeconds":{"type":"number","example":3600},"history":{"type":"object","properties":{"samples":{"type":"integer","example":288},"hoursCovered":{"type":"number","example":24},"oldestSample":{"type":"string","format":"date-time"},"newestSample":{"type":"string","format":"date-time"},"sampleIntervalSeconds":{"type":"integer","example":300},"retentionHours":{"type":"integer","example":168}}}}}}}}}}}}}