Skip to main content
Glama

wallet_get_gas_price

Retrieve the current gas price on Ethereum and EVM-compatible blockchains to optimize transaction costs for wallet operations.

Instructions

Get the current gas price

Input Schema

NameRequiredDescriptionDefault
walletNoThe wallet (private key, mnemonic, or JSON). If not provided, uses PRIVATE_KEY environment variable if set.

Input Schema (JSON Schema)

{ "properties": { "wallet": { "description": "The wallet (private key, mnemonic, or JSON). If not provided, uses PRIVATE_KEY environment variable if set.", "type": "string" } }, "required": [], "type": "object" }

Implementation Reference

  • The handler function that executes the wallet_get_gas_price tool. It retrieves the connected wallet, checks for a provider, fetches the current gas price using wallet.getGasPrice(), formats it, and returns the result or error.
    export const getGasPriceHandler = async (input: any): Promise<ToolResultSchema> => { try { const wallet = await getWallet(input.wallet, input.password); if (!wallet.provider) { return createErrorResponse("Provider is required to get gas price, please set the provider URL"); } const gasPrice = await wallet.getGasPrice(); return createSuccessResponse( `Gas price retrieved successfully Gas price: ${gasPrice.toString()} Gas price in Gwei: ${ethers.utils.formatUnits(gasPrice, "gwei")} `); } catch (error) { return createErrorResponse(`Failed to get gas price: ${(error as Error).message}`); } };
  • Input schema definition for the wallet_get_gas_price tool, specifying the optional wallet parameter.
    { name: "wallet_get_gas_price", description: "Get the current gas price", inputSchema: { type: "object", properties: { wallet: { type: "string", description: "The wallet (private key, mnemonic, or JSON). If not provided, uses PRIVATE_KEY environment variable if set." } }, required: [] } },
  • src/tools.ts:574-574 (registration)
    Registration of the wallet_get_gas_price tool to its handler function in the handlers dictionary.
    "wallet_get_gas_price": getGasPriceHandler,

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