Skip to main content

eth_estimateGas RPC Method

Returns an estimation of gas for a given transaction.

Updated on
Nov 2, 2023

eth_estimateGas RPC Method

Parameters

transaction
object
The transaction call object. If no field is provided, the latest block is used by default
from
string
The address from which the transaction is sent
to
string
The address to which the transaction is addressed
gas
integer
The integer of gas provided for the transaction execution
gasPrice
integer
The integer of gasPrice used for each paid gas encoded as hexadecimal
value
integer
The integer of value sent with this transaction encoded as hexadecimal
data
string
The hash of the method signature and encoded parameters. For more information, see the Contract ABI description in the Solidity documentation.
blockNumber
string
REQUIRED
The block number in hexadecimal format or the string latest, earliest, pending, safe or finalized
Object
object
The State Override Set option allows you to change the state of a contract before executing the call, which means you can modify the values of variables stored in the contract, such as balances and approvals for that call without actually modifying the contract. Each address maps to an object containing:
balance
string
The fake balance to set for the account before executing the call
nonce
string
The fake nonce to set for the account before executing the call
code
string
The fake EVM bytecode to inject into the account before executing the call
state
object
The fake key-value mapping to override all slots in the account storage before executing the call
stateDiff
integer
The fake key-value mapping to override individual slots in the account storage before executing the call

Returns

quantity
The estimated gas consumption for a transaction, provided as a hexadecimal value
Request
1
curl https://docs-demo.arbitrum-mainnet.quiknode.pro/ \
2
-X POST \
3
-H "Content-Type: application/json" \
4
--data '{
5
"method": "eth_estimateGas",
6
"params": [
7
{
8
"from": "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045",
9
"to": "0xd3CdA913deB6f67967B99D67aCDFa1712C293601",
10
"value": "0x1"
11
},
12
"latest",
13
{
14
"0x1111111111111111111111111111111111111111": {
15
"balance": "0xFFFFFFFFFFFFFFFFFFFF"
16
}
17
}
18
],
19
"id": 1,
20
"jsonrpc": "2.0"
21
}'
Don't have an account yet?
Create your QuickNode endpoint in seconds and start building
Get started for free