# eth_callBundle

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

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

Simulates a bundle of signed transactions against a specific block number, including simulating a bundle at the top of the next block. This method allows you to test transaction bundles before submitting them to the network.


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

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| Bundle parameters | object | Yes | The bundle simulation parameters containing the transactions to simulate and the block context for the simulation.  |

## Result

**Bundle simulation result** (object): The result of the bundle simulation containing gas usage, fees, and individual transaction results. 

## Example

### Request

```json
{
  "jsonrpc": "2.0",
  "method": "eth_callBundle",
  "params": [
    {
      "txs": [
        "0x123abc...",
        "0x456def..."
      ],
      "blockNumber": "0xb63dcd",
      "stateBlockNumber": "latest",
      "timestamp": 1615920932
    }
  ],
  "id": 1
}
```

### Response

```json
{
  "jsonrpc": "2.0",
  "result": {
    "bundleGasPrice": "476190476193",
    "bundleHash": "0x73b1e258c7a42fd0230b2fd05529c5d4b6fcb66c227783f8bece8aeacdd1db2e",
    "coinbaseDiff": "20000000000126000",
    "ethSentToCoinbase": "20000000000000000",
    "gasFees": "126000",
    "results": [
      {
        "coinbaseDiff": "10000000000063000",
        "ethSentToCoinbase": "10000000000000000",
        "fromAddress": "0x02A727155aeF8609c9f7F2179b2a1f560B39F5A0",
        "gasFees": "63000",
        "gasPrice": "476190476193",
        "gasUsed": 21000,
        "toAddress": "0x73625f59CAdc5009Cb458B751b3E7b6b48C06f2C",
        "txHash": "0x669b4704a7d993a946cdd6e2f95233f308ce0c4649d2e04944e8299efcaa098a",
        "value": "0x"
      },
      {
        "coinbaseDiff": "10000000000063000",
        "ethSentToCoinbase": "10000000000000000",
        "fromAddress": "0x02A727155aeF8609c9f7F2179b2a1f560B39F5A0",
        "gasFees": "63000",
        "gasPrice": "476190476193",
        "gasUsed": 21000,
        "toAddress": "0x73625f59CAdc5009Cb458B751b3E7b6b48C06f2C",
        "txHash": "0xa839ee83465657cac01adc1d50d96c1b586ed498120a84a64749c0034b4f19fa",
        "value": "0x"
      }
    ],
    "stateBlockNumber": 5221585,
    "totalGasUsed": 42000
  },
  "id": 1
}
```

## Code Examples

### cURL

```bash
curl --request POST \
  --url https://tempo-mainnet.g.alchemy.com/v2/docs-demo \
  --header 'Content-Type: application/json' \
  --data '{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "eth_callBundle",
  "params": [
    {
      "txs": [
        "0x123abc...",
        "0x456def..."
      ],
      "blockNumber": "0xb63dcd",
      "stateBlockNumber": "latest",
      "timestamp": 1615920932
    }
  ]
}'
```

### JavaScript

```javascript
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: JSON.stringify({
    jsonrpc: '2.0',
    id: 1,
    method: 'eth_callBundle',
    params: [
      {
        txs: ['0x123abc...', '0x456def...'],
        blockNumber: '0xb63dcd',
        stateBlockNumber: 'latest',
        timestamp: 1615920932
      }
    ]
  })
};

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

payload = {
    "jsonrpc": "2.0",
    "id": 1,
    "method": "eth_callBundle",
    "params": [
        {
            "txs": ["0x123abc...", "0x456def..."],
            "blockNumber": "0xb63dcd",
            "stateBlockNumber": "latest",
            "timestamp": 1615920932
        }
    ]
}
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://tempo-mainnet.g.alchemy.com/v2/docs-demo"

	payload := strings.NewReader("{\n  \"jsonrpc\": \"2.0\",\n  \"id\": 1,\n  \"method\": \"eth_callBundle\",\n  \"params\": [\n    {\n      \"txs\": [\n        \"0x123abc...\",\n        \"0x456def...\"\n      ],\n      \"blockNumber\": \"0xb63dcd\",\n      \"stateBlockNumber\": \"latest\",\n      \"timestamp\": 1615920932\n    }\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://tempo-mainnet.g.alchemy.com/v2/docs-demo")
  .header("Content-Type", "application/json")
  .body("{\n  \"jsonrpc\": \"2.0\",\n  \"id\": 1,\n  \"method\": \"eth_callBundle\",\n  \"params\": [\n    {\n      \"txs\": [\n        \"0x123abc...\",\n        \"0x456def...\"\n      ],\n      \"blockNumber\": \"0xb63dcd\",\n      \"stateBlockNumber\": \"latest\",\n      \"timestamp\": 1615920932\n    }\n  ]\n}")
  .asString();
```

### C#

```csharp
using RestSharp;


var options = new RestClientOptions("https://tempo-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_callBundle\",\n  \"params\": [\n    {\n      \"txs\": [\n        \"0x123abc...\",\n        \"0x456def...\"\n      ],\n      \"blockNumber\": \"0xb63dcd\",\n      \"stateBlockNumber\": \"latest\",\n      \"timestamp\": 1615920932\n    }\n  ]\n}", false);
var response = await client.PostAsync(request);

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

```


## OpenRPC Method Specification

```yaml
name: eth_callBundle
description: |
  Simulates a bundle of signed transactions against a specific block number, including simulating a bundle at the top of the next block. This method allows you to test transaction bundles before submitting them to the network.
params:
  - name: Bundle parameters
    required: true
    description: |
      The bundle simulation parameters containing the transactions to simulate and the block context for the simulation.
    schema:
      type: object
      required:
        - txs
        - blockNumber
        - stateBlockNumber
      additionalProperties: false
      properties:
        txs:
          description: Array of signed transactions to execute in an atomic bundle.
          type: array
          minItems: 1
          items:
            title: hex encoded bytes
            type: string
            pattern: ^0x[0-9a-f]*$
        blockNumber:
          description: A hex encoded block number for which this bundle is valid on.
          title: hex encoded unsigned integer
          type: string
          pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$
        stateBlockNumber:
          description: |
            Either a hex encoded number or a block tag for which state to base this simulation on. Can use "latest".
          title: Block number, tag, or 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
              description: 32-byte Keccak hash of the block header identifying a specific block.
              type: string
              pattern: ^0x[0-9a-f]{64}$
        timestamp:
          description: |
            Optional timestamp to use for this bundle simulation, in seconds since the unix epoch.
          type: integer
          minimum: 0
result:
  name: Bundle simulation result
  description: |
    The result of the bundle simulation containing gas usage, fees, and individual transaction results.
  schema:
    type: object
    required:
      - bundleGasPrice
      - bundleHash
      - coinbaseDiff
      - ethSentToCoinbase
      - gasFees
      - results
      - stateBlockNumber
      - totalGasUsed
    additionalProperties: false
    properties:
      bundleGasPrice:
        description: The gas price used for the bundle simulation.
        title: hex encoded unsigned integer
        type: string
        pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$
      bundleHash:
        description: The hash of the bundle.
        title: 32 byte hex value
        type: string
        pattern: ^0x[0-9a-f]{64}$
      coinbaseDiff:
        description: The total difference in coinbase payments.
        title: hex encoded unsigned integer
        type: string
        pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$
      ethSentToCoinbase:
        description: The total ETH sent to the coinbase.
        title: hex encoded unsigned integer
        type: string
        pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$
      gasFees:
        description: The total gas fees for the bundle.
        title: hex encoded unsigned integer
        type: string
        pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$
      results:
        description: Array of individual transaction results within the bundle.
        type: array
        items:
          type: object
          required:
            - coinbaseDiff
            - ethSentToCoinbase
            - fromAddress
            - gasFees
            - gasPrice
            - gasUsed
            - toAddress
            - txHash
            - value
          additionalProperties: false
          properties:
            coinbaseDiff:
              description: The coinbase difference for this transaction.
              title: hex encoded unsigned integer
              type: string
              pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$
            ethSentToCoinbase:
              description: The ETH sent to coinbase for this transaction.
              title: hex encoded unsigned integer
              type: string
              pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$
            fromAddress:
              title: hex encoded address
              type: string
              pattern: ^0x[0-9a-fA-F]{40}$
              description: The address that sent the transaction.
            gasFees:
              description: The gas fees for this transaction.
              title: hex encoded unsigned integer
              type: string
              pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$
            gasPrice:
              description: The gas price used for this transaction.
              title: hex encoded unsigned integer
              type: string
              pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$
            gasUsed:
              description: The amount of gas used by this transaction.
              type: integer
              minimum: 0
            toAddress:
              title: hex encoded address
              type: string
              pattern: ^0x[0-9a-fA-F]{40}$
              description: The address the transaction was sent to.
            txHash:
              description: The hash of the transaction.
              title: 32 byte hex value
              type: string
              pattern: ^0x[0-9a-f]{64}$
            value:
              description: The value transferred in the transaction.
              title: hex encoded unsigned integer
              type: string
              pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$
      stateBlockNumber:
        description: The block number used for state simulation.
        type: integer
        minimum: 0
      totalGasUsed:
        description: The total gas used by all transactions in the bundle.
        type: integer
        minimum: 0
examples:
  - name: eth_callBundle example
    params:
      - name: Bundle parameters
        value:
          txs:
            - 0x123abc...
            - 0x456def...
          blockNumber: '0xb63dcd'
          stateBlockNumber: latest
          timestamp: 1615920932
    result:
      name: Bundle simulation result
      value:
        bundleGasPrice: '476190476193'
        bundleHash: '0x73b1e258c7a42fd0230b2fd05529c5d4b6fcb66c227783f8bece8aeacdd1db2e'
        coinbaseDiff: '20000000000126000'
        ethSentToCoinbase: '20000000000000000'
        gasFees: '126000'
        results:
          - coinbaseDiff: '10000000000063000'
            ethSentToCoinbase: '10000000000000000'
            fromAddress: '0x02A727155aeF8609c9f7F2179b2a1f560B39F5A0'
            gasFees: '63000'
            gasPrice: '476190476193'
            gasUsed: 21000
            toAddress: '0x73625f59CAdc5009Cb458B751b3E7b6b48C06f2C'
            txHash: '0x669b4704a7d993a946cdd6e2f95233f308ce0c4649d2e04944e8299efcaa098a'
            value: 0x
          - coinbaseDiff: '10000000000063000'
            ethSentToCoinbase: '10000000000000000'
            fromAddress: '0x02A727155aeF8609c9f7F2179b2a1f560B39F5A0'
            gasFees: '63000'
            gasPrice: '476190476193'
            gasUsed: 21000
            toAddress: '0x73625f59CAdc5009Cb458B751b3E7b6b48C06f2C'
            txHash: '0xa839ee83465657cac01adc1d50d96c1b586ed498120a84a64749c0034b4f19fa'
            value: 0x
        stateBlockNumber: 5221585
        totalGasUsed: 42000
```
