# simulateBundle

> Simulates a Jito bundle: up to 20 transactions run in order, each on the state the ones before it left.

Source: https://docs.constant-k.com/rpc/http/simulatebundle/

`simulateBundle` runs the transactions of a bundle one after another on the region's current state. Each transaction sees the account changes of the transactions before it. The run stops at the first transaction that fails. Nothing is sent to the network.

The request and the response follow Jito's `simulateBundle`, so Jito client libraries work unchanged.

- Transport: HTTP, JSON-RPC 2.0 `POST` to `https://rpc-newyork.constant-k.com/?api-key=YOUR_API_KEY` (New York) or `https://rpc-frankfurt.constant-k.com/?api-key=YOUR_API_KEY` (Frankfurt) or `https://rpc-amsterdam.constant-k.com/?api-key=YOUR_API_KEY` (Amsterdam). The key also works as an `x-api-key` header.
- Category: Transactions
- Availability: Operator and above

## Parameters

`params` is a positional JSON array, in this order:

- `bundle` (object, required): An object with `encodedTransactions`: 1 to 20 base64-encoded transactions, in bundle order.
  - `encodedTransactions` (string[], optional)
- `config` (object, optional): `skipSigVerify` (default `false`): skip the signature checks. `replaceRecentBlockhash` (default `false`, needs `skipSigVerify`): run each transaction with the latest blockhash. `simulationBank`: `{"commitment": {"commitment": "processed"}}`, `confirmed` (the default) or `finalized`, or `"tip"` for processed. `preExecutionAccountsConfigs` and `postExecutionAccountsConfigs`: one entry per transaction, `null` or `{"addresses": [...], "encoding": "base64"}`, to return those accounts before or after the transaction runs. `transactionEncoding`: `base64` only.

## Result

- `result` (object, optional): `context` and `value`. `value.summary` is `"succeeded"`, or `failed` with the error and the signature of the first transaction that failed. `value.transactionResults` has one entry per transaction that ran: `err`, `logs`, `unitsConsumed`, `fee`, `preBalances`, `postBalances`, the token balances, the requested accounts, `returnData`, `loadedAddresses` and, with `replaceRecentBlockhash`, `replacementBlockhash`.

## Example: Simulate a two-transaction bundle

Request:

```bash
curl "https://rpc-newyork.constant-k.com/?api-key=YOUR_API_KEY" \
  -X POST \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "simulateBundle",
    "params": [
      {
        "encodedTransactions": [
          "<base64 transaction 1>",
          "<base64 transaction 2>"
        ]
      },
      {
        "skipSigVerify": true,
        "replaceRecentBlockhash": true,
        "preExecutionAccountsConfigs": [null, null],
        "postExecutionAccountsConfigs": [null, null]
      }
    ]
  }'
```

Response:

```json
{
  "jsonrpc": "2.0",
  "result": {
    "context": {
      "slot": 461637058,
      "apiVersion": "4.3.2"
    },
    "value": {
      "summary": "succeeded",
      "transactionResults": [
        {
          "err": null,
          "logs": [
            "Program 11111111111111111111111111111111 invoke [1]",
            "Program 11111111111111111111111111111111 success"
          ],
          "unitsConsumed": 150,
          "fee": 5000,
          "replacementBlockhash": {
            "blockhash": "ExampleBlockhashNotReal",
            "lastValidBlockHeight": 439666042
          }
        }
      ]
    }
  },
  "id": 1
}
```

_Long arrays in this example were trimmed._

## Notes

- The example transactions and blockhash are placeholders.
- Maximum 20 transactions per call. Base64 only.
- A transaction that fails comes back with its error, no logs and 0 compute units, the same as Jito's `simulateBundle`.
- The state is the region's node state at the requested commitment. A bundle can still fail in a block when its accounts change before it lands. A slot number in `simulationBank` is not supported.
- Counts against the plan's bundle limit. Runs in the region and does not use the Jito relay rate.
- Not accepted in batch requests, and not served on the Neon Zero hostnames. Not included in the Free plan.

