Skip to main content

Gas Estimation and Overrides

The thirdweb SDK allows you to:

  • View the current gas cost in gwei
  • Estimate the gas cost of a transaction at the current point in time
  • Override parts of a transaction (e.g. gas limit, gas price, nonce, from, value, etc...)

Current Gas Price

const gasCostInGwei = await contract.estimator.currentGasPriceInGwei();
View in Javascript SDK Documentation

Estimate Transaction Gas Cost

const costOfBurn = await contract?.estimator.gasCostOf("burn", [0]);
View in Javascript SDK Documentation

Override Transaction Data

contract.interceptor.overrideNextTransaction(() => ({
gasLimit: 3000000,
}));
View in Javascript SDK Documentation