Docs

useEstimateGasCost

A hook to estimate the gas cost in ether and wei for a given transaction.

Example

import { useEstimateGasCost } from "thirdweb/react";
const { mutate: estimateGasCost, data: gasEstimate } =
useEstimateGas();
// later
const estimatedGas = await estimateGasCost(tx);
console.log("gas cost in ether", estimatedGas.ether);

Returns

A mutation object to estimate gas cost.