Request
curl https://eth.l0vdinfra.com/YOUR_KEY \
-X POST \
-H "Content-Type: application/json" \
--data '{"jsonrpc":"2.0","id":1,"method":"eth_estimateGas","params":[{"from":"0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045","to":"0x000000000000000000000000000000000000dEaD","value":"0x1"}]}'
{
"jsonrpc": "2.0",
"id": 1,
"result": "0x5208"
}
Params and your endpoint
Parameters
transactionobjectrequired- Transaction object.
blockstringoptional- Block to estimate against. Defaults to "latest".
Returns
string Estimated gas, hex.
When to use it
Estimate how much gas a transaction would use before you sign and send it.
How to read the result
Hex gas units: 0x5208 = 21,000, the cost of a plain native transfer.
Tips
- Add a safety margin (10 to 20 percent) when you set the gas limit; state can change between estimate and inclusion.
- If the call would revert, you get an error with the revert data instead of a number.
Related methods