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
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "GAS_PRICE"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| chain | No | The blockchain network to execute the transaction on. uses fraxtal as default | fraxtal |
Implementation Reference
- src/tools/chain.ts:13-35 (handler)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}`); } }; - src/types.ts:4-12 (schema)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") }); - src/tools/index.ts:22-27 (registration)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 },