Register and show off your project at Ethereum QuickPitch and win $10,000. Apply now

Contents

eth_estimateGas RPC method

The API credit value for this method is 10 . To learn more about API credits and each method's value, visit the API Credits page.

Parameters:

  1. Object - Transaction object, where from field is optional and nonce field is ommited.
  2. Quantity or Tag - (optional) Integer block number, or the string 'latest', 'earliest' or 'pending'. For more information, see the default block parameter description in Ethereum's documentation.

Returns:

  1. Quantity - The estimated amount of gas used.

Code Examples:

const ethers = require("ethers");
(async () => {
  const provider = new ethers.providers.JsonRpcProvider("http://sample-endpoint-name.network.quiknode.pro/token-goes-here/");
  const estimate = await provider.estimateGas({
    from: "0x8D97689C9818892B700e27F316cc3E41e17fBeb9",
    to: "0xd3CdA913deB6f67967B99D67aCDFa1712C293601",
    value: 1,
  });
  console.log(estimate);
})();
Ready to get started? Create a free account