> ## Documentation Index
> Fetch the complete documentation index at: https://docs.chainstack.com/llms.txt
> Use this file to discover all available pages before exploring further.

<AgentInstructions>

## Submitting Feedback

If you encounter incorrect, outdated, or confusing documentation on this page, submit feedback:

POST https://docs.chainstack.com/feedback

```json
{
  "path": "/reference/cronos-estimategas",
  "feedback": "Description of the issue"
}
```

Only submit feedback when you have something specific and actionable to report.

</AgentInstructions>

# eth_estimateGas | Cronos

Cronos API method that returns an estimate of gas units needed for a given transaction.

It estimates the maximum amount of gas units required to complete the transaction based on the network's current state and the transaction's parameters. A client or wallet can use this estimate to determine the appropriate amount of gas to include in a transaction to ensure the network processes it.

<Check>
  **Get your own node endpoint today**

  [Start for free](https://console.chainstack.com/) and get your app to production levels immediately. No credit card required.

  You can sign up with your GitHub, X, Google, or Microsoft account.
</Check>

## Parameters

* `object` — the transaction call object, same as in `eth_call`; the `from` field is optional, and the `nonce` field is omitted:

  * `from` — (optional) the address string used to send the transaction.
  * `to` — the string of the address to which the transaction is directed, a wallet, or a smart contract.
  * `gas` — (optional) the maximum amount of gas that can be used by the transaction.
  * `gasprice` — (optional) the amount of gas price the sender is willing to pay for each gas unit in [Wei](https://ethereum.org/en/developers/docs/intro-to-ether/#denominations).
  * `value` — (optional) the value sent with this transaction, encoded as hexadecimal.
  * `data` — (optional) additional data to be sent with the call, usually used to invoke functions from smart contracts as a string of the hash of the method signature and encoded parameters; see the [Ethereum Contract ABI](https://solidity.readthedocs.io/en/latest/abi-spec.html).
* `quantity or tag` — the integer of a block encoded as hexadecimal or the string with:

  * `latest` — the most recent block in the blockchain and the current state of the blockchain at the most recent block. A chain reorganization is to be expected.
  * `safe` — the block that received justification from the beacon chain. Although this block could be involved in a chain reorganization, it would necessitate either a coordinated attack by the majority of validators or an instance of severe propagation latency.
  * `finalized` — the block accepted as canonical by more than 2/3 of the validators. A chain reorganization is extremely unlikely, and it would require at least 1/3 of the staked amount to be burned.
  * `earliest` — the earliest available or genesis block.
  * `pending` — the pending state and transactions block. The current state of transactions that have been broadcast to the network but have not yet been included in a block.

<Note>
  See the [default block parameter](https://ethereum.org/en/developers/docs/apis/json-rpc/#default-block) and [How The Merge Impacts Ethereum’s Application Layer](https://blog.ethereum.org/2021/11/29/how-the-merge-impacts-app-layer).
</Note>

## Response

* `quantity` — the estimated amount of gas units needed, represented as a hexadecimal string.

## `eth_estimateGas` code examples

<CodeGroup>
  ```javascript web3.js theme={"system"}
  const { Web3 } = require("web3");
  const NODE_URL = "CHAINSTACK_NODE_URL";
  const web3 = new Web3(NODE_URL);

  async function estimateGas() {
  	// The transaction to estimate is a simple transfer in this example.
    const transactionObj = {
      from: "0x25aA97464F38a1506a16160bbc03cfC6DD863da3",
      to: "0xbe0eb53f46cd790cd13851d5eff43d12404d33e8",
    }

    const gasUnits = await web3.eth.estimateGas(transactionObj);
    console.log(`Estimated gas units required: ${gasUnits}`);
  }

  estimateGas()
  ```

  ```javascript ethers.js theme={"system"}
  const ethers = require('ethers');
  const NODE_URL = "CHAINSTACK_NODE_URL";
  const provider = new ethers.JsonRpcProvider(NODE_URL);

  const estimateGas = async () => {
      // The transaction to estimate is a simple transfer in this example.
      const transactionObj = {
          from: "0x25aA97464F38a1506a16160bbc03cfC6DD863da3",
          to: "0xbe0eb53f46cd790cd13851d5eff43d12404d33e8",
      }

      const gasUnits = await provider.estimateGas(transactionObj);
      console.log(`Estimated gas units required: ${gasUnits}`);
  };

  estimateGas();
  ```

  ```python web3.py theme={"system"}
  from web3 import Web3  
  node_url = "CHAINSTACK_NODE_URL"

  web3 = Web3(Web3.HTTPProvider(node_url)) 
  print(web3.eth.estimate_gas({"from":"0x25aA97464F38a1506a16160bbc03cfC6DD863da3","to":"0xbe0eb53f46cd790cd13851d5eff43d12404d33e8"}, "latest" ))  
  ```
</CodeGroup>

## Use case

A practical use case for `eth_estimateGas` is to calculate the gas cost required for a transaction that transfers a value from one Ethereum address (`fromAddress`) to another (`toAddress`). The gas cost is an important factor in transactions, as it determines the amount of fees that need to be paid by the sender to the network for processing the transaction.


## OpenAPI

````yaml /openapi/cronos_node_api/eth_estimateGas.json POST /b9b0fb92029d58b396139a9e89cf479b
openapi: 3.0.0
info:
  title: Cronos Node API
  version: 1.0.0
  description: This is an API for interacting with a Cronos node.
servers:
  - url: https://nd-907-114-772.p2pify.com
security: []
paths:
  /b9b0fb92029d58b396139a9e89cf479b:
    post:
      tags:
        - upload
      summary: eth_estimateGas
      operationId: estimateGas
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                id:
                  type: integer
                  default: 1
                jsonrpc:
                  type: string
                  default: '2.0'
                method:
                  type: string
                  default: eth_estimateGas
                params:
                  type: array
                  items:
                    type: object
                    properties:
                      from:
                        type: string
                        format: byte
                      to:
                        type: string
                        format: byte
                  default:
                    - from: '0x25aA97464F38a1506a16160bbc03cfC6DD863da3'
                      to: '0x2A39319dB98A3982F7C363380b72C66Ab1FFe228'
                    - latest
      responses:
        '200':
          description: The estimated gas amount
          content:
            application/json:
              schema:
                type: object
                properties:
                  jsonrpc:
                    type: string
                  id:
                    type: integer
                  result:
                    type: string
                    format: byte

````