Portal
Search…
eth_estimateGas
Estimate gas needed for execution of given contract
1
web3.eth.estimateGas(callObject [, callback])
Copied!

Parameters

    1.
    A transaction object.
    2.
    (optional) Optional callback, returns an error object as first parameter and the result as second.

Returns

the used gas for the simulated call/transaction.

Example

1
web3.eth.estimateGas({
2
from : account1,
3
to : account2
4
}).then(console.log);
5
> 21000
Copied!
Last modified 9mo ago
Copy link