# Whats exactly Ether unit return web3.eth.estimateGas, wei, gwei ...?

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?

I think I found the answer, but if you go to the source code "eth.py", function signature says it's returning "Wei":

``````def estimateGas(self, transaction: TxParams, block_identifier: BlockIdentifier=None) -> Wei:
``````

This is actually very misleading. I tested this out. It returned "239231", but in what unit? You should interpret the number as follows:

``````gas_estimate
239231
gas_price = w3.eth.gasPrice
gas_price
5000000000000
gas_estimate_wei = gas_estimate * gas_price
gas_estimate_wei
1196155000000000000
gas_estimate_in_coin = gas_estimate_wei / (1000000000 * 1000000000)
gas_estimate_in_coin
1.196155
``````

How you should interpret the numbers are as follows:

gas_estimate = 239231 units

gas_price = 5000,000,000,000 wei per unit

Or

gas_price = 5000 gwei per unit

So, "gas_estimate_in_coin" = 1.196155. Now, what "coin"? It depends on the chain you're interacting with. If you're interacting with CRONOS, that's 1.196155 CRO, which is about 49.9 cents in USD (CROUSDT = 0.4168 on 20220413)! On the other hand, on Ethereum mainnet, that's 1.196155 ETH, which changed everything!!!

References

(Wei, Gwei, ETH conversion)

https://blog.oasis.app/gas-fees-a-small-guide/

https://www.thebalance.com/gwei-5194614

https://norman-lm-fung.medium.com/interact-with-cronos-single-usdc-lp-with-web3-py-1e14c62a0d9c

Similar question: Smart Contract - approve function: wad

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.

• 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. Commented May 27, 2021 at 9:56
• For that you need to use `web3.eth.getGasPrice`. Commented May 27, 2021 at 10:06
• getGasPrice is a fixed value by the chain. I dont need that. Commented May 27, 2021 at 19:43
• 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. Commented May 28, 2021 at 3:47
• this awnser is prerry correct to what was asked, why somebody downvoted it. estimateGas returns the gas limit, its unit is gas 'unit'. Commented Sep 13, 2022 at 0:48