> ## Documentation Index
> Fetch the complete documentation index at: https://solana.com/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> This page is part of the Solana developer documentation at https://solana.com/developers/docs. Append `.md` to any docs URL, or send `Accept: text/markdown`, to get the page as Markdown.
> Index of all pages: https://solana.com/llms.txt. Per-section indexes such as https://solana.com/developers/docs/payments/llms.txt are smaller; prefer them when working on one task.
> Coding agents: install the official Solana skill for current APIs and conventions with `npx skills add https://github.com/solana-foundation/solana-dev-skill` (also served at https://solana.com/SKILL.md).
> Code in the cookbook and task pages comes from tested example files. Prefer it over writing API calls from memory.

# slotsUpdatesSubscribe

> Subscribe to tagged slot lifecycle updates emitted by the validator.

Subscribe to a stream of tagged slot lifecycle updates emitted by the validator.

<Info>
  **Source**

  [`slots_updates_subscribe`](https://github.com/anza-xyz/agave/blob/v4.3.2/rpc/src/rpc_pubsub.rs#L540)
</Info>

<Warning>
  This subscription is unstable. The format may change in the future and may not
  always be supported.
</Warning>

<RequestExample>
  ```json WebSocket
  {
    "jsonrpc": "2.0",
    "id": 1,
    "method": "slotsUpdatesSubscribe"
  }
  ```

  ```ts web3.js
  import { Connection, clusterApiUrl } from "@solana/web3.js";

  const connection = new Connection(clusterApiUrl("devnet"), "confirmed");

  const subscriptionId = connection.onSlotUpdate((slotUpdate) => {
    console.log("Slot update:", slotUpdate);
  });
  ```

  ```rs Rust
  use anyhow::Result;
  use futures::StreamExt;
  use solana_client::nonblocking::pubsub_client::PubsubClient;

  #[tokio::main]
  async fn main() -> Result<()> {
      let pubsub_client = PubsubClient::new("wss://api.devnet.solana.com/").await?;

      let (mut notifications, unsubscribe) = pubsub_client.slot_updates_subscribe().await?;

      while let Some(notification) = notifications.next().await {
          println!("{:?}", notification);
      }

      unsubscribe().await;

      Ok(())
  }
  ```
</RequestExample>

<ResponseExample>
  ```json Response
  {
    "jsonrpc": "2.0",
    "result": 0,
    "id": 1
  }
  ```
</ResponseExample>

## Parameters

**None**

## Result

<ResponseField name="result" type="integer">
  Subscription id. Pass this to
  [slotsUpdatesUnsubscribe](/developers/docs/rpc/websocket/slotsupdatesunsubscribe).
</ResponseField>

## Notification format

Notifications are delivered as `slotsUpdatesNotification`. The payload is the
tagged slot-update object serialized as JSON with a `type` field.

| `type` value             | Fields present                |
| ------------------------ | ----------------------------- |
| `firstShredReceived`     | `slot`, `timestamp`           |
| `completed`              | `slot`, `timestamp`           |
| `createdBank`            | `slot`, `parent`, `timestamp` |
| `frozen`                 | `slot`, `timestamp`, `stats`  |
| `dead`                   | `slot`, `timestamp`, `err`    |
| `optimisticConfirmation` | `slot`, `timestamp`           |
| `root`                   | `slot`, `timestamp`           |

`timestamp` is emitted as a Unix timestamp in milliseconds.

The example below shows a `frozen` notification captured from a local validator.
Other variants use the field matrix above.

```json
{
  "jsonrpc": "2.0",
  "method": "slotsUpdatesNotification",
  "params": {
    "result": {
      "type": "frozen",
      "slot": 356,
      "timestamp": 1774643712834,
      "stats": {
        "numTransactionEntries": 1,
        "numSuccessfulTransactions": 1,
        "numFailedTransactions": 0,
        "maxTransactionsPerEntry": 1
      }
    },
    "subscription": 4
  }
}
```

<ResponseField name="jsonrpc" type="string">
  Always `"2.0"`.
</ResponseField>

<ResponseField name="method" type="string">
  Always `"slotsUpdatesNotification"`.
</ResponseField>

<ResponseField name="params" type="object">
  Notification wrapper with the serialized slot-update payload and the
  subscription id.

  <Expandable title="properties" defaultOpen>
    <ResponseField name="result" type="object">
      Tagged payload with a `type` discriminator. The fields present depend on the
      variant listed in the table above.

      <Expandable title="properties">
        <ResponseField name="type" type="string">
          Variant discriminator serialized with camelCase values such as
          `"firstShredReceived"` or `"frozen"`.
        </ResponseField>

        <ResponseField name="slot" type="u64">
          Slot associated with this update.
        </ResponseField>

        <ResponseField name="timestamp" type="u64">
          Unix timestamp in milliseconds for this update.
        </ResponseField>

        <ResponseField name="stats" type="SlotTransactionStats | undefined">
          Transaction statistics present only on `frozen` updates.

          <Expandable title="properties">
            <ResponseField name="numTransactionEntries" type="u64">
              Number of transaction entries in the slot.
            </ResponseField>

            <ResponseField name="numSuccessfulTransactions" type="u64">
              Number of successfully executed transactions in the slot.
            </ResponseField>

            <ResponseField name="numFailedTransactions" type="u64">
              Number of failed transactions in the slot.
            </ResponseField>

            <ResponseField name="maxTransactionsPerEntry" type="u64">
              Largest transaction count among entries in the slot.
            </ResponseField>
          </Expandable>
        </ResponseField>
      </Expandable>
    </ResponseField>

    <ResponseField name="subscription" type="integer">
      Subscription id that produced this notification.
    </ResponseField>
  </Expandable>
</ResponseField>
