The eth_estimateGas
method calculates the amount of gas required to execute a transaction. This estimation is done without sending the transaction to the network. It's important to note that the actual gas used by the transaction may differ from the estimate due to the dynamic nature of Ronin transactions and block inclusion.
Get you own node endpoint today
Start for free and get your app to production levels immediately. No credit card required.
You can sign up with your GitHub, X, Google, or Microsoft account.
Parameters
transaction
: An object containing transaction fields, including:from
(optional): The address the transaction is sent from.to
: The address the transaction is directed to.- Additional fields such as
value
,data
, andgasPrice
can also be included for a more accurate estimate.
blockParameter
(optional): A string representing the block number (in hexadecimal) or one of the strings "latest", "earliest", or "pending". This parameter determines the state against which the transaction is estimated.
Response
result
: The estimated amount of gas required to execute the transaction, returned as a hexadecimal number.
Use case
Estimating gas is crucial for interacting with the Ronin network as it helps users and applications determine the appropriate gas limit to specify for a transaction. This prevents transactions from running out of gas (and thus failing) or from overestimating and locking unnecessary amounts of ether for gas.
Try the eth_estimateGas
RPC method yourself
eth_estimateGas
RPC method yourself