# eth_callMany

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

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

Executes a list of transaction bundles without creating transactions on the blockchain. This method is particularly useful for simulating transactions to understand their potential outcomes. It supports simulating transactions at an intermediate state of a block, simulating multiple transactions with sequential dependencies, and overwriting block headers.


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

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| Bundles | object[] | Yes | A list of bundles where each bundle contains transactions and optional block overrides.  |
| Simulation context | object | Yes | The context for the simulation, specifying the blockNumber or Tag and transactionIndex.  |
| State overrides | object | No | An optional mapping for state overrides, following the eth_call standard.  |
| Timeout | integer | No | The maximum running time for the simulations in milliseconds, defaulting to 5000 milliseconds.  |

## Result

**Call results** (object[][]): A list of lists containing either the return value of the executed contract call or the reverted error code. Each bundle returns an array with one result per transaction. 

## Example

### Request

```json
{
  "jsonrpc": "2.0",
  "method": "eth_callMany",
  "params": [
    [
      {
        "transactions": [
          {
            "from": "0x1985ea6e9c68e1c272d8209f3b478ac2fdb25c87",
            "to": "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",
            "gas": "0x0f4240",
            "gasPrice": "0x7896e72a",
            "data": "0xa9059cbb000000000000000000000000bc0e63965946815d105e7591407704e6e1964e590000000000000000000000000000000000000000000000000000000005f5e100"
          },
          {
            "to": "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",
            "gasPrice": "0x7896e72a",
            "data": "0x70a08231000000000000000000000000bc0e63965946815d105e7591407704e6e1964e59"
          }
        ],
        "blockOverride": {
          "blockNumber": "0xbb5fe9"
        }
      }
    ],
    {
      "blockNumber": "0xbb5fe9",
      "transactionIndex": 1
    },
    {},
    5000
  ],
  "id": 1
}
```

### Response

```json
{
  "jsonrpc": "2.0",
  "result": [
    [
      {
        "value": "0x0000000000000000000000000000000000000000000000000000000000000001"
      },
      {
        "value": "0x0000000000000000000000000000000000000000000000000000000005f5e100"
      }
    ]
  ],
  "id": 1
}
```

## Code Examples

### cURL

```bash
curl --request POST \
  --url https://sonic-mainnet.g.alchemy.com/v2/docs-demo \
  --header 'Content-Type: application/json' \
  --data '{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "eth_callMany",
  "params": [
    [
      {
        "transactions": [
          {
            "type": "string",
            "nonce": "string",
            "to": null,
            "from": "string",
            "gas": "string",
            "value": "string",
            "input": "string",
            "gasPrice": "string",
            "maxPriorityFeePerGas": "string",
            "maxFeePerGas": "string",
            "maxFeePerBlobGas": "string",
            "accessList": [
              {
                "address": "string",
                "storageKeys": [
                  "string"
                ]
              }
            ],
            "blobVersionedHashes": [
              "string"
            ],
            "blobs": [
              "string"
            ],
            "chainId": "string"
          }
        ],
        "blockOverride": {
          "blockNumber": "string",
          "blockHash": "string",
          "coinbase": "string",
          "timestamp": "string",
          "difficulty": "string",
          "gasLimit": "string",
          "baseFee": "string"
        }
      }
    ],
    {
      "blockNumber": "0xbb5fe9",
      "transactionIndex": 1
    },
    {},
    5000
  ]
}'
```

### JavaScript

```javascript
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: JSON.stringify({
    jsonrpc: '2.0',
    id: 1,
    method: 'eth_callMany',
    params: [
      [
        {
          transactions: [
            {
              type: 'string',
              nonce: 'string',
              to: null,
              from: 'string',
              gas: 'string',
              value: 'string',
              input: 'string',
              gasPrice: 'string',
              maxPriorityFeePerGas: 'string',
              maxFeePerGas: 'string',
              maxFeePerBlobGas: 'string',
              accessList: [{address: 'string', storageKeys: ['string']}],
              blobVersionedHashes: ['string'],
              blobs: ['string'],
              chainId: 'string'
            }
          ],
          blockOverride: {
            blockNumber: 'string',
            blockHash: 'string',
            coinbase: 'string',
            timestamp: 'string',
            difficulty: 'string',
            gasLimit: 'string',
            baseFee: 'string'
          }
        }
      ],
      {blockNumber: '0xbb5fe9', transactionIndex: 1},
      {},
      5000
    ]
  })
};

fetch('https://sonic-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://sonic-mainnet.g.alchemy.com/v2/docs-demo"

payload = {
    "jsonrpc": "2.0",
    "id": 1,
    "method": "eth_callMany",
    "params": [[
            {
                "transactions": [
                    {
                        "type": "string",
                        "nonce": "string",
                        "to": None,
                        "from": "string",
                        "gas": "string",
                        "value": "string",
                        "input": "string",
                        "gasPrice": "string",
                        "maxPriorityFeePerGas": "string",
                        "maxFeePerGas": "string",
                        "maxFeePerBlobGas": "string",
                        "accessList": [
                            {
                                "address": "string",
                                "storageKeys": ["string"]
                            }
                        ],
                        "blobVersionedHashes": ["string"],
                        "blobs": ["string"],
                        "chainId": "string"
                    }
                ],
                "blockOverride": {
                    "blockNumber": "string",
                    "blockHash": "string",
                    "coinbase": "string",
                    "timestamp": "string",
                    "difficulty": "string",
                    "gasLimit": "string",
                    "baseFee": "string"
                }
            }
        ], {
            "blockNumber": "0xbb5fe9",
            "transactionIndex": 1
        }, {}, 5000]
}
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://sonic-mainnet.g.alchemy.com/v2/docs-demo"

	payload := strings.NewReader("{\n  \"jsonrpc\": \"2.0\",\n  \"id\": 1,\n  \"method\": \"eth_callMany\",\n  \"params\": [\n    [\n      {\n        \"transactions\": [\n          {\n            \"type\": \"string\",\n            \"nonce\": \"string\",\n            \"to\": null,\n            \"from\": \"string\",\n            \"gas\": \"string\",\n            \"value\": \"string\",\n            \"input\": \"string\",\n            \"gasPrice\": \"string\",\n            \"maxPriorityFeePerGas\": \"string\",\n            \"maxFeePerGas\": \"string\",\n            \"maxFeePerBlobGas\": \"string\",\n            \"accessList\": [\n              {\n                \"address\": \"string\",\n                \"storageKeys\": [\n                  \"string\"\n                ]\n              }\n            ],\n            \"blobVersionedHashes\": [\n              \"string\"\n            ],\n            \"blobs\": [\n              \"string\"\n            ],\n            \"chainId\": \"string\"\n          }\n        ],\n        \"blockOverride\": {\n          \"blockNumber\": \"string\",\n          \"blockHash\": \"string\",\n          \"coinbase\": \"string\",\n          \"timestamp\": \"string\",\n          \"difficulty\": \"string\",\n          \"gasLimit\": \"string\",\n          \"baseFee\": \"string\"\n        }\n      }\n    ],\n    {\n      \"blockNumber\": \"0xbb5fe9\",\n      \"transactionIndex\": 1\n    },\n    {},\n    5000\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://sonic-mainnet.g.alchemy.com/v2/docs-demo")
  .header("Content-Type", "application/json")
  .body("{\n  \"jsonrpc\": \"2.0\",\n  \"id\": 1,\n  \"method\": \"eth_callMany\",\n  \"params\": [\n    [\n      {\n        \"transactions\": [\n          {\n            \"type\": \"string\",\n            \"nonce\": \"string\",\n            \"to\": null,\n            \"from\": \"string\",\n            \"gas\": \"string\",\n            \"value\": \"string\",\n            \"input\": \"string\",\n            \"gasPrice\": \"string\",\n            \"maxPriorityFeePerGas\": \"string\",\n            \"maxFeePerGas\": \"string\",\n            \"maxFeePerBlobGas\": \"string\",\n            \"accessList\": [\n              {\n                \"address\": \"string\",\n                \"storageKeys\": [\n                  \"string\"\n                ]\n              }\n            ],\n            \"blobVersionedHashes\": [\n              \"string\"\n            ],\n            \"blobs\": [\n              \"string\"\n            ],\n            \"chainId\": \"string\"\n          }\n        ],\n        \"blockOverride\": {\n          \"blockNumber\": \"string\",\n          \"blockHash\": \"string\",\n          \"coinbase\": \"string\",\n          \"timestamp\": \"string\",\n          \"difficulty\": \"string\",\n          \"gasLimit\": \"string\",\n          \"baseFee\": \"string\"\n        }\n      }\n    ],\n    {\n      \"blockNumber\": \"0xbb5fe9\",\n      \"transactionIndex\": 1\n    },\n    {},\n    5000\n  ]\n}")
  .asString();
```

### C#

```csharp
using RestSharp;


var options = new RestClientOptions("https://sonic-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_callMany\",\n  \"params\": [\n    [\n      {\n        \"transactions\": [\n          {\n            \"type\": \"string\",\n            \"nonce\": \"string\",\n            \"to\": null,\n            \"from\": \"string\",\n            \"gas\": \"string\",\n            \"value\": \"string\",\n            \"input\": \"string\",\n            \"gasPrice\": \"string\",\n            \"maxPriorityFeePerGas\": \"string\",\n            \"maxFeePerGas\": \"string\",\n            \"maxFeePerBlobGas\": \"string\",\n            \"accessList\": [\n              {\n                \"address\": \"string\",\n                \"storageKeys\": [\n                  \"string\"\n                ]\n              }\n            ],\n            \"blobVersionedHashes\": [\n              \"string\"\n            ],\n            \"blobs\": [\n              \"string\"\n            ],\n            \"chainId\": \"string\"\n          }\n        ],\n        \"blockOverride\": {\n          \"blockNumber\": \"string\",\n          \"blockHash\": \"string\",\n          \"coinbase\": \"string\",\n          \"timestamp\": \"string\",\n          \"difficulty\": \"string\",\n          \"gasLimit\": \"string\",\n          \"baseFee\": \"string\"\n        }\n      }\n    ],\n    {\n      \"blockNumber\": \"0xbb5fe9\",\n      \"transactionIndex\": 1\n    },\n    {},\n    5000\n  ]\n}", false);
var response = await client.PostAsync(request);

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

```


## OpenRPC Method Specification

```yaml
name: eth_callMany
description: |
  Executes a list of transaction bundles without creating transactions on the blockchain. This method is particularly useful for simulating transactions to understand their potential outcomes. It supports simulating transactions at an intermediate state of a block, simulating multiple transactions with sequential dependencies, and overwriting block headers.
params:
  - name: Bundles
    required: true
    description: |
      A list of bundles where each bundle contains transactions and optional block overrides.
    schema:
      type: array
      minItems: 1
      items:
        type: object
        required:
          - transactions
        additionalProperties: false
        properties:
          transactions:
            description: An array of transaction objects with parameters similar to eth_call.
            type: array
            minItems: 1
            items:
              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)$
          blockOverride:
            description: |
              Overrides for the execution context block header, including blockNumber, blockHash, coinbase, timestamp, difficulty, gasLimit, and baseFee.
            type: object
            additionalProperties: false
            properties:
              blockNumber:
                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
                    description: Unsigned integer block height (e.g., 0 for genesis).
                    type: string
                    pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$
                  - 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.
              blockHash:
                title: 32 byte hex value
                type: string
                pattern: ^0x[0-9a-f]{64}$
              coinbase:
                title: hex encoded address
                type: string
                pattern: ^0x[0-9a-fA-F]{40}$
              timestamp:
                title: hex encoded unsigned integer
                type: string
                pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$
              difficulty:
                title: hex encoded unsigned integer
                type: string
                pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$
              gasLimit:
                title: hex encoded unsigned integer
                type: string
                pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$
              baseFee:
                title: hex encoded unsigned integer
                type: string
                pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$
  - name: Simulation context
    required: true
    description: |
      The context for the simulation, specifying the blockNumber or Tag and transactionIndex.
    schema:
      type: object
      required:
        - blockNumber
        - transactionIndex
      additionalProperties: false
      properties:
        blockNumber:
          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
              description: Unsigned integer block height (e.g., 0 for genesis).
              type: string
              pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$
            - 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.
        transactionIndex:
          type: integer
          minimum: 0
  - name: State overrides
    required: false
    description: |
      An optional mapping for state overrides, following the eth_call standard.
    schema:
      type: object
      additionalProperties:
        type: object
        additionalProperties: false
        properties:
          balance:
            title: hex encoded unsigned integer
            type: string
            pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$
          nonce:
            title: hex encoded unsigned integer
            type: string
            pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$
          code:
            title: hex encoded bytes
            type: string
            pattern: ^0x[0-9a-f]*$
          state:
            description: Full storage override (slot -> value, 32-byte hex).
            type: object
            additionalProperties:
              title: 32 byte hex value
              type: string
              pattern: ^0x[0-9a-f]{64}$
          stateDiff:
            description: Partial storage diff (slot -> value, 32-byte hex).
            type: object
            additionalProperties:
              title: 32 byte hex value
              type: string
              pattern: ^0x[0-9a-f]{64}$
  - name: Timeout
    required: false
    description: |
      The maximum running time for the simulations in milliseconds, defaulting to 5000 milliseconds.
    schema:
      type: integer
      minimum: 1
result:
  name: Call results
  description: |
    A list of lists containing either the return value of the executed contract call or the reverted error code. Each bundle returns an array with one result per transaction.
  schema:
    type: array
    items:
      type: array
      items:
        oneOf:
          - type: object
            additionalProperties: false
            required:
              - value
            properties:
              value:
                title: hex encoded bytes
                type: string
                pattern: ^0x[0-9a-f]*$
                description: The return value if the transaction was successful.
          - type: object
            additionalProperties: false
            required:
              - error
            properties:
              error:
                description: The error if the transaction failed.
                type: object
                required:
                  - code
                  - message
                additionalProperties: false
                properties:
                  code:
                    type: integer
                  message:
                    type: string
                  data:
                    title: hex encoded bytes
                    type: string
                    pattern: ^0x[0-9a-f]*$
                    description: Optional ABI-encoded revert data.
examples:
  - name: eth_callMany — USDC transfer and balance check example
    params:
      - name: Bundles
        value:
          - transactions:
              - from: '0x1985ea6e9c68e1c272d8209f3b478ac2fdb25c87'
                to: '0x833589fcd6edb6e08f4c7c32d4f71b54bda02913'
                gas: '0x0f4240'
                gasPrice: '0x7896e72a'
                data: '0xa9059cbb000000000000000000000000bc0e63965946815d105e7591407704e6e1964e590000000000000000000000000000000000000000000000000000000005f5e100'
              - to: '0x833589fcd6edb6e08f4c7c32d4f71b54bda02913'
                gasPrice: '0x7896e72a'
                data: '0x70a08231000000000000000000000000bc0e63965946815d105e7591407704e6e1964e59'
            blockOverride:
              blockNumber: '0xbb5fe9'
      - name: Simulation context
        value:
          blockNumber: '0xbb5fe9'
          transactionIndex: 1
      - name: State overrides
        value: {}
      - name: Timeout
        value: 5000
    result:
      name: Call results
      value:
        - - value: '0x0000000000000000000000000000000000000000000000000000000000000001'
          - value: '0x0000000000000000000000000000000000000000000000000000000005f5e100'
  - name: eth_callMany — revert example
    params:
      - name: Bundles
        value:
          - transactions:
              - to: '0x0000000000000000000000000000000000000000'
                data: '0xdeadbeef'
      - name: Simulation context
        value:
          blockNumber: latest
          transactionIndex: 0
    result:
      name: Call results
      value:
        - - error:
              code: -32000
              message: execution reverted
              data: 0x08c379a00000000000000000000000000000000000000000000000000000000000000020...
```
