360 Secure SkillHub
360 安全技能中心

base-gas

提供 Base 主网实时与历史 Gas 价格、交易成本估算、跨链费用比较和最便宜时段建议;通过 x402 付费接口和 agentcash 命令行获取,返回结构化数据,不负责签名或发送交易。

分类:数据
memosr
memosr
热度 10.22
最近更新 2026-11-19 00:37:24

安装

发给 Agent
帮我安装这个技能: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 - Getting ready-to-sign maxFeePerGas / maxPriorityFeePerGas for a Base transaction - 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" - "maxFeePerGas", "what fee should I set", "fee for my transaction" - "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":3,"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
Send now or wait GET /gas/advice $0.003 send_now or wait, reason, USD cost now, ready-to-sign fees (medium tier, wei)
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, ETH and USD), suggestedFees (low/medium/high maxFeePerGas and maxPriorityFeePerGas in wei, ready to sign), blockNumber, fetchedAt.

Send Now or Wait

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

Parameters:

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

Returns: advice (send_now or wait), reason, waitMinutes when the advice is wait, now.costUsd (USD cost of sending now, as a string such as "0.003504"), and suggestedFees (medium tier maxFeePerGas and maxPriorityFeePerGas in wei, ready to sign).

One call answers "should I send this now?" for a single transaction. Quote reason rather than reinterpreting it.

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

  • Ask first: GET /gas/advice?gasLimit=<n>
  • If advice is send_now, sign with suggestedFees directly (wei strings)
  • If advice is wait, wait waitMinutes and call /gas/advice again
  • For a deeper look, 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/advice?gasLimit=180000"
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
  • To send the transaction, use suggestedFees.medium as-is (wei strings). maxFeePerGas is a ceiling: the chain charges base fee plus priority and refunds the rest
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/advice when:

  • You need one quick send-now-or-wait decision before a single transaction
  • You want the decision and ready-to-sign fees in one call

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.