estimateGas - Ethereum Classic

Returns the estimated gas a call or transaction would consume at a chosen block, the GraphQL equivalent of eth_estimateGas. Accessed within a block selection.

Schema

graphqlblock { estimateGas(data: CallData!): Long! }

Arguments

ArgumentTypeDescription
data.toAddressTarget address
data.dataBytesABI-encoded call data
data.fromAddressOptional caller address
data.valueBigIntOptional value in wei

Query

graphqlquery {
  block {
    estimateGas(data: {to: "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045", value: "1000000000000000000"})
  }
}

Example

bashexport ETC_GRAPHQL=https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/

curl --location --request POST "${ETC_GRAPHQL}graphql" \
--header 'Content-Type: application/json' \
--data-raw '{"query": "query { block { estimateGas(data: {to: \"0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045\", value: \"1000000000000000000\"}) } }"}'

Response

json{
    "data": {
        "block": {
            "estimateGas": 21000
        }
    }
}

Response Fields

FieldTypeDescription
estimateGasLongEstimated gas units for the call

Use Cases

  • Gas Sizing: Set a gas limit before sending
  • Fee Preview: Multiply by gasPrice for a fee estimate
  • Validation: Detect calls that would fail

Error Handling

ErrorMessageDescription
errors[]gas estimation failedThe call reverted during estimation
403 / RBAC: access deniedAccess deniedThe GetBlock access token is missing or incorrect