π Estimate gas for transaction
Code samples
POST /api/v1/eth/account/estimate-gas
Estimates the gas required for a transaction using eth_estimateGas.
Body parameter
{
"transaction": {
"from": "string",
"to": "string",
"gas": "string",
"gasPrice": "string",
"maxFeePerGas": "string",
"maxPriorityFeePerGas": "string",
"value": "string",
"data": "string",
"nonce": "string"
},
"block": "latest"
}
π οΈ Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
| body | body | object | true | none |
| Β» transaction | body | EthTransactionRequest | 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"
}
π Responses
| Status | Meaning | Description | Schema |
|---|---|---|---|
| 200 | OK | Estimated gas | Inline |
| 422 | Unprocessable Entity | Invalid request body (missing or invalid transaction) | None |
| 500 | Internal Server Error | Could not connect to ETH node | None |
π Response Schema
Status Code 200
| Name | Type | Required | Restrictions | Description |
|---|---|---|---|---|
| Β» gas | string | false | none | Gas estimate as hex QUANTITY from eth_estimateGas. |