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
| Name | Required | Description | Default |
|---|---|---|---|
| wallet | No | The 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
- src/handlers/wallet.ts:255-273 (handler)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}`); } };
- src/tools.ts:199-209 (schema)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,