Skip to main content
Glama

Estimate contract gas

estimate_contract_gas
Read-only

Estimate the gas a contract function call would use from a given address, plus its cost at the current gas price, without signing or sending anything. Reveals revert reasons.

Instructions

Estimate the gas a contract function call would use if sent from from_address, and its cost at the current gas price. Nothing is signed or sent. A call that would revert returns success false with the reason in error.

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": {
      "contract_address": "<contract_address>",
      "function_name": "<function_name>",
      "abi": "<abi>",
      "from_address": "<from_address>"
    },
    "name": "estimate_contract_gas"
  }
}

Input Schema

NameRequiredDescriptionDefault
abiYesThe contract ABI, as a JSON array or a JSON string. Only the entry for function_name is needed.
valueNoCELO to send with the call, in wei.0
from_addressYesThe address the call would be sent from.
function_argsNoPositional arguments for the function.
function_nameYesThe function to estimate, as named in the ABI.
contract_addressYesThe contract address.

Output Schema

NameRequiredDescriptionDefault
errorNoError message if failed
successYesWhether estimation was successful
gas_priceYesCurrent gas price
total_costYesTotal cost in wei
gas_estimateYesEstimated gas limit
function_nameYesFunction name
contract_addressYesContract address

Schema Changelog

Changes observed during successful MCP inspections.

  1. Addedv0.5.0

TDQS

A3.8/5.0
Behavior4/5

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

Beyond the read-only annotation, the description discloses that nothing is signed or sent and that a reverting call returns success false with the reason in error. These are meaningful behavioral details about safety and failure handling that the annotations alone do not convey.

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

Conciseness5/5

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

The description is two tightly written sentences with no wasted wording. The core purpose is front-loaded, and the non-mutating and revert behavior follow naturally.

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?

Given that the input schema is fully described, annotations declare read-only and open-world behavior, and an output schema exists, the description covers the essential context: estimation, no signing or sending, and revert handling. It is complete enough for an agent to call correctly without over-explaining fields already covered by the schema.

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

Parameters3/5

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

Schema description coverage is 100%, so all six parameters are already documented in the schema, including abi, value, from_address, function_args, function_name, and contract_address. The description references from_address but adds no additional parameter meaning beyond what the schema provides.

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

Purpose4/5

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

The description states a specific verb and resource: estimating gas for a contract function call from a given address, plus its current cost. It is clear what the tool does, but it does not explicitly distinguish itself from siblings such as call_contract_function or estimate_transaction.

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

Usage Guidelines3/5

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

The description implies usage for preflight estimation by saying nothing is signed or sent, which helps an agent understand this is a simulation rather than execution. However, it gives no explicit when-to-use guidance or named alternatives for cases like estimating a plain transaction versus a contract call.

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