Skip to main content
Glama

provider_estimate_gas

Calculate the gas needed for Ethereum or EVM-compatible transactions to ensure accurate fee estimation and successful execution.

Instructions

Estimate the gas required for a transaction

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
transactionYesThe transaction to estimate gas for

Implementation Reference

  • The handler function that executes the provider_estimate_gas tool by calling estimateGas on the provider with the input transaction.
    export const estimateGasHandler = async (input: any): Promise<ToolResultSchema> => { try { if (!input.transaction) { return createErrorResponse("Transaction is required"); } const provider = getProvider(); if (!provider) { return createErrorResponse("Provider is required to estimate gas, please set the provider URL"); } const gasEstimate = await provider.estimateGas(input.transaction); return createSuccessResponse( `Gas estimate retrieved successfully Gas estimate: ${gasEstimate.toString()} `); } catch (error) { return createErrorResponse(`Failed to estimate gas: ${(error as Error).message}`); } };
  • The input schema definition for the provider_estimate_gas tool in the tools array.
    { name: "provider_estimate_gas", description: "Estimate the gas required for a transaction", inputSchema: { type: "object", properties: { transaction: { type: "object", description: "The transaction to estimate gas for", properties: { to: { type: "string" }, from: { type: "string" }, data: { type: "string" }, value: { type: "string" } } } }, required: ["transaction"] } },
  • src/tools.ts:595-595 (registration)
    Registration mapping the tool name 'provider_estimate_gas' to its handler function in the handlers dictionary.
    "provider_estimate_gas": estimateGasHandler,

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/dcSpark/mcp-cryptowallet-evm'

If you have feedback or need assistance with the MCP directory API, please join our Discord server