1

I am testing with function web3.eth.estimateGas and is not clear what Ether unit is returning.

Looks like it's gwei, but my final calculations don't match.

In my code, the EGAS returned is 84753. I think it is too little to be wei or gwei

How can I convert to wei the uint returned by estimateGas function?

0

It returns the gas limit, not the gas price. Gas limit is how many units of gas to use at most, and a unit of gas is your gas price.

4
  • I dont want to know te gasPrice. There is a web3js function for that. I need to know the real fee for a transaccion in Wei.
    – JTConsulta
    May 27 '21 at 9:56
  • For that you need to use web3.eth.getGasPrice.
    – bru53001
    May 27 '21 at 10:06
  • getGasPrice is a fixed value by the chain. I dont need that.
    – JTConsulta
    May 27 '21 at 19:43
  • 3
    What? It literally returns the thing you want, the gas price in Wei. Also it is NOT a fixed value. Try multiplying estimateGas with getGasPrice for a transaction's total fee in wei.
    – bru53001
    May 28 '21 at 3:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.