> ## 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.

# eth_call | Cronos

> Cronos API method that enables instant execution of a new message call without requiring the creation of a transaction on the blockchain.

Cronos API method that enables instant execution of a new message call without requiring the creation of a transaction on the blockchain. This can be useful for testing and debugging by simulating transfers or smart contract transactions and retrieving data from the blockchain.

<Note>
  When called against a block older than the latest \~128 blocks, this method is treated as an archive request (2 RUs instead of 1 RU). See [request units](/docs/request-units#evm-methods-affected-by-block-age).
</Note>

<Note>
  **Disclaimer**

  The interactive example in this page uses `eth_call` to call the `decimals()` method from the [WCRO Token smart contract on Cronos Chain](https://cronoscan.com/token/0x5c7f8a570d578ed84e63fdfa7b1ee72deae1ae23#readContract).

  You can use the [Chainstack EVM Knife](https://web3tools.chainstacklabs.com/generate-solidity-functions-signature) to generate the function signatures from smart contracts.
</Note>

## Parameters

* `object` — the transaction call object:
  * `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 severe propagation latency.
  * `finalized` —the block accepted as canonical by more than 2/3 of the validators. A chain reorganization is extremely unlikely, requiring burning at least 1/3 of the staked amount.
  * `earliest` — the earliest available or genesis block.
  * `pending` —the pending state and transactions block. This is 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).
</Note>

### State override (optional)

`eth_call` accepts an optional third parameter: a state override set that changes account state for this call only. Nothing is written to the chain. The set is an object keyed by account address, and each address can override:

* `balance` — the account balance in wei, hex-encoded
* `nonce` — the account nonce, hex-encoded
* `code` — the bytecode to run at the address
* `state` — storage slot values that replace the account's entire storage
* `stateDiff` — storage slot values to change, keeping the rest of the storage

This example puts bytecode that returns `42` at an unused address, then calls that address:

```bash theme={"system"}
curl --request POST \
  --url CHAINSTACK_NODE_URL \
  --header 'Content-Type: application/json' \
  --data '{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "eth_call",
    "params": [
      { "to": "0x00000000000000000000000000000000c0ffee42", "data": "0x" },
      "latest",
      { "0x00000000000000000000000000000000c0ffee42": { "code": "0x602a60005260206000f3" } }
    ]
  }'
```

```json theme={"system"}
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": "0x000000000000000000000000000000000000000000000000000000000000002a"
}
```

## Response

* `data` — the result of executing the specified call on the Ethereum Virtual Machine (EVM), encoded as a hexadecimal string.

## `eth_call` code examples

The following code snippets clearly demonstrate how to simulate a standard ether transfer between two accounts. Note that when using `eth_call` to simulate a transfer or a smart contract transaction, the sender account must have a sufficient balance to cover the associated gas fee.

<CodeGroup>
  ```javascript ethers.js theme={"system"}
  const ethers = require('ethers');
  const NODE_URL = "CHAINSTACK_NODE_URL";
  const provider = new ethers.JsonRpcProvider(NODE_URL);

  const simulateTransfer = async () => {
    try {    
      // Define the accounts to transfer between
      const fromAddress = "0x71F0cDb17454ad7EeB7e26242292fe0E0189645a";
      const toAddress = "0x19e7e376e7c213b7e7e7e46cc70a5dd086daff2a";

      // Define the value to transfer
      const value = ethers.parseEther("1");

      // Build transaction object
      const transactionObject = {
          from: fromAddress,
          to: toAddress,
          gasLimit: ethers.toQuantity(21000),
          value: value
      }

      // Use eth_call to simulate the transfer on the latest block
      const result = await provider.call(transactionObject);
      console.log(`Result: ${result}`);

    } catch (error) {
      console.error(`Error: ${error.message}`);

    }
  }

  simulateTransfer();
  ```

  ```python web3.py theme={"system"}
  from web3 import Web3  
  node_url = "CHAINSTACK_NODE_URL"

  web3 = Web3(Web3.HTTPProvider(node_url)) 

  # Define the accounts to transfer between
  from_address = web3.to_checksum_address('0x71F0cDb17454ad7EeB7e26242292fe0E0189645a')
  to_address = web3.to_checksum_address('0x19e7e376e7c213b7e7e7e46cc70a5dd086daff2a')

  # Define the value to transfer (in Ether)
  value = web3.to_wei(1, 'ether')

  # Build the transaction object
  transaction = {
      'from': from_address,
      'to': to_address,
      'gas': 21000,  # 21000 is the standard for a regular transfer
      'value': value,
      'data': '',
  }

  # Use eth_call to simulate the transfer
  result = web3.eth.call(transaction, 'latest')
  print(result)
  ```
</CodeGroup>

Executing this code will produce a return value of `0x`, indicating a successful transaction. This implies that the transaction will be executed without errors when the code is used to send the transaction.

## Use case

A common use case for `eth_call` is calling smart contract functions. For example, interact with an ERC-20 token smart contract deployed on the Cronos network and retrieve the balance of a specific account.


## OpenAPI

````yaml openapi/cronos_node_api/eth_call.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:
        - transactions info
      summary: eth_call
      operationId: ethCall
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                jsonrpc:
                  type: string
                  default: '2.0'
                method:
                  type: string
                  default: eth_call
                id:
                  type: integer
                  default: 1
                params:
                  type: array
                  items:
                    type: object
                    title: Call object
                    properties:
                      to:
                        type: string
                        description: The address of the contract to call.
                      data:
                        type: string
                        description: The data to send with the call.
                  default:
                    - to: '0x5C7F8A570d578ED84E63fdFA7b1eE72dEae1AE23'
                      data: '0x313ce567'
                    - latest
      responses:
        '200':
          description: The result of the call.
          content:
            application/json:
              schema:
                type: object
                properties:
                  jsonrpc:
                    type: string
                  id:
                    type: integer
                  result:
                    type: string

````