# slotSubscribe

Solana API method to subscribe to receive notification each time a slot is processed by the validator.

# Solana.py

To use the Solana API subscriptions with the solana.py library, install the asyncstdlib package with:

pip install asyncstdlib

# cURL

To use the Solana API subscriptions with cURL, use the code example as a message body in a WebSocket request in Postman.

Parameters:

  • none

Returns:

  • <integer> — the subscription ID (needed to unsubscribe).

Example:

  • Solana web3.js
  • Solana.py
  • cURL
import { Connection } from "@solana/web3.js";

const web3 = new Connection("CHAINSTACK_HTTPS_URL", {
    wsEndpoint: "CHAINSTACK_WSS_URL",
  });

  (async () => {    
    web3.onSlotChange((slotInfo) =>
    console.log("Updated slot info: ", slotInfo)
  );
})();