> For the complete documentation index, see [llms.txt](https://sodex.com/documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://sodex.com/documentation/for-developers/api-reference/json-rpc/eth-estimategas.md).

# eth\_estimateGas

POST `https://mainnet.valuechain.xyz`

Estimates the gas required to execute a transaction.

An estimate reflects current state. The later transaction can still fail. See [Gas & Fees](/documentation/for-developers/developers/valuechain-evm/gas-and-fees.md).

## Parameters

| Name          | Type            | Required | Description                                                                                                                                                                                              |
| ------------- | --------------- | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `transaction` | object          | Yes      | Same `from`, `to`, `value`, and `data` that will be submitted.                                                                                                                                           |
| `block`       | quantity or tag | No       | Hex block number, or `earliest`, `latest`, `safe`, `finalized`, or `pending`. See [block tags](/documentation/for-developers/developers/valuechain-evm/differences-from-ethereum.md#consensus-finality). |

## Result

**Gas** (quantity): Hex-encoded gas units, not an amount of SOSO.

## Example

### Response

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": "0x5208"
}
```

## Code examples

### cURL

```bash
curl --request POST \
  --url https://mainnet.valuechain.xyz \
  --header 'Content-Type: application/json' \
  --data '{"jsonrpc": "2.0", "id": 1, "method": "eth_estimateGas", "params": [{"from": "0x7779ef1c26a0437f9fbd06e21f238da8b8336cf2", "to": "0x7779ef1c26a0437f9fbd06e21f238da8b8336cf2", "value": "0x0"}]}'
```

### JavaScript

```javascript
const options = {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({"jsonrpc": "2.0", "id": 1, "method": "eth_estimateGas", "params": [{"from": "0x7779ef1c26a0437f9fbd06e21f238da8b8336cf2", "to": "0x7779ef1c26a0437f9fbd06e21f238da8b8336cf2", "value": "0x0"}]})
};

fetch('https://mainnet.valuechain.xyz', options)
  .then((res) => res.json())
  .then((res) => console.log(res))
  .catch((err) => console.error(err));
```

### Python

```python
import requests

url = "https://mainnet.valuechain.xyz"
payload = {
  "jsonrpc": "2.0",
  "id": 1,
  "method": "eth_estimateGas",
  "params": [
    {
      "from": "0x7779ef1c26a0437f9fbd06e21f238da8b8336cf2",
      "to": "0x7779ef1c26a0437f9fbd06e21f238da8b8336cf2",
      "value": "0x0"
    }
  ]
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)
```
