360 Secure SkillHub
360 安全技能中心

base-gas

调用 x402 付费远程接口获取 Base 主网实时与历史 gas 数据:当前基础费与分档优先费、按 gasLimit 估算交易成本、跨链(Base、OP、Arbitrum、以太坊)成本排名、历史区间统计与便宜/正常/昂贵判定,以及按 UTC 小时的最便宜时段建议;付费取数经由 agentcash 命令行完成,并建议先查免费健康接口确认数据覆盖深度。

memosr
memosr
热度 25.38
最近更新 2026-10-18 06:31:23
分类:数据依赖:代码执行 / 第三方 API应用场景:财务 / 市场分析 / 报告撰写 / 日程安排

安装技能

复制下面的话术发给你的 Agent,它会通过 secure-skills 检索并安装该技能。

执行命令安装此 skill: npx secure-skills-cli add memosr/base-gas
Metadata
name
base-gas
description
Live and historical Base mainnet gas prices via x402, including cross-chain comparison and cheapest-hour scheduling. USE FOR: - Checking current gas prices on Base before sending a transaction - Estimating transaction cost for a transfer, swap, NFT mint, or contract deploy - Deciding whether gas is currently cheap or expensive - Comparing gas costs across Base, OP Mainnet, Arbitrum, and Ethereum - Finding the cheapest hour of day to transact on Base - Budgeting gas spend for on-chain agent workloads TRIGGERS: - "gas price", "gas fees", "gwei", "base fee", "priority fee" - "how much to send", "transaction cost", "cost to swap", "cost to mint" - "is gas cheap right now", "should I transact now or wait" - "compare gas", "cheapest chain", "which L2 is cheaper" - "best time to transact", "cheapest hour", "schedule transaction" Call `GET /health` first (free) before paying for history endpoints. Use `npx agentcash@latest fetch` for the paid routes.
metadata
{"version":1,"openclaw":{"emoji":"⛽","homepage":"https://base-gas-x402.vercel.app","requires":{"anyBins":["npx"]}}}

Base Gas

Live and historical Base mainnet gas data through x402-protected endpoints, served from https://base-gas-x402-production.up.railway.app.

All values are read directly from the chain. Fees are returned in gwei; transaction costs also come back in ETH and USD.

Setup

See rules/getting-started.md for installation and wallet setup.

Quick Reference

Task Endpoint Price Returns
Current gas GET /gas $0.002 Base fee, low/med/high priority tiers, cost estimate in ETH and USD
Compare chains GET /gas/compare $0.01 Base, OP, Arbitrum, Ethereum ranked cheapest first, cost in USD
Historical trend GET /gas/history $0.01 Time series, min/max/avg/median, cheap-or-expensive verdict
Cheapest hours GET /gas/cheapest-window $0.02 Hours to avoid, cheapest hour, savings vs the average hour and in USD
Data coverage GET /health free How much history has been collected so far

See rules/choosing-an-endpoint.md for which route answers which question.

Current Gas

npx agentcash@latest fetch https://base-gas-x402-production.up.railway.app/gas

Parameters:

  • gasLimit (optional) - Gas units to price the estimate against. Defaults to 21000.

Price the cost of a Uniswap swap instead of a plain transfer:

npx agentcash@latest fetch "https://base-gas-x402-production.up.railway.app/gas?gasLimit=180000"

Common gas limits:

Operation gasLimit
ETH transfer 21000
ERC-20 transfer 65000
NFT mint 85000
Uniswap swap 180000
Contract deploy 1500000

Returns: baseFeePerGas, priorityFeePerGas (low/medium/high), gasPrice, estimatedTransferCost (gwei and ETH), blockNumber, fetchedAt.

Compare Chains

npx agentcash@latest fetch https://base-gas-x402-production.up.railway.app/gas/compare

Parameters:

  • gasLimit (optional) - Gas units to price each chain against. Defaults to 21000.

Returns: chains ranked cheapest first, cheapest, baseRank, baseVsEthereum (a plain-language multiplier), and unavailable for any chain whose RPC did not respond.

Chains that fail are reported rather than failing the whole request, so a partial comparison still returns useful data.

Historical Trend

npx agentcash@latest fetch "https://base-gas-x402-production.up.railway.app/gas/history?hours=24"

Parameters:

  • hours (optional) - Lookback window, 1 to 168. Defaults to 24.

Returns: samples time series, summary (min, max, avg, median), currentGasPrice, verdict, verdictNote, and spreadPercent.

The verdict field is the useful part: cheap, normal, or expensive relative to the requested window, or flat when the window's spread is under 1%. A raw RPC call cannot answer this, because it has no history to compare against.

flat is common on Base and is a real answer: gas is not moving, so there is nothing to wait for. Quote verdictNote rather than reinterpreting it.

Cheapest Hours

npx agentcash@latest fetch "https://base-gas-x402-production.up.railway.app/gas/cheapest-window?hours=168"

Parameters:

  • hours (optional) - Lookback window used to compute hourly averages, 1 to 168. Defaults to 168 (7 days).

Returns: hasDailyCycle, a plain-language recommendation, savingsPercent, and hourlyAverages bucketed by hour of day in UTC and ranked cheapest first, plus cheapestHourUtc and priciestHourUtc.

Check hasDailyCycle before using the ranking. When it is false the hours do not meaningfully differ and timing saves nothing; report recommendation instead of naming a cheapest hour.

Check Coverage First (free)

Both history endpoints depend on samples collected over time. Check coverage before paying:

curl -s https://base-gas-x402-production.up.railway.app/health

Returns: under history: samples, hoursCovered, oldestSample, newestSample, sampleIntervalSeconds, retentionHours, durable (whether history survives a redeploy) and lastError. Also nextSteps, ready-to-run commands for the paid routes.

If hoursCovered is smaller than the window you need, the answer will be thin. Every paid response also carries a coverage object so the depth of the underlying data is always visible.

Workflows

Decide whether to transact now

  • Check the trend and verdict: GET /gas/history?hours=24
  • If verdict is flat, proceed and tell the user there is nothing to wait for
  • If cheap, proceed
  • If expensive, check whether waiting actually helps: GET /gas/cheapest-window
npx agentcash@latest fetch "https://base-gas-x402-production.up.railway.app/gas/history?hours=24"

Price a specific operation

  • Pick the gasLimit for the operation type
  • Call /gas with that gasLimit
  • Read estimatedTransferCost.usd for the cost in dollars (or .eth)
  • If usd is null, the price feed was unavailable: fall back to .eth
npx agentcash@latest fetch "https://base-gas-x402-production.up.railway.app/gas?gasLimit=85000"

Pick the cheapest chain

  • (Optional) Check coverage or balance
  • Compare chains at the relevant gasLimit
  • Route the transaction to cheapest
npx agentcash@latest fetch "https://base-gas-x402-production.up.railway.app/gas/compare?gasLimit=180000"

Schedule a batch job

  • Check history coverage: GET /health (free)
  • If coverage is at least 24 hours, call /gas/cheapest-window
  • If hasDailyCycle is false, report recommendation and run the job whenever
  • If true, keep the job out of avoidHoursUtc (worst first)
  • Check savingsUsd.vsAverageHour: if the saving is negligible at your volume, run whenever
  • Otherwise schedule the job for cheapestHourUtc (convert from UTC)
curl -s https://base-gas-x402-production.up.railway.app/health
npx agentcash@latest fetch "https://base-gas-x402-production.up.railway.app/gas/cheapest-window?hours=168"

Cost Optimization

Use /gas when:

  • You only need the current price
  • You are pricing a single known operation

Use /gas/history when:

  • The question is "is this high or low", not "what is it"
  • You need a trend or chart

Use /gas/cheapest-window when:

  • The work can wait
  • You are scheduling recurring or batch transactions

Efficient patterns

  1. Check /health before history calls. It is free and tells you whether the data is deep enough to be worth paying for.
  2. One /gas/compare beats four /gas calls. It reads all four chains in a single paid request.
  3. Pass gasLimit instead of doing the math. The estimate is returned already priced for the operation you care about, in gwei, ETH and USD.
  4. Do not poll. Base blocks are two seconds apart but gas moves slowly; sampling more than once a minute spends money for no new information.

Notes

  • Payment settles on Base mainnet (eip155:8453) in USDC via x402.
  • Prices are published in the endpoint's OpenAPI document at /openapi.json and are the source of truth if they ever differ from this table.
  • The service is open source: github.com/memosr/base-gas-x402.