> For the complete documentation index, see [llms.txt](https://docs.circular.fi/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.circular.fi/v2/replay.md).

# Replay 🆕

**Get the exact state a Solana transaction ran against.**

**Replay** is Circular's state replay API for Solana mainnet.\
It returns the state of every account a transaction loaded, before and after it ran, rebuilt by Circular's replayer in the slot the transaction landed in.

Load that state into LiteSVM and the transaction runs again on your machine, with the same compute units and the same logs as on chain. From there you can change an account, try another amount or test a strategy against real state.

### Why Replay exists

An RPC gives you the state of now, and a simulation runs against it. To understand why a transaction succeeded, failed or made what it made, you need the state it actually executed against: the accounts as they were in its slot, right before it ran, with the program versions deployed at that moment.

### What you get

#### Transaction

The pre and post state of every account a transaction loaded, its address lookup tables, the parsed SPL Token data, the sysvars of its slot and, on request, the bytecode and program data of the programs that ran. See [Transaction](https://docs.circular.fi/v2/replay/transaction.md).

#### Accounts at a slot

The state of up to 100 accounts at the start of any slot of the window. See [Slot accounts](https://docs.circular.fi/v2/replay/slot-accounts.md).

#### Slot entries

The signatures of a slot, entry by entry, in execution order. See [Slot entries](https://docs.circular.fi/v2/replay/slot-entries.md).

### Routes

| Route                                    | Returns                                                    | Credits |
| ---------------------------------------- | ---------------------------------------------------------- | ------- |
| `GET /v2/replay/tx/:signature`           | Pre and post state of every account the transaction loaded | 25,000  |
| `GET /v2/replay/slot/:slot?accounts=...` | State of 1 to 100 accounts at the start of the slot        | 25,000  |
| `GET /v2/replay/slot/:slot/entries`      | Signatures of the slot, grouped by entry                   | 1,000   |
| `GET /v2/replay/status`                  | The queryable slot window                                  | Free    |

Base URL: `https://pro.circular.fi`. Every route is a `GET` and takes your API key in the `x-api-key` header, like the rest of the Pro API (see [Api Keys](https://docs.circular.fi/informations/api-keys.md) and [Authentification](https://docs.circular.fi/informations/auth.md)).

### Queryable window

Replay covers a rolling window of recent slots, not the full history of the chain. [Status](https://docs.circular.fi/v2/replay/status.md) returns the oldest and the newest slot you can query. A slot outside the window answers `404 slot_out_of_window` and costs nothing.

### Access, credits and limits

* Available from the **Searcher** plan. Free keys have no access.
* A request that fails (slot outside the window, replayer busy, upstream error) consumes no credits. It still counts in the per-minute limit.
* Requests per minute, counted separately on each paid route: Searcher 10 / Startup 100 / Pro 200.
* At most 4 replay requests in flight per API key.

### Compression

With `program_details=true`, a response carries the bytecode of the programs the transaction loaded: tens of MB of JSON (16 MB for a transaction loading four programs). Always send `Accept-Encoding: gzip` (or `zstd`): the response is about 15 times smaller (`--compressed` with curl).

### Errors

Errors of the replay itself use the v2 envelope, with the error code at the start of the message:

```json
{
  "success": false,
  "errors": [
    { "code": 404, "message": "slot_out_of_window: ..." }
  ],
  "data": null,
  "meta": { "ts": 1793805474302 }
}
```

| HTTP      | Code                                                                                   | Meaning                                                                                                           |
| --------- | -------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------- |
| 402       | `Insufficient credits`                                                                 | Not enough credits left for this call                                                                             |
| 403       | `Access to this route is not allowed.`                                                 | The plan has no access to Replay (Free), or no API key was sent                                                   |
| 404       | `slot_out_of_window`                                                                   | The slot is outside the queryable window                                                                          |
| 404       | `transaction_not_found`, `slot_not_resolved`, `slot_out_of_range`                      | Unknown transaction or slot                                                                                       |
| 422       | `invalid_signature`, `invalid_pubkey`, `too_many_accounts`                             | Invalid input, nothing is charged                                                                                 |
| 429       | `Rate limit exceeded.`, `too_many_inflight`                                            | Rate limit of the plan, or more than 4 replay requests in flight on the key: retry after the `Retry-After` header |
| 503       | `slot_not_yet_indexed`                                                                 | The slot is newer than the indexed window, retry shortly                                                          |
| 503       | `replay_busy`                                                                          | The replayer is at capacity, retry after the `Retry-After` header                                                 |
| 503       | `replay_unavailable`                                                                   | Replay is not available, retry later                                                                              |
| 502 / 504 | `upstream_error`, `upstream_unreachable`, `upstream_unauthorized` / `upstream_timeout` | The replayer is unavailable, retry later                                                                          |

Refusals made before the route runs (invalid input, plan, rate limit, credits) come as `{ "detail": { "message": "..." } }` instead of the envelope. A failed request consumes no credits.

### Try it in the app

Every replay is also browsable in the app at [circular.fi/replay](https://circular.fi/replay): the state diff account by account, the programs that ran, its slot in execution order, and a local replay in the browser.

### The payoff

Replay gives you the state a transaction **actually** ran against, ready to run again.

To understand a Solana transaction, start from the state it saw.
