Skip to main content
Tempo API method that estimates the gas needed to execute a transaction. On Tempo, gas fees are paid in TIP-20 stablecoins, not a native token.

Parameters

  • callObject — the call object:
    • from — (optional) address the transaction is sent from
    • to — (optional) address the transaction is directed to
    • gas — (optional) gas provided for the transaction
    • gasPrice — (optional) gas price
    • value — (optional) value sent with the transaction
    • data — (optional) hash of the method signature and encoded parameters

Response

  • result — the estimated gas amount encoded as hexadecimal

eth_estimateGas code examples

const Web3 = require("web3");
const NODE_URL = "CHAINSTACK_NODE_URL";
const web3 = new Web3(NODE_URL);

async function estimateGas() {
  const gas = await web3.eth.estimateGas({
    from: "0x9729187D9E8Bbefa8295F39f5634cA454dd9d294",
    to: "0x20c0000000000000000000000000000000000000",
    data: "0x70a082310000000000000000000000009729187d9e8bbefa8295f39f5634ca454dd9d294"
  });
  console.log(`Estimated gas: ${gas}`);
}

estimateGas()