---
title: "eth_estimateGas"
description: "Estimates the gas required to execute a transaction on Base; use pending on Flashblocks to estimate against pre-confirmed state."
source: https://basehub.org/api-reference/eth/eth_estimategas/
---
import { Aside, Tabs, TabItem } from '@astrojs/starlight/components';

Returns an estimate of how much gas a transaction would require. The reported value may exceed what the transaction actually consumes when executed.

<Aside type="tip">
**Flashblocks:** call `https://mainnet-preconf.base.org` with `"pending"` to estimate gas against the current pre-confirmed state — useful when a new transaction depends on one that has just been pre-confirmed.
</Aside>

## Parameters

### `transaction` (object, required)

The transaction object to estimate gas for.

| Field | Type | Description |
| --- | --- | --- |
| `from` | string | Address the transaction is sent from. Optional. |
| `to` | string | Address the transaction is sent to. Optional for contract deployments. |
| `gas` | string | Gas limit. Optional; a high default is used if omitted. |
| `gasPrice` | string | Gas price in wei for legacy transactions. Optional. |
| `maxFeePerGas` | string | EIP-1559 maximum total fee per gas. Optional. |
| `maxPriorityFeePerGas` | string | EIP-1559 maximum priority fee per gas. Optional. |
| `value` | string | Value to transfer in wei. Optional. |
| `data` | string | ABI-encoded call data. Optional. |

### `block` (string, optional)

Block to estimate against. Defaults to `"latest"`. Pass `"pending"` on a Flashblocks endpoint to estimate against pre-confirmed state.

## Returns

| Field | Type | Description |
| --- | --- | --- |
| `result` | string | The estimated gas amount as a hexadecimal integer. |

## Error codes

| Code | Message | Description |
| --- | --- | --- |
| `-32000` | execution reverted | The transaction would revert. The error `data` field may contain a revert reason. |

## Example

### Request

<Tabs>
  <TabItem label="Standard">

```bash
curl https://mainnet.base.org \
  -X POST \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "method": "eth_estimateGas",
    "params": [{
      "from": "0xd3CdA913deB6f4967b2Ef66ae97DE114a83bcc01",
      "to": "0x4200000000000000000000000000000000000006",
      "value": "0x2c68af0bb14000"
    }],
    "id": 1
  }'
```

  </TabItem>
  <TabItem label="Flashblocks (pending state)">

```bash
curl https://mainnet-preconf.base.org \
  -X POST \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "method": "eth_estimateGas",
    "params": [{
      "from": "0xd3CdA913deB6f4967b2Ef66ae97DE114a83bcc01",
      "to": "0x4200000000000000000000000000000000000006",
      "value": "0x2c68af0bb14000"
    }, "pending"],
    "id": 1
  }'
```

  </TabItem>
</Tabs>

### Response

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