Skip to main content
Glama
buildwithgrove

Grove's MCP Server for Pocket Network

estimate_gas

Calculate transaction gas costs on multiple blockchains to optimize network fees before execution.

Instructions

Estimate gas required for a transaction

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
blockchainYesBlockchain name
transactionYesTransaction object with from, to, data, value, etc.
networkNoNetwork type (defaults to mainnet)

Implementation Reference

  • The handler logic for the 'estimate_gas' tool. Extracts parameters from args and delegates to AdvancedBlockchainService.estimateGas, then formats the response as MCP content.
    case 'estimate_gas': {
      const blockchain = args?.blockchain as string;
      const transaction = args?.transaction as any;
      const network = (args?.network as 'mainnet' | 'testnet') || 'mainnet';
    
      const result = await advancedBlockchain.estimateGas(blockchain, transaction, network);
    
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(result, null, 2),
          },
        ],
        isError: !result.success,
      };
    }
  • Input schema definition for the 'estimate_gas' tool, specifying required blockchain, transaction object, and optional network.
    inputSchema: {
      type: 'object',
      properties: {
        blockchain: {
          type: 'string',
          description: 'Blockchain name',
        },
        transaction: {
          type: 'object',
          description: 'Transaction object with from, to, data, value, etc.',
        },
        network: {
          type: 'string',
          enum: ['mainnet', 'testnet'],
          description: 'Network type (defaults to mainnet)',
        },
      },
      required: ['blockchain', 'transaction'],
    },
  • Tool object registration for 'estimate_gas' returned by registerTransactionHandlers, including name, description, and schema. Added to global tools list in src/index.ts.
    {
      name: 'estimate_gas',
      description: 'Estimate gas required for a transaction',
      inputSchema: {
        type: 'object',
        properties: {
          blockchain: {
            type: 'string',
            description: 'Blockchain name',
          },
          transaction: {
            type: 'object',
            description: 'Transaction object with from, to, data, value, etc.',
          },
          network: {
            type: 'string',
            enum: ['mainnet', 'testnet'],
            description: 'Network type (defaults to mainnet)',
          },
        },
        required: ['blockchain', 'transaction'],
      },
    },
  • Supporting method in AdvancedBlockchainService that performs the actual RPC call to 'eth_estimateGas' via the blockchain service.
    async estimateGas(
      blockchain: string,
      transaction: any,
      network: 'mainnet' | 'testnet' = 'mainnet'
    ): Promise<EndpointResponse> {
      const service = this.blockchainService.getServiceByBlockchain(blockchain, network);
    
      if (!service) {
        return {
          success: false,
          error: `Blockchain service not found: ${blockchain} (${network})`,
        };
      }
    
      return this.blockchainService.callRPCMethod(
        service.id,
        'eth_estimateGas',
        [transaction]
      );
    }

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/buildwithgrove/mcp-pocket'

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