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
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": "wallet_get_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. |
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,