Defined in the Ethereum JSON-RPC Specification
Generates and returns an estimate of how much gas is necessary to allow the transaction to complete.
Parameters
The transaction call object.Show Transaction object properties
The address the transaction is sent from (20 bytes).
The address the transaction is directed to (20 bytes).
Integer of the gas provided for the transaction execution.
Integer of the gasPrice used for each paid gas.
Integer of the value sent with this transaction.
Hash of the method signature and encoded parameters.
Returns
The amount of gas used as a hexadecimal string.
{
"id": 1,
"jsonrpc": "2.0",
"method": "eth_estimateGas",
"params": [{
"from": "0xb60e8dd61c5d32be8058bb8eb970870f07233155",
"to": "0xd46e8dd67c5d32be8058bb8eb970870f07244567",
"gas": "0x76c0",
"gasPrice": "0x9184e72a000",
"value": "0x9184e72a",
"data": "0xd46e8dd67c5d32be8d24c6b0afe7c5c3f4e9c3b2"
}]
}
{
"id": 1,
"jsonrpc": "2.0",
"result": "0x5208"
}
Error Handling
Code | Message | Description |
---|
-32602 | Invalid params | Invalid transaction parameters |
-32000 | Execution reverted | Transaction would revert during execution |
4100 | Requested method not supported | The method is not supported by the wallet |
The estimate may not be accurate if the blockchain state changes between the estimation and actual execution.