Skip to main content
Glama

GAS_PRICE

Check current gas prices on blockchain networks to optimize transaction costs when using decentralized exchanges.

Instructions

Get gas price

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
chainNoThe blockchain network to execute the transaction on. uses fraxtal as defaultfraxtal

Implementation Reference

  • The main handler function that executes the GAS_PRICE tool. It resolves the chain, uses ChainService to fetch the gas price, and returns it as JSON.
    export const gasPrice = async (args: z.infer<typeof chainParamsSchema>) => { try { const inputChain = args.chain.toLowerCase(); const chainObject = getChainFromName(inputChain); console.error(`[GAS_PRICE] Using chain: ${chainObject} (${chainObject.id})`); const service = new ChainService(); const gasPrice = await service.gasPrice(chainObject.id); if (gasPrice instanceof Error) { return `Error fetching gasPrice: ${gasPrice.message}`; } return JSON.stringify(gasPrice, null, 2); } catch (error: unknown) { const message = error instanceof Error ? error.message : "An unknown error occurred while fetching gasPrice."; console.error(`[GAS_PRICE] Error: ${message}`); throw new Error(`Failed to fetch gasPrice: ${message}`); } };
  • Registration of the GAS_PRICE tool in the tools export, specifying name, description, parameters schema, and execute handler.
    gasPrice: { name: "GAS_PRICE", description: "Get gas price", parameters: chainParamsSchema, execute: chainExecute.gasPrice },
  • Zod schema for chainParams used as input parameters for GAS_PRICE tool.
    export const chainParamsSchema = z.object({ chain: z .string() .optional() .describe( "The blockchain network to execute the transaction on. uses fraxtal as default", ) .default("fraxtal") });

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/openocean-finance/openocean-mcp'

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