Docs
Supported ChainsImmutableJSON-RPC APITransaction Methods

eth_estimateGas - Immutable RPC Method

Estimate gas required for transactions on Immutable. Essential for optimizing transaction costs for Web3 gaming (Gods Unchained, RavenQuest), gaming NFTs with enforced royalties, and cross-chain game assets.

Estimates the gas necessary to execute a transaction on Immutable.

Why Immutable? Build on the gaming-optimized zkEVM with 660+ games, 5.5M+ Passport signups, and $40M TVL with first EVM chain with enforceable royalties, Polygon zkEVM technology, $2B+ ecosystem funding, and Agglayer cross-chain liquidity.

Use Cases

The eth_estimateGas method is essential for:

  • Transaction preparation - Set appropriate gas limits
  • Cost estimation - Calculate transaction costs before sending
  • Error detection - Identify reverts before spending gas
  • DeFi operations - Estimate costs for Web3 gaming (Gods Unchained, RavenQuest), gaming NFTs with enforced royalties, and cross-chain game assets

Request Parameters

Request
fromDATA

Sender address

toDATA

Recipient address

gasQUANTITY

Gas limit

gasPriceQUANTITY

Gas price

valueQUANTITY

Value in wei

dataDATA

Transaction data

Response Body

Response
resultQUANTITY

Estimated gas amount in hexadecimal

Code Examples

Bash
curl -X POST https://api-immutable-zkevm-mainnet.n.dwellir.com/YOUR_API_KEY \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "method": "eth_estimateGas",
    "params": [{
      "from": "0x3A0C2Ba54D6CBd3121f01b96DFd20e99D1696c9D",
      "to": "0x3A0C2Ba54D6CBd3121f01b96DFd20e99D1696c9D",
      "value": "0x1"
    }],
    "id": 1
  }'
JavaScript
import { JsonRpcProvider, parseEther } from 'ethers';

const provider = new JsonRpcProvider('https://api-immutable-zkevm-mainnet.n.dwellir.com/YOUR_API_KEY');

// Estimate simple transfer
async function estimateTransfer(to, value) {
  const gasEstimate = await provider.estimateGas({
    to: to,
    value: parseEther(value)
  });

  console.log('Estimated gas:', gasEstimate.toString());
  return gasEstimate;
}

// Estimate contract call
async function estimateContractCall(contract, method, args) {
  const gasEstimate = await contract[method].estimateGas(...args);
  console.log('Estimated gas:', gasEstimate.toString());

  // Add 20% buffer for safety
  return gasEstimate * 120n / 100n;
}
Python
from web3 import Web3

w3 = Web3(Web3.HTTPProvider('https://api-immutable-zkevm-mainnet.n.dwellir.com/YOUR_API_KEY'))

def estimate_transfer(to, value_in_ether):
    gas_estimate = w3.eth.estimate_gas({
        'to': to,
        'value': w3.to_wei(value_in_ether, 'ether')
    })

    print(f'Estimated gas: {gas_estimate}')
    return gas_estimate

def estimate_contract_call(contract, method, args):
    func = getattr(contract.functions, method)
    gas_estimate = func(*args).estimate_gas()

    # Add 20% buffer
    return int(gas_estimate * 1.2)

# Estimate simple transfer
gas = estimate_transfer('0x3A0C2Ba54D6CBd3121f01b96DFd20e99D1696c9D', 0.1)
Go
package main

import (
    "context"
    "fmt"
    "log"
    "math/big"

    "github.com/ethereum/go-ethereum"
    "github.com/ethereum/go-ethereum/common"
    "github.com/ethereum/go-ethereum/ethclient"
)

func main() {
    client, err := ethclient.Dial("https://api-immutable-zkevm-mainnet.n.dwellir.com/YOUR_API_KEY")
    if err != nil {
        log.Fatal(err)
    }

    toAddress := common.HexToAddress("0x3A0C2Ba54D6CBd3121f01b96DFd20e99D1696c9D")
    msg := ethereum.CallMsg{
        To:    &toAddress,
        Value: big.NewInt(1000000000000000000),
    }

    gasLimit, err := client.EstimateGas(context.Background(), msg)
    if err != nil {
        log.Fatal(err)
    }

    fmt.Printf("Estimated gas: %d\n", gasLimit)
}

Error Handling

Error CodeMessageDescription
-32000Execution revertedTransaction would fail
-32602Invalid paramsInvalid transaction parameters

Tip: If estimation fails, the transaction would likely revert if sent.