# Base Transaction Cost Estimator

> Base Transaction Cost Estimator is a paid API for AI agents from x402-data-api.bodhinindustries.workers.dev, paid per call via x402, $0.01/call, status unknown (last checked 2026-09-14).

Estimates the gas cost of a transaction on Base L2, returning gas units, effective gas price, ETH cost, and USD cost computed live from the chain with no third-party data.

## Facts

- Endpoint: GET https://x402-data-api.bodhinindustries.workers.dev/txcost
- Price: $0.01/call
- Payment: x402
- Status: unknown
- Last checked: 2026-09-14
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/base-transaction-cost-estimator-266789e0
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_KUpX3LnshpQvvZuPhNERz

Status and success rate cover calls made through Zero and Zero's own probes. Third-party monitors may report differently.

## How to call it through Zero

Zero handles the 402 payment challenge and records the run. With the Zero CLI installed (`npm i -g @zeroxyz/cli`):

```sh
zero fetch --capability base-transaction-cost-estimator-266789e0
```

Example prompt: Before I submit this contract call on Base, can you estimate the gas cost — the target is 0x1234...abcd, the calldata is 0xa9059cbb..., and my wallet is 0xabc...def — tell me the gas units, ETH cost, USD cost, and whether it will revert?

## When to prefer this

Use this endpoint when you need a live, self-computed gas cost estimate for a Base L2 transaction without relying on any external price feeds or third-party oracles. It is ideal for pre-flight transaction checks, cost budgeting, revert detection, and building autonomous agents that need trustless fee estimation directly from the Base chain.

## Known failure modes

- Missing 'to' parameter returns a 400 error
- Transaction simulation reverts — willRevert is true and revertReason is populated
- Invalid address format causes estimation failure
- Calldata that triggers out-of-gas errors returns null gasEstimate
- Network congestion on Base may cause delayed or stale block data

## How this service works

Self-computed Base onchain toolkit for AI agents: ERC-20 safety scan, manipulation-resistant TWAP price oracle, gas/fee oracle, calldata decoder, token/address/contract intel, wallet approval-risk audit, and batch token triage — all computed live from raw Base chain, no third-party data.

## Output

Returns the estimated gas units, effective gas price in Gwei, expected cost in ETH and USD (using a self-computed ETH/USD price), the Base block height at time of computation, whether the transaction would revert, the revert reason if any, and a flag confirming no third-party data was used.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "required": [
  "to"
 ],
 "properties": {
  "to": {
   "type": "string",
   "description": "Target address of the transaction."
  },
  "data": {
   "type": "string",
   "description": "Calldata hex (omit for a plain ETH transfer)."
  },
  "from": {
   "type": "string",
   "description": "Sender (msg.sender) — recommended for accurate estimates."
  },
  "value": {
   "type": "string",
   "description": "ETH value in wei (integer string)."
  }
 }
}
```

## Response schema (JSON Schema)

```json
{
 "type": "object",
 "properties": {
  "to": {
   "type": "string",
   "description": "target"
  },
  "from": {
   "type": "string",
   "description": "sender (or null)"
  },
  "block": {
   "type": "integer",
   "description": "Base block height"
  },
  "chain": {
   "type": "string",
   "description": "base"
  },
  "ethUsd": {
   "type": "number",
   "description": "self-computed ETH/USD"
  },
  "costEth": {
   "type": "string",
   "description": "expected cost in ETH (or null)"
  },
  "costUsd": {
   "type": "number",
   "description": "expected cost in USD (or null)"
  },
  "valueWei": {
   "type": "string",
   "description": "value in wei"
  },
  "computedAt": {
   "type": "string",
   "description": "ISO-8601 timestamp"
  },
  "willRevert": {
   "type": "boolean",
   "description": "estimateGas reverted"
  },
  "gasEstimate": {
   "type": "string",
   "description": "gas units (or null)"
  },
  "gasPriceGwei": {
   "type": "number",
   "description": "effective gas price used"
  },
  "revertReason": {
   "type": "string",
   "description": "revert reason (or null)"
  },
  "thirdPartyDataUsed": {
   "type": "boolean",
   "description": "always false"
  }
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/base-transaction-cost-estimator-266789e0/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from x402-data-api.bodhinindustries.workers.dev](https://www.zero.xyz/host/x402-data-api.bodhinindustries.workers.dev/llms.txt)
