eth_estimateGas RPC Method
The eth_estimateGas
method is used to estimate the gas that would be used by a transaction if it were to be executed. This transaction will not appear on blockchain
⚠️
eth_estimateGas
verifies the balance of the sender to ensure that the sender has sufficient gas to fulfill the request. While the call does not consume any gas, the from
address must have enough gas to execute the transaction.
Parameters
1.TRANSACTION CALL OBJECT
[required]
from
[optional] - The address are you sending transactions from.to
- The address where the transaction is sent to.gas
[optional] - Integer of the gas provided for the transaction execution. Althougheth_estimateGas
does not require gas, this parameter may still be needed by some executions.gasPrice
[optional] - The price to be paid per gas (hexadecimal format).maxPriorityFeePerGas
[optional] - Maximum fee, in Wei, the sender is ready to pay per gas above the base fee.maxFeePerGas
[optional] - Maximum total fee (base fee + priority fee), in Wei, the sender is ready to pay per gas.maxPriorityFeePerGas
andmaxFeePerGas
are used in the new type of Ethereum transactions called EIP 1559. Read more info here (opens in a new tab)
💎
maxPriorityFeePerGas
and maxFeePerGas
can not be used with gasPrice
in one transacion
💎
You can convert WEI
to ETH
on this page (opens in a new tab).
value
[optional] - Interger of the value transferred in the transaction. (How much do you send)data
[optional] - Hash of the method signature and encoded parameters. More info 👉 Ethereum Contract ABI (opens in a new tab)
Returns
Gas used
- the amount of gas used.
Request
POST https://<network>.chainnodes.org/YOUR-API-KEY
Example
💡
Confusing? Ask blockchain developers in Chainnodes Telegram Chat (opens in a new tab)
- HTTPS POST Request with a JSON RPC call in the body
- Replace YOUR-API-KEY with the API key from your Chainnodes.org Dashboard
- You can use a different supported network by replacing
mainnet
curl https://mainnet.chainnodes.org/YOUR-API-KEY \
-X POST \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"eth_estimateGas","params": [{"from": "0x47ac0Fb4F2D84898e4D9E7b4DaB3C24507a6D503","to": "0xdAC17F958D2ee523a2206206994597C13D831ec7","gas": "0x30D40","gasPrice": "0x2E90EDD000","value": "0x0","data": "0xa9059cbb000000000000000000000000d6216fc19db775df9774a6e33526131da7d19a2c0000000000000000000000000000000000000000000000000000000005f5e100"}],"id":1}'
Body
{
"jsonrpc": "2.0",
"id": 1,
"result": "0xb411"
}