estimateGas

Estimates the gas required to execute a transaction. The gas is returned as a bigint and in gwei units.

Example

import { estimateGas } from "thirdweb";
const gas = await estimateGas({
transaction,
from: "0x...",
});
function estimateGas(
): Promise<EstimateGasResult>;

Parameters

The options for estimating gas.

Type

let options: Prettify<
{ transaction: PreparedTransaction<any> } & (
| { account: Account; from?: never }
| { account?: never; from?: string }
)
>;

Returns

let returnType: bigint;

A promise that resolves to the estimated gas as a bigint.