For the complete documentation index, see llms.txt. This page is also available as Markdown.

useGetGasPrice

Description

This hook fetches the current gas price for transactions on the connected blockchain. It leverages a public client to estimate the gas fees and provides both maxFeePerGas and maxPriorityFeePerGas values.

The maxFeePerGas is calculated with a buffer, doubling the estimated fee to accommodate potential fluctuations in gas prices.

This hook is useful for determining the cost of transactions in real-time.

Parameters

  • rpcUrl? (string) : An optional RPC URL to use for the public client. If not provided, the default RPC URL associated with the smart account will be used.

Returns

  • data (GasPriceResult | undefined): The fetched gas price data, containing maxFeePerGas and maxPriorityFeePerGas.

  • isLoading (boolean): A boolean indicating whether the data is currently being fetched.

  • error (Error | null): An error object if an error occurred during the fetching process, otherwise null.

Example

Usage context

The useGetGasPrice hook must be used within a context that provides access to useSmartAccount. This ensures that the smartAccountClient and queryClient are available, and it avoids errors related to missing context or data.

Last updated