eth_estimateGas - Celo
eth_estimateGas. Estimates the gas required to execute a transaction
eth_getEstimateGas - celo [Value: 60CU]
Calculates the exact amount of gas required, optimizing transaction efficiency and preventing out-of-gas errors
Use cases
- Estimate the gas needed for a transaction
- Plan transactions to use optimal gas amounts
- Optimize gas usage
Constraints
- Requires valid addresses
- Estimates vary with network conditions
- Calculation depends on the node's processing speed
Unlock Access to 50+ chains
Boost your app's speed and reliability with dRPC - get your access API key
Language
Request
Examples
curl --request POST \
--url https://celo.drpc.org \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--data '
{
"id": 1,
"jsonrpc": "2.0",
"method": "eth_estimateGas",
"params": [
{
"to": "0xd46e8dd67c5d32be8058bb8eb970870f07244567",
"gas": "0x0",
"gasPrice": "0x9184e72a000",
"value": "0x0",
"data": "0x"
},
{
"to": "0xd46e8dd67c5d32be8058bb8eb970870f07244567",
"gas": "0x0",
"gasPrice": "0x9184e72a000",
"value": "0x0",
"data": "0x"
}
]
}
'
Response
200
{
"jsonrpc": "2.0",
"id": 1,
"result": "0xb1770efb14906e509893b6190359658208ae64d0c56e22f748a1b0869885559e"
}
Request params
idinteger
jsonrpcstring
methodstring
array
transactionobject
array
fromstring
(optional) The sender's address.
tostring
The recipient's address.
gasinteger
(optional) The gas limit for the transaction.
gasPricestring
(optional) The gas price in wei.
valueinteger
(optional) The value sent in wei.
datastring
(optional) The data sent with the transaction.
objectobject
A state override set, mapping addresses to their respective states. Each address maps to an object with:
array
balancestring
Simulated balance assigned to the account prior to executing the call.
noncestring
Simulated nonce assigned to the account before the call.
codeinteger
Simulated EVM bytecode inserted into the account.
stateDiffstring
Simulated key-value pairs to override the account's storage slots.
Response
200
The estimated gas amount needed for the transaction, returned as a hexadecimal string.Response params
object
idinteger
jsonrpcstring
resultstring