Skip to main content
Glama

GAS_PRICE

Check current gas prices on blockchain networks to estimate transaction costs before executing swaps or transfers on 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 execute handler function for the GAS_PRICE tool. Resolves the chain name, instantiates ChainService, fetches gas price, and returns JSON or error.
    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}`); } };
  • Input schema (parameters) for GAS_PRICE tool, defining optional 'chain' parameter defaulting to 'fraxtal'.
    export const chainParamsSchema = z.object({ chain: z .string() .optional() .describe( "The blockchain network to execute the transaction on. uses fraxtal as default", ) .default("fraxtal") });
  • Registration of the GAS_PRICE tool in the tools export object, linking name, description, parameters, and execute handler.
    gasPrice: { name: "GAS_PRICE", description: "Get gas price", parameters: chainParamsSchema, execute: chainExecute.gasPrice },

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