---
title: slotsUpdatesSubscribe
description:
  Subscribe to tagged slot lifecycle updates emitted by the validator.
url: /docs/rpc/websocket/slotsupdatessubscribe
type: reference
hideTableOfContents: true
---

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

<Callout type="info" title="Source">
  [`slots_updates_subscribe`](https://github.com/anza-xyz/agave/blob/v3.1.8/rpc/src/rpc_pubsub.rs#L537)
</Callout>

<Callout type="warn">
  This subscription is unstable. The format may change in the future and may not
  always be supported.
</Callout>

<APIMethod>

```jsonc !!request curl
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "slotsUpdatesSubscribe"
}
```

```ts !!request title="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 !!request title="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(())
}
```

### !params

**None**

### !!result

```jsonc !response
{
  "jsonrpc": "2.0",
  // !hover result
  "result": 0,
  "id": 1
}
```

!type integer

Subscription id. Pass this to
[slotsUpdatesUnsubscribe](/docs/rpc/websocket/slotsupdatesunsubscribe).

</APIMethod>

### 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.

<CodeReference>

```jsonc !!
{
  // !hover jsonrpc
  "jsonrpc": "2.0",
  // !hover method
  "method": "slotsUpdatesNotification",
  // !hover(1:14) params
  "params": {
    // !hover(1:11) params.result
    "result": {
      // !hover params.result.type
      "type": "frozen",
      // !hover params.result.slot
      "slot": 356,
      // !hover params.result.timestamp
      "timestamp": 1774643712834,
      // !hover(1:6) params.result.stats
      "stats": {
        // !hover params.result.stats.numTransactionEntries
        "numTransactionEntries": 1,
        // !hover params.result.stats.numSuccessfulTransactions
        "numSuccessfulTransactions": 1,
        // !hover params.result.stats.numFailedTransactions
        "numFailedTransactions": 0,
        // !hover params.result.stats.maxTransactionsPerEntry
        "maxTransactionsPerEntry": 1
      }
    },
    // !hover params.subscription
    "subscription": 4
  }
}
```

## !reference

### !! jsonrpc

!type string

Always `"2.0"`.

### !! method

!type string

Always `"slotsUpdatesNotification"`.

### !! params

!type object

Notification wrapper with the serialized slot-update payload and the
subscription id.

#### !! result

!type object

Tagged payload with a `type` discriminator. The fields present depend on the
variant listed in the table above.

##### !! type

!type string

Variant discriminator serialized with camelCase values such as
`"firstShredReceived"` or `"frozen"`.

##### !! slot

!type u64

Slot associated with this update.

##### !! timestamp

!type u64

Unix timestamp in milliseconds for this update.

##### !! stats

!type SlotTransactionStats | undefined

Transaction statistics present only on `frozen` updates.

###### !! numTransactionEntries

!type u64

Number of transaction entries in the slot.

###### !! numSuccessfulTransactions

!type u64

Number of successfully executed transactions in the slot.

###### !! numFailedTransactions

!type u64

Number of failed transactions in the slot.

###### !! maxTransactionsPerEntry

!type u64

Largest transaction count among entries in the slot.

#### !! subscription

!type integer

Subscription id that produced this notification.

</CodeReference>
