ethEstimateGas

suspend fun ethEstimateGas(chainId: String, transaction: EthTransactionParam): Any

Estimates the amount of gas required to execute a transaction.

This function interacts with the Ethereum JSON-RPC API to estimate the gas needed for a given transaction. It uses the eth_estimateGas method.

Return

Any The estimated gas amount object

Parameters

chainId

The ID of the chain on which to perform the gas estimation. This is used to identify the correct network endpoint.

transaction

An EthTransactionParam object representing the transaction for which the gas estimation is needed. This object typically contains details like from, to, value, data, etc.

See also

Throws

If there is an error during the request to the JSON-RPC provider. This could be due to network issues, invalid parameters, or an error returned by the Ethereum node.