eth_estimateGas RPC Method
Calculates the approximate gas needed to execute a given transaction without broadcasting it.
Parameters#
Transaction call object with the following fields:
Sender address for the call.
Recipient address of the call.
Gas budget allocated for execution, hex-encoded.
Upper bound on the per-gas fee the caller will pay, hex-encoded.
Tip per unit of gas for the block producer, hex-encoded.
Amount of native token attached to the call, hex-encoded.
Contract bytecode or ABI-encoded function selector with arguments.
Same as input — contract bytecode or ABI-encoded call data.
Caller nonce, hex-encoded.
Target chain identifier, hex-encoded.
EIP-2930 access list.
EIP-7702 authorization list.
Block identifier — a tag (latest, safe, finalized, pending) or a 32-byte block hash.
Result#
string - The approximate gas required, hex-encoded.
Code sample#
{
"jsonrpc": "2.0",
"method": "eth_estimateGas",
"params": [
{
"to": "0x6b175474e89094c44da98b954eedeac495271d0f",
"data": "0x70a08231000000000000000000000000407d73d8a49eeb85d32cf465507dd71d507100c1"
},
"latest"
],
"id": 1
}
Response#
{
"jsonrpc": "2.0",
"id": 1,
"result": "0x5208"
}