Skip to main content
Glama

evm_estimate_gas

Estimate gas for EVM transactions with a 20% safety buffer to predict costs and avoid out-of-gas failures before signing.

Instructions

Estimate gas required for a transaction with automatic 20% safety buffer.

Simulates transaction execution to determine gas consumption. Returns estimated gas limit with built-in safety buffer to prevent out-of-gas failures.

CRITICAL RULES:

  • Estimation simulates execution without committing to blockchain

  • Includes 20% safety buffer above raw estimate

  • May fail if transaction would revert (shows reason)

  • Gas estimate varies based on contract state and input data

  • "from" address must have sufficient balance if checking value transfers

PARAMETERS:

  • chain: EVM chain for gas estimation (required)

    • Gas costs are chain-specific

    • Same transaction uses different gas on different chains

    • Example: Contract call may cost 200k gas on Ethereum, 150k on Polygon

  • from: Sender address (optional but recommended)

    • Required for checking balance requirements

    • Affects gas calculation for some contracts

    • Use zero address (0x0000...0000) if unknown

  • to: Target address (required)

    • Contract address for contract calls

    • EOA address for simple transfers

    • Format: 0x followed by 40 hex characters

  • value: Amount to send in ether (optional)

    • For native currency transfers

    • Example: "0.1" for 0.1 ETH/POL/etc.

    • Leave empty for zero-value transactions

  • data: Transaction data (optional)

    • Hex-encoded function call data for contracts

    • Empty for simple transfers

    • Format: 0x + hex string

EXAMPLES: ✅ Estimate simple transfer: {chain: "polygon", to: "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb", value: "0.1"}

✅ Estimate contract call: {chain: "ethereum", from: "0x...", to: "0x...", data: "0xa9059cbb..."}

✅ Check deployment gas: {chain: "bsc", to: "0x0000000000000000000000000000000000000000", data: "0x608060..."}

❌ Invalid - missing recipient: {chain: "polygon", value: "1.0"} // No "to" address

❌ Invalid - wrong data format: {chain: "ethereum", to: "0x...", data: "abc123"} // Missing 0x prefix

SUPPORTED EVM CHAINS (7 networks): • ethereum (Sepolia) - EIP-1559 enabled, ~12s blocks, moderate gas costs • polygon (Amoy) - Low fees, fast finality (~2s), layer 2 • avalanche (Fuji C-Chain) - Sub-second finality, dynamic fees • bsc (BNB Testnet) - 3s blocks, low gas costs, Binance ecosystem • arbitrum (Sepolia) - Optimistic rollup, low fees, Ethereum security • base (Sepolia) - Coinbase layer 2, EIP-1559, low fees • worldchain (World Sepolia) - World Network testnet, EIP-1559

CRITICAL GAS CONSIDERATIONS:

  • Ethereum: High gas costs, use gas oracle for timing

  • Polygon/BSC: Very low gas, safe for frequent transactions

  • Arbitrum/Base: L2 optimizations, ~10-50x cheaper than Ethereum

  • Avalanche: Dynamic fees, can spike during congestion

  • Always check gas price before executing transactions

TESTNET TOKENS: All chains use testnet tokens with NO REAL VALUE. Faucets available for all supported networks.

OUTPUT STRUCTURE: • success: Boolean indicating estimation success • chain: Chain used for estimation • estimatedGas: Raw gas estimate (units) • gasLimit: Recommended gas limit (with 20% buffer) • estimatedCost: Approximate cost in native currency • gasPrice: Current gas price used for cost calculation • executionTime: Time taken in milliseconds

COMMON MISTAKES:

  • Not including "from" when balance checks matter

  • Using estimated gas without safety buffer (use gasLimit instead)

  • Estimating with stale state (contract state may change)

  • Forgetting gas estimates can fail if transaction would revert

  • Not accounting for gas price in total cost calculation

USE CASES:

  • Calculate transaction costs before signing

  • Verify contract interactions will succeed

  • Determine optimal gas limits for transactions

  • Compare gas costs across different contract methods

  • Budget for transaction batches

GAS ESTIMATION TIPS:

  • Add 20-30% buffer to raw estimates for safety

  • Re-estimate before submitting if state has changed

  • Higher gas limit doesn't cost more (only gas used is charged)

  • Failed estimates often indicate transaction will revert

  • Contract calls use more gas than simple transfers

Running on Linux.

LINUX-SPECIFIC NOTES:

  • Package manager: apt (Ubuntu/Debian), yum (RHEL/CentOS), or pacman (Arch)

  • Python 3 is typically 'python3' command

  • GNU tools are standard

  • Use 'xdg-open' command to open files/applications

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "chain": "<chain>",
      "to": "<to>"
    },
    "name": "evm_estimate_gas"
  }
}

Input Schema

NameRequiredDescriptionDefault
toYesRecipient address (0x... - 42 characters)
dataNoTransaction data (optional, 0x... hex string)
fromNoSender address (optional but recommended, 0x...)
chainYesEVM chain to estimate gas on
valueNoAmount to send in ether (optional, e.g., "0.1")

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.0.0

TDQS

A4.1/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full disclosure burden and does so well: it states that estimation simulates execution without committing, that a 20% buffer is applied, that it fails with a revert reason, that results vary with contract state, and that 'from' needs balance for value checks. It omits auth, rate limits, and whether estimates are cached, which keeps it short of a 5.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness2/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The purpose is front-loaded, but the body is heavily padded: the 20% buffer is restated three times, GAS ESTIMATION TIPS duplicates CRITICAL RULES and COMMON MISTAKES, and the example invalids restate schema constraints. Worst, the trailing LINUX-SPECIFIC NOTES about apt/yum/xdg-open are entirely unrelated to gas estimation and inject noise into the tool definition.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

No output schema exists, yet the description supplies an explicit OUTPUT STRUCTURE with field meanings (estimatedGas vs gasLimit vs estimatedCost), which is exactly what the agent needs to interpret results. The supported-chain enum and its per-chain properties are also covered, leaving only auth/limits unstated.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so the baseline is 3, but the description genuinely adds meaning: chain-specific gas divergence with a concrete Ethereum-vs-Polygon comparison, the zero-address workaround when 'from' is unknown, and the units of 'value' (ether in native currency). The data-format examples largely restate the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The opening sentence names a specific verb and resource ('Estimate gas required for a transaction') and adds the distinguishing behavior 'automatic 20% safety buffer'. That separates it from the price/lookup siblings such as evm_get_gas_price and evm_get_gas_oracle without needing the schema.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

USE CASES and COMMON MISTAKES sections give concrete situations to invoke it (costing before signing, verifying a contract call would succeed, budgeting batches) plus failure conditions to watch. What is missing is any explicit routing to sibling tools — nothing says to use evm_get_gas_price for a price-only lookup or evm_estimate_fees for a full fee breakdown instead.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Deploy Server

Other Tools