Gas price
GET /api/gas-estimate · Cached 30sCurrent gas price on Base, Polygon, Arbitrum, Optimism, Ethereum, Monad, Celo, Avalanche, Sei, or Robinhood Chain - for an agent budgeting a transaction: returns network, gasPriceGwei and gasPriceWei (decimal strings) from the chain's own eth_gasPrice, the node's suggested all-in price per gas unit. Send GET /api/gas-estimate with no required fields (1 optional) and pay $0.001 per call over x402 or MPP (there is no free tier). It returns a JSON object with network, gasPriceGwei and gasPriceWei.
Multiply by the gas a transaction uses (21000 for a plain transfer) for its fee. Read-only. ?network=base
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
network | string | no | chain: base | polygon | arbitrum | optimism | ethereum | monad | celo | avalanche | sei | robinhood (default base) |
Example request
curl -i "https://agent402.tools/api/gas-estimate?network=base"
Without payment this returns HTTP 402 Payment Required with the exact price for gas-estimate; any x402 v2 or MPP client pays it and retries.
Example response
{
"network": "base",
"gasPriceGwei": "0.0051",
"gasPriceWei": "5100000"
}
| Field | Type | Always present | In the example |
|---|---|---|---|
network | string | yes | base |
gasPriceGwei | string | yes | 0.0051 |
gasPriceWei | string | yes | 5100000 |
From an MCP client
catalog.call {
"slug": "gas-estimate",
"params": {
"network": "base"
}
}
The hosted connector at https://agent402.tools/mcp needs a payment for gas-estimate; the stdio package pays it from a wallet or from AGENT402_CREDITS_KEY. Local install: npx -y agent402-mcp.
Errors and behavior
- Every field is optional. An input the tool rejects returns an HTTP 4xx whose body carries
error,tool,expected,requiredandexample. - A paid call that ends in any status of 400 or above is not charged over x402, MPP or a prepaid credits key: settlement is cancelled when the tool fails. The exception is a Tempo push credential, a transfer the buyer sent before the call: it settles before the tool runs, so if the tool then fails the payment is recorded as a refund owed to the paying wallet.
- Wallet-only: this tool reaches the network or stored state, so it has no proof-of-work tier. A prepaid card-credits key issued earlier (
Authorization: Bearer a402_...) also pays it. - Cached: an identical request within 30s is answered from cache with
X-Cache: hit. - A
POSTwith a JSON body to /api/gas-estimate is served as this GET, with the body as the input. - An
Idempotency-Keyheader makes a retried paid call replay the first 200 instead of charging again (an answer larger than 1 MB is not replayed).
Paid call (JavaScript agent)
import { wrapFetchWithPayment } from "@x402/fetch";
import { x402Client } from "@x402/core/client";
import { registerExactEvmScheme } from "@x402/evm/exact/client";
import { privateKeyToAccount } from "viem/accounts";
const client = new x402Client();
client.setSpendControls?.(false); // keep your own spending ceiling in code
registerExactEvmScheme(client, { signer: privateKeyToAccount(KEY) });
const payFetch = wrapFetchWithPayment(fetch, client);
const res = await payFetch("https://agent402.tools/api/gas-estimate?network=base");
Part of these workflows
Gas price is one step in these 3 skill packs, each sold as a single call:
- Macro dashboard refresh - The full macro + crypto dashboard in one call: 5 FRED series, 5 Treasury reads, yield-curve spread, crypto market/trending/global, and live gas - the 14-tool basket recurring buyers refresh every cycle, bundled below its a la carte price.
- Cheapest rail right now - Where should an agent transact this minute? Live gas on Ethereum + every major L2 side by side, Base gas tiers, a fee estimate for your transaction type, and ETH spot to price it all in dollars.
- Gas optimizer - Find the cheapest gas right now: Base gas, Ethereum gas, Base fee estimate, and ETH price for USD conversion.
Related tools
Transaction status
GET /api/tx-statusCheck the confirmation status of a transaction by hash on Base/Polygon/Arbitrum/Optimism/Ethereum/Monad/Celo/Avalanche/S…
Build USDC transfer authorization
POST /api/transfer-authorizationBuild the EIP-3009 transferWithAuthorization typed data for a gasless USDC transfer on Base/Polygon/Arbitrum/Optimism/Et…
USDC balance
GET /api/usdc-balanceRead the USDC balance of any address on Base, Polygon, Arbitrum, Optimism, Ethereum, Monad, Celo, Avalanche, or Sei. Rea…
Verify x402 settlement
GET /api/x402-verifyConfirm a USDC payment actually settled: given a tx hash (and network), returns whether it succeeded and the USDC transf…
Gas snapshot (slow / standard / fast)
POST /api/gas-snapshotLive gas price snapshot for a chain - slow / standard / fast tiers in gwei, plus the latest base fee. Sampled from eth_f…
B20 activation check
GET /api/b20-activation-checkIs B20 live on Base mainnet? Queries the Activation Registry precompile for base.b20_asset and base.b20_stablecoin (or a…