๐Ÿ”ต Base
eth_estimateGas

๐Ÿ”ต Base Chain RPC Methods & API Documentation

eth_estimateGas RPC Method

The eth_estimateGas method is used to estimate the amount of gas a transaction would consume if executed on the Base chain (an Ethereum L2 built by Coinbase). This estimation simulates the transaction and does not broadcast it to the blockchain.

โš ๏ธ eth_estimateGas verifies that the sender (from) address has enough ETH to cover gas costs, even though the call itself doesn't consume gas.


Parameters

1. Transaction Call Object (required)

  • from (optional) โ€” Address sending the transaction.
  • to (required) โ€” Address the transaction is sent to.
  • gas (optional) โ€” Gas limit provided for the transaction execution.
  • gasPrice (optional) โ€” Price per unit of gas (in hexadecimal Wei).
  • maxPriorityFeePerGas (optional) โ€” Max fee per gas above the base fee.
  • maxFeePerGas (optional) โ€” Max total fee per gas (base + priority), in Wei.
  • value (optional) โ€” Amount of ETH to transfer (in hexadecimal Wei).
  • data (optional) โ€” ABI-encoded function call. More info: Ethereum ABI Spec (opens in a new tab)

๐Ÿ’Ž maxPriorityFeePerGas and maxFeePerGas (EIP-1559) must not be used with gasPrice in the same transaction.

๐Ÿ’Ž You can convert Wei to ETH using eth-converter.com (opens in a new tab). ETH on Base uses 18 decimals.


Returns

Returns the estimated gas (in hexadecimal) that the transaction would consume if sent.


Request Format

POST https://base-mainnet.chainnodes.org/YOUR-API-KEY
 

Example

๐Ÿ’ก

Confusing? Ask blockchain developers in Chainnodes Telegram Chat (opens in a new tab)

curl https://base-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
  }'
 

Sample Response

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": "0xb411"
}

๐Ÿ’ก Confusing?

Ask our experienced blockchain developers in Telegram

JSON-RPC API Documentation by CHAINNODES is based on Erigon node client. Contact us if you are interested in specific methods that are only available on geth, besu, Nethermind or reth