# eth_call

> For the complete documentation index, see [llms.txt](/docs/llms.txt).

POST https://linea-mainnet.g.alchemy.com/v2/{apiKey}

Executes a new message call immediately without creating a transaction on the blockchain.

Reference: https://www.alchemy.com/docs/chains/linea/linea-api-endpoints/eth-call

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| Transaction | object | Yes | The transaction call object containing the details of the message call. |
| Block | string or enum | No | The block number, tag, or hash at which to execute the call. Defaults to `'latest'` if not provided. |

## Result

**Return data** (string): The return value of the executed contract function, encoded as a hexadecimal string.

## Example

### Request

```json
{
  "jsonrpc": "2.0",
  "method": "eth_call",
  "params": [
    {
      "to": "0x69498dd54bd25aa0c886cf1f8b8ae0856d55ff13",
      "value": "0x1"
    },
    "latest"
  ],
  "id": 1
}
```

### Response

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

## Code Examples

### cURL

```bash
curl --request POST \
  --url https://linea-mainnet.g.alchemy.com/v2/docs-demo \
  --header 'Content-Type: application/json' \
  --data '{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "eth_call",
  "params": [
    {
      "to": "0x69498dd54bd25aa0c886cf1f8b8ae0856d55ff13",
      "value": "0x1"
    },
    "latest"
  ]
}'
```

### JavaScript

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

fetch('https://linea-mainnet.g.alchemy.com/v2/docs-demo', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
```

### Python

```python
import requests

url = "https://linea-mainnet.g.alchemy.com/v2/docs-demo"

payload = {
    "jsonrpc": "2.0",
    "id": 1,
    "method": "eth_call",
    "params": [
        {
            "to": "0x69498dd54bd25aa0c886cf1f8b8ae0856d55ff13",
            "value": "0x1"
        },
        "latest"
    ]
}
headers = {"Content-Type": "application/json"}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
```

### Go

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://linea-mainnet.g.alchemy.com/v2/docs-demo"

	payload := strings.NewReader("{\n  \"jsonrpc\": \"2.0\",\n  \"id\": 1,\n  \"method\": \"eth_call\",\n  \"params\": [\n    {\n      \"to\": \"0x69498dd54bd25aa0c886cf1f8b8ae0856d55ff13\",\n      \"value\": \"0x1\"\n    },\n    \"latest\"\n  ]\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(string(body))

}
```

### Java

```java
HttpResponse<String> response = Unirest.post("https://linea-mainnet.g.alchemy.com/v2/docs-demo")
  .header("Content-Type", "application/json")
  .body("{\n  \"jsonrpc\": \"2.0\",\n  \"id\": 1,\n  \"method\": \"eth_call\",\n  \"params\": [\n    {\n      \"to\": \"0x69498dd54bd25aa0c886cf1f8b8ae0856d55ff13\",\n      \"value\": \"0x1\"\n    },\n    \"latest\"\n  ]\n}")
  .asString();
```

### C#

```csharp
using RestSharp;


var options = new RestClientOptions("https://linea-mainnet.g.alchemy.com/v2/docs-demo");
var client = new RestClient(options);
var request = new RestRequest("");
request.AddJsonBody("{\n  \"jsonrpc\": \"2.0\",\n  \"id\": 1,\n  \"method\": \"eth_call\",\n  \"params\": [\n    {\n      \"to\": \"0x69498dd54bd25aa0c886cf1f8b8ae0856d55ff13\",\n      \"value\": \"0x1\"\n    },\n    \"latest\"\n  ]\n}", false);
var response = await client.PostAsync(request);

Console.WriteLine("{0}", response.Content);

```


## OpenRPC Method Specification

```yaml
name: eth_call
description: Executes a new message call immediately without creating a transaction on the blockchain.
params:
  - name: Transaction
    required: true
    description: The transaction call object containing the details of the message call.
    schema:
      type: object
      title: Transaction object generic to all types
      description: Parameters describing a transaction/message call.
      additionalProperties: false
      properties:
        type:
          title: type
          description: Transaction type byte (per EIP-2718), e.g., 0x0 (legacy), 0x1 (EIP-2930), 0x2 (EIP-1559), 0x3 (EIP-4844).
          type: string
          pattern: ^0x([0-9a-fA-F]?){1,2}$
        nonce:
          title: nonce
          description: Number of prior transactions sent from the sender account.
          type: string
          pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$
        to:
          title: to address
          description: Recipient of the call. Use null to indicate contract creation.
          oneOf:
            - title: Contract Creation (null)
              description: Null to create a contract; the address is derived from sender and nonce.
              type: 'null'
            - title: Address
              type: string
              pattern: ^0x[0-9a-fA-F]{40}$
              description: 20-byte address of the recipient account or contract.
        from:
          title: from address
          type: string
          pattern: ^0x[0-9a-fA-F]{40}$
          description: 20-byte address of the sender (msg.sender).
        gas:
          title: gas limit
          description: Maximum gas provided for execution.
          type: string
          pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$
        value:
          title: value
          description: Amount of Ether to transfer with the call, in wei.
          type: string
          pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$
        input:
          title: input data
          type: string
          pattern: ^0x[0-9a-f]*$
          description: Calldata for the call (hex-encoded bytes).
        gasPrice:
          title: gas price
          description: The gas price willing to be paid by the sender in wei
          type: string
          pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$
        maxPriorityFeePerGas:
          title: max priority fee per gas
          description: Maximum fee per gas the sender is willing to pay to miners in wei
          type: string
          pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$
        maxFeePerGas:
          title: max fee per gas
          description: The maximum total fee per gas the sender is willing to pay (includes the network / base fee and miner / priority fee) in wei
          type: string
          pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$
        maxFeePerBlobGas:
          title: max fee per blob gas
          description: The maximum total fee per gas the sender is willing to pay for blob gas in wei
          type: string
          pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$
        accessList:
          title: accessList
          description: EIP-2930 access list of pre-touched addresses and storage keys.
          type: array
          items:
            title: Access list entry
            type: object
            additionalProperties: false
            properties:
              address:
                title: hex encoded address
                type: string
                pattern: ^0x[0-9a-fA-F]{40}$
              storageKeys:
                type: array
                items:
                  title: 32 byte hex value
                  type: string
                  pattern: ^0x[0-9a-f]{64}$
        blobVersionedHashes:
          title: blobVersionedHashes
          description: List of versioned blob hashes associated with the transaction's EIP-4844 data blobs.
          type: array
          items:
            title: 32 byte hex value
            type: string
            pattern: ^0x[0-9a-f]{64}$
        blobs:
          title: blobs
          description: Raw EIP-4844 blob data (each item is a binary-encoded blob).
          type: array
          items:
            title: hex encoded bytes
            type: string
            pattern: ^0x[0-9a-f]*$
        chainId:
          title: chainId
          description: Chain ID that this transaction is valid on.
          type: string
          pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$
  - name: Block
    required: false
    description: The block number, tag, or hash at which to execute the call. Defaults to `'latest'` if not provided.
    schema:
      title: Block number, tag, or block hash
      description: Identifies a block by explicit number, a predefined tag (e.g., latest/safe/finalized), or a 32-byte block hash.
      anyOf:
        - title: Block number
          type: string
          pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$
          description: Unsigned integer block height (e.g., 0 for genesis).
        - title: Block tag
          description: A well-known tag such as "latest", "earliest", "pending", "safe", or "finalized".
          type: string
          enum:
            - earliest
            - finalized
            - safe
            - latest
            - pending
        - title: Block hash
          type: string
          pattern: ^0x[0-9a-f]{64}$
          description: 32-byte Keccak hash of the block header identifying a specific block.
result:
  name: Return data
  description: The return value of the executed contract function, encoded as a hexadecimal string.
  schema:
    title: hex encoded bytes
    type: string
    pattern: ^0x[0-9a-f]*$
examples:
  - name: eth_call example
    params:
      - name: Transaction
        value:
          to: '0x69498dd54bd25aa0c886cf1f8b8ae0856d55ff13'
          value: '0x1'
      - name: Block
        value: latest
    result:
      name: Return data
      value: 0x
```
