eth_estimateGas
Generates and returns an estimate of how much gas is necessary to allow the transaction to complete. The transaction will not be added to the blockchain.

Parameters

See eth_call parameters, expect that all properties are optional. If no gas limit is specified geth uses the block gas limit from the pending block as an upper bound. As a result the returned estimate might not be enough to executed the call/transaction when the amount of gas is higher than the pending block gas limit.

Returns

QUANTITY(hex string) - the amount of gas used.

Example

Request

1
curl https://api.blockvision.org/v1/<api key> \
2
-X POST \
3
-H "Content-Type: application/json" \
4
-d '{
5
"jsonrpc": "2.0",
6
"method": "eth_estimateGas",
7
"params": [
8
{
9
"from": "0x3d597789ea16054a084ac84ce87f50df9198f415",
10
"to": "0x3d597789ea16054a084ac84ce87f50df9198f415",
11
"value": "0x1"
12
}
13
],
14
"id": 1
15
}'
Copied!

Result

1
{
2
"jsonrpc": "2.0",
3
"id": 1,
4
"result": "0x5208"
5
}
Copied!