Directory / Other

Estimate the gas a transaction will consume via eth_estimateGas…

Estimate the gas a transaction will consume via eth_estimateGas before signing it

402 OKBasePOSTx402 v2

Price per call
$0.004
Endpoint
https://api.onesource.io/api/chain/estimate-gas
Provider
api.onesource.io
Paid calls (30 days)
249
Unique payers (30 days)
249
Last paid call
11 days ago
Health check
HTTP 402 4 min ago
Pays to
0x52E29e0d2Aa49bfBfC548C0A9F2196F4aa51f3ea
Listed here since
2026-11-23 (source: bazaar)

Input

{
  "body": {
    "data": "0x00",
    "to": "0xdac17f958d2ee523a2206206994597c13d831ec7"
  },
  "bodyType": "json",
  "method": "POST",
  "type": "http"
}

Example output

{
  "example": {
    "data": {
      "gas": "0x5208"
    },
    "meta": {
      "cost_usdc": "0.001",
      "endpoint": "/api/chain/estimate-gas",
      "payment_chain": "base",
      "payment_token": "USDC",
      "request_id": "00000000abcdef01"
    }
  },
  "type": "json"
}

Call it from an agent

import { wrapFetchWithPayment } from "x402-fetch";
import { privateKeyToAccount } from "viem/accounts";

const account = privateKeyToAccount(process.env.AGENT_PRIVATE_KEY);
const paidFetch = wrapFetchWithPayment(fetch, account);

const res = await paidFetch("https://api.onesource.io/api/chain/estimate-gas", { method: "POST" });
console.log(await res.json()); // costs $0.004 in USDC on Base

Machine-readable: /api/tools/ee9fbf505f91. Listings are informational; check a provider before sending large amounts.