π Estimate gas for transaction
Code samples
POST /api/v1/eth/account/estimate-gas
curl -X POST 'https://settla.net/api/v1/eth/account/estimate-gas' \
-H 'X-API-Key: $SETTLA_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"transaction": {
"to": "0x28c6c06298d514db089934071355e5743bf21d60",
"value": "0x1"
}
}'
Estimates the gas required for a transaction using eth_estimateGas.
Body parameter
{
"transaction": {
"to": "0x28c6c06298d514db089934071355e5743bf21d60",
"value": "0x1"
}
}
π οΈ Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
| body | body | object | true | none |
| Β» transaction | body | object | true | Ethereum transaction parameters used with eth_call, eth_estimateGas and eth_sendTransaction. |
| »» from | body | string | false | Sender address. |
| »» to | body | string¦null | false | Recipient address, or null for contract creation. |
| »» gas | body | string | false | Gas limit as hex QUANTITY. |
| »» gasPrice | body | string | false | Legacy gas price as hex QUANTITY. |
| »» maxFeePerGas | body | string | false | EIP-1559 max fee per gas as hex QUANTITY. |
| »» maxPriorityFeePerGas | body | string | false | EIP-1559 priority fee per gas as hex QUANTITY. |
| »» value | body | string | false | Amount of wei to send as hex QUANTITY. |
| »» data | body | string | false | Call data or contract deployment bytecode. |
| »» nonce | body | string | false | Nonce as hex QUANTITY. |
| Β» block | body | string | false | Optional block number or tag; defaults to latest. |
Example responses
200 Response
{
"gas": "0x5208"
}
422 Response
{
"error": "Field \"transaction\" is required and must be an object"
}
500 Response
{
"error": "Could not connect to ETH node."
}
π Responses
| Status | Meaning | Description | Schema |
|---|---|---|---|
| 200 | OK | Estimated gas. 0x5208 (21000) is the floor for a plain ETH transfer; a contract call costs more. | Inline |
| 422 | Unprocessable Entity | Invalid request body (missing or invalid transaction) | Inline |
| 500 | Internal Server Error | Node unreachable β or the node refused to estimate, for example when from cannot cover value plus fees. The API collapses both cases into the same message, so check the sender's balance before assuming the node is down. | Inline |
π Response Schema
Status Code 200
| Name | Type | Required | Restrictions | Description |
|---|---|---|---|---|
| Β» gas | string | false | none | Gas estimate as hex QUANTITY from eth_estimateGas. |
Status Code 422
| Name | Type | Required | Restrictions | Description |
|---|---|---|---|---|
| Β» error | string | false | none | none |
Status Code 500
| Name | Type | Required | Restrictions | Description |
|---|---|---|---|---|
| Β» error | string | false | none | none |