githubEdit

eth_estimateGas - Celo

Example code for the eth_estimateGas JSON-RPC method. Complete guide on how to use eth_estimateGas JSON-RPC in GetBlock Web3 documentation.

This method generates an estimate of how much gas is necessary to complete a transaction on the Celo network. This is essential for setting appropriate gas limits. Celo's low gas costs make accurate estimation important for optimal fee management.

circle-info

Use eth_estimateGas to calculate gas requirements before sending transactions to avoid out-of-gas errors and set appropriate gas limits.

Parameters

Parameter
Type
Required
Description

transaction

object

Yes

Transaction call object

blockNumber

string

No

Block number in hex, or "latest" (default)

Request Example

cURL
curl -X POST https://go.getblock.io/<ACCESS-TOKEN>/ \
-H "Content-Type: application/json" \
-d '{
  "jsonrpc": "2.0",
  "id": "getblock.io",
  "method": "eth_estimateGas",
  "params": [
    {
      "from": "0x742d35Cc6634C0532925a3b844Bc9e7595f8bB45",
      "to": "0x8626f6940E2eb28930eFb4CeF49B2d1F2C9C1199",
      "value": "0xde0b6b3a7640000"
    }
  ]
}'

Response Example

Response Definition

Field
Type
Description

result

string

Estimated gas amount in hexadecimal

Use Cases

  • Calculate transaction costs before sending

  • Set appropriate gas limits

  • Budget gas for complex contract interactions

  • Optimize transaction parameters

  • Prevent out-of-gas errors

Error Handling

Error Code
Description

-32602

Invalid params - malformed transaction object

-32603

Internal error - execution reverted

-32000

Execution error - insufficient funds or revert

SDK Integration

Last updated

Was this helpful?