getSlotLeaders - Solana

This method returns the identity Pubkey of the scheduled leader for each slot in a contiguous range. A maximum of 5,000 slots can be requested per call.

Parameters

ParameterTypeRequiredDescription
startSlotnumberYesFirst slot of the range, inclusive
limitnumberYesNumber of slots to return, between 1 and 5000

Request

bashcurl --location --request POST 'https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/' \
--header 'Content-Type: application/json' \
--data-raw '{
    "jsonrpc": "2.0",
    "method": "getSlotLeaders",
    "params": [397234561, 4],
    "id": "getblock.io"
}'

example.js

javascriptconst { Connection } = require('@solana/web3.js');

const connection = new Connection('https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/', 'confirmed');

const leaders = await connection.getSlotLeaders(397234561, 4);

console.log(leaders.map((l) => l.toBase58()));

example.py

pythonimport requests

response = requests.post(
    'https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/',
    headers={'Content-Type': 'application/json'},
    json={
        'jsonrpc': '2.0',
        'method': 'getSlotLeaders',
        'params': [397234561, 4],
        'id': 'getblock.io'
    }
)

print(response.json()['result'])

example.rs

rustuse reqwest::Client;
use serde_json::{json, Value};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = Client::new();

    let response = client
        .post("https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/")
        .header("Content-Type", "application/json")
        .json(&json!({
            "jsonrpc": "2.0",
            "method": "getSlotLeaders",
            "params": [397234561, 4],
            "id": "getblock.io"
        }))
        .send()
        .await?
        .json::<Value>()
        .await?;

    println!("Result: {}", response["result"]);
    Ok(())
}

Response

json{
    "jsonrpc": "2.0",
    "id": "getblock.io",
    "result": [
        "dv1ZAGvdsz5hHLwWXsVnM94hWf1pjbKVau1QVkaMJ92",
        "dv1ZAGvdsz5hHLwWXsVnM94hWf1pjbKVau1QVkaMJ92",
        "dv1ZAGvdsz5hHLwWXsVnM94hWf1pjbKVau1QVkaMJ92",
        "dv1ZAGvdsz5hHLwWXsVnM94hWf1pjbKVau1QVkaMJ92"
    ]
}

Response Parameters

ParameterTypeDescription
jsonrpcstringJSON-RPC protocol version ("2.0")
idstringRequest identifier matching the request
resultarrayArray of leader identity Pubkeys, one per slot in the requested range

Use Cases

  • Leader Prefetch: Warm connections to the next few leaders before sending
  • Send Fanout: Broadcast a transaction to several upcoming leaders at once
  • Rotation Analysis: Observe the four-slot leader rotation pattern directly
  • Operator Alerts: Notify an operator shortly before its leader slots begin

Error Handling

Error CodeMessageDescription
-32602Invalid paramsLimit exceeds 5000 or the range extends beyond the known schedule
-32603Internal errorNode failed to read the leader schedule for the range
-32005Node is unhealthyThe node has fallen behind the cluster tip