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
| Name | Required | Description | Default |
|---|---|---|---|
| transaction | Yes | The transaction to estimate gas for |
Implementation Reference
- src/handlers/wallet.ts:600-619 (handler)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}`); } };
- src/tools.ts:450-469 (schema)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,