> For the complete documentation index, see [llms.txt](https://docs.getblock.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.getblock.io/api-reference/solana-sol/slotsubscribe-solana.md).

# slotSubscribe – Solana

{% hint style="info" %}
The **slotSubscribe RPC Solana** method establishes a **WebSocket connection** that notifies clients when a new **slot** is set.
{% endhint %}

This is particularly useful for applications that require **live updates** on the Solana blockchain. Developers can use this method to **track transaction processing, blockchain synchronization, and block validation.**

### Supported Networks

* Mainnet

### Parameters

{% hint style="info" %}
None: This method does not require any parameters.
{% endhint %}

### Result

Returns a **subscription ID**, which is required for **unsubscribing** from notifications.

#### Result Format

* **`integer`**: The **subscription ID** needed to **unsubscribe**.

### Request Example

#### API Endpoints

```json
wss://go.getblock.io/<ACCESS-TOKEN>/
```

#### JSON-RPC Request

{% tabs %}
{% tab title="wss" %}

```json
wscat -c "wss://go.getblock.io/<ACCESS-TOKEN>/" --exec '{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "slotSubscribe"
}'

```

{% endtab %}
{% endtabs %}

### Response

A successful **request** returns a **subscription ID**.

#### Example Response

```json
{
  "jsonrpc": "2.0",
  "result": 0,
  "id": 1
}
```

In this response:

* **result**: **`0`** represents the assigned **subscription ID**.

### Notification Format

Upon slot updates, clients receive notifications containing slot details.

#### Example Notification

```json
{
  "jsonrpc": "2.0",
  "method": "slotNotification",
  "params": {
    "result": {
      "parent": 75,
      "root": 44,
      "slot": 76
    },
    "subscription": 0
  }
}
```

#### Notification Fields

* **`parent`**: The **parent slot**.
* **`root`**: The **current root slot**.
* **`slot`**: The **newly set slot value**.

### Error Handling

Common **slotSubscribe error** scenarios:

* **Network issues**: Problems with the **Solana JSON-RPC API endpoints**.
* **Invalid WebSocket connection**: Issues with **maintaining a stable connection**.

#### Example Error Response

```json
{
  "jsonrpc": "2.0",
  "error": {
    "code": -32000,
    "message": "WebSocket connection error"
  },
  "id": 1
}
```

### Use Cases

The **Solana slotSubscribe** method is essential for:

* **Live blockchain monitoring**.
* **Tracking real-time slot updates** for validators and explorers.
* **Keeping applications in sync** with the Solana blockchain.
* **Enhancing dApps** by ensuring **transaction validation** and **block consistency**.

### Code slotSubscribe Example – Web3 Integration

{% tabs %}
{% tab title="JavaScript" %}

```javascript
const WebSocket = require('ws');

const ws = new WebSocket("wss://go.getblock.io/<ACCESS-TOKEN>/");

ws.on('open', () => {
  const payload = {
    jsonrpc: "2.0",
    id: 1,
    method: "slotSubscribe"
  };
  ws.send(JSON.stringify(payload));
});

ws.on('message', (data) => {
  console.log("Slot Notification:", JSON.parse(data));
});

ws.on('error', (error) => {
  console.error("WebSocket error:", error.message);
});

ws.on('close', () => {
  console.log("WebSocket connection closed");
});

```

{% endtab %}
{% endtabs %}

### Integration with Web3

By integrating Web3 **slotSubscribe** into **Solana's Core API**, developers can:

* **Monitor slot progression in real-time**.
* **Enhance dApps with live updates**.
* **Improve blockchain data tracking systems**.
* **Ensure API requests** are processed efficiently.
* **Track block synchronization** to optimize transactions and **block validation**.

This method is a critical component of the **Core API** that enables efficient **block tracking, request handling, and transaction updates** in Solana-based applications.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.getblock.io/api-reference/solana-sol/slotsubscribe-solana.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
