eth_estimateGas
Calculates the exact amount of gas required, optimizing transaction efficiency and preventing out-of-gas errors
Request
Examples
curl --request POST \
--url https://rpc.xone.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 OK
{
"jsonrpc": "2.0",
"id": 1,
"result": "0xb1770efb14906e509893b6190359658208ae64d0c56e22f748a1b0869885559e"
}Request params
| Name | Type | Description |
|---|---|---|
| id | integer | Request identifier |
| jsonrpc | string | JSON-RPC version |
| method | string | API method name |
| Parameters | array | |
| transaction | object | |
| object | object | A state override set, mapping addresses to their respective states. Each address maps to an object with: |
Response
200
The estimated gas amount needed for the transaction, returned as a hexadecimal string.| Name | Type | Description |
|---|---|---|
| Parameters | object | |
| id | integer | |
| jsonrpc | string | |
| result | string |