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

> The example is a call to the poolinfo of the Gamma MasterChef contract. eth_call JSON-RPC method available on the Optimism blockchain via Chainstack.

The example is a call to the `poolinfo` of the [Gamma MasterChef contract](https://optimistic.etherscan.io/address/0xc7846d1bc4d8bcf7c45a7c998b77ce9b3c904365#readContract).

Optimism API method `eth_call` executes a smart contract function call directly and returns the result without requiring a transaction or changing the state on the blockchain. This method is widely used for reading data from smart contracts.

## Parameters

* `transactionObject` — an object containing transaction parameters, including:
  * `to` — the address of the contract to call.
  * `data` — the call data, typically including the function signature and parameters.
* `blockParameter` — a string specifying the block number (in hexadecimal) or one of the strings `"earliest"`, `"latest"`, or `"pending"`, indicating the blockchain state to use for the call. Most commonly, `"latest"` is used.

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

* `result` — the result of the call, encoded as a hexadecimal string. The format of the result depends on the function called.

## Use case

The `eth_call` method is essential for:

* DApps that need to retrieve state or compute derived values from smart contracts without making a transaction.
* Wallets and interfaces that display contract information, such as token balances or the state of a decentralized finance (DeFi) contract.
* Automated scripts and bots that monitor contract states or conditions on the blockchain.


## OpenAPI

````yaml openapi/optimism_node_api/eth_call.json POST /efb0a5eccd2caa5135eb54eba6f7f300
openapi: 3.0.0
info:
  title: eth_call example
  version: 1.0.0
  description: >-
    This is an API example for eth_call, a method to execute a new message call
    immediately without creating a  transaction on the block chain.
servers:
  - url: https://optimism-mainnet.core.chainstack.com
security: []
paths:
  /efb0a5eccd2caa5135eb54eba6f7f300:
    post:
      tags:
        - Ethereum Operations
      summary: eth_call
      operationId: call
      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:
                    anyOf:
                      - type: object
                        properties:
                          to:
                            type: string
                            default: '0xC7846d1bc4d8bcF7c45a7c998b77cE9B3c904365'
                          data:
                            type: string
                            default: >-
                              0x1526fe270000000000000000000000000000000000000000000000000000000000000001
                      - type: string
                        default: latest
                  default:
                    - to: '0xC7846d1bc4d8bcF7c45a7c998b77cE9B3c904365'
                      data: >-
                        0x1526fe270000000000000000000000000000000000000000000000000000000000000001
                    - 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

````