eth_estimateGas
https://triport.io/rpc/bscEstimate gas for an EVM call.
eth_estimateGas simulates an EVM call against current BNB Smart Chain state and returns the estimated gas requirement as a hex quantity.
Use the estimate to prepare a transaction's gas limit. The call object can supply sender, destination, value, calldata, fee fields, gas, and an access list; it must contain at least one of to, data, or input according to the OpenRPC schema.
Unlike eth_call, this method returns a gas amount rather than contract output. It does not broadcast or mutate state, and raw transaction submission is not exposed for BSC. Execution can still fail for malformed calldata or a reverting call.
Parameters
JSON-RPC params is a positional array: [call].
callobjectrequiredaccessListarray<object>optionaladdress and storageKeys.datastring (hex data)optionalinput.fromstring (address)optionalgasstring (hex quantity)optionalgasPricestring (hex quantity)optionalinputstring (hex data)optionaldata.maxFeePerGasstring (hex quantity)optionalmaxPriorityFeePerGasstring (hex quantity)optionaltostring (address)optionalvaluestring (hex quantity)optionalaccessList[]objectaddressstring (address)requiredstorageKeysarray<string>requiredResponse
The response below is the checked fixture for this method; it is reproduced without changing its fields or values.
resultstring (hex quantity)Errors
Errors use the standard JSON-RPC error envelope. See BSC errors for network-specific classification and the linked shared reference.
| Code | Meaning | When it happens |
|---|---|---|
-32602 | Invalid params | A required positional parameter is missing or a value does not match the OpenRPC schema. |
401 | Unauthorized | The x-token API key is missing or invalid. |
429 | Rate limited | The request exceeds the configured category RPS for the caller's tier. |
Examples
JavaScript (fetch)
const response = await fetch("https://triport.io/rpc/bsc", {
method: "POST",
headers: {
"x-token": process.env.TRIPORT_API_KEY,
"Content-Type": "application/json",
},
body: JSON.stringify({
"jsonrpc": "2.0",
"id": 1,
"method": "eth_estimateGas",
"params": [
{
"to": "0x0000000000000000000000000000000000000000",
"value": "0x0"
}
]
}),
});
const payload = await response.json();
console.log(payload.result);Notes
- An estimate is a simulation result, not a guarantee that a later transaction will use exactly the same gas.
- The BSC categories use configured defaults of 15 / 20 / 100 / 250 RPS; they are marked unmeasured in the tier matrix.
- Related methods:
eth_call,eth_gasPrice,eth_feeHistory.