OpenInfra.sh is now live - Solana infrastructure, included with every server. LEARN MORE HERE >

OpenInfra.shopeninfra.sh

getLeaderSchedule

Returns the leader schedule for the epoch that contains the supplied slot, or for the current epoch if no slot is supplied.

Request

Send a JSON-RPC 2.0 POST request with method: "getLeaderSchedule". The params array takes an optional slot (or null) and an optional configuration object.

curl · JSON-RPCjson
{  "jsonrpc": "2.0",  "id": 1,  "method": "getLeaderSchedule",  "params": [    null,    {      "commitment": "processed",      "identity": "dv2eQHeP4RFrJZ6UeiZWoc3XTtmtZCUKxxCApCDcRNV"    }  ]}

@solana/kit

kit.tsts
import { address, createSolanaRpc, type Commitment } from "@solana/kit"; const rpc_url = "https://rpc.openinfra.sh";const rpc = createSolanaRpc(rpc_url); let slotNumber = null; let identity = address("dv1ZAGvdsz5hHLwWXsVnM94hWf1pjbKVau1QVkaMJ92");let commitment: Commitment = "finalized"; let leaderSchedule = await rpc  .getLeaderSchedule(slotNumber, { identity, commitment })  .send(); console.log(leaderSchedule);

@solana/web3.js

web3.tsts
import { Connection, clusterApiUrl } from "@solana/web3.js"; const connection = new Connection("https://rpc.openinfra.sh", "confirmed"); let leaderSchedule = await connection.getLeaderSchedule(); console.log(leaderSchedule);

Rust

main.rsrs
use anyhow::Result;use solana_client::{nonblocking::rpc_client::RpcClient, rpc_config::RpcLeaderScheduleConfig};use solana_commitment_config::CommitmentConfig; #[tokio::main]async fn main() -> Result<()> {    let client = RpcClient::new_with_commitment(        String::from("https://rpc.openinfra.sh"),        CommitmentConfig::confirmed(),    );     let slot_number = None;    let config = RpcLeaderScheduleConfig {        identity: String::from("dv1ZAGvdsz5hHLwWXsVnM94hWf1pjbKVau1QVkaMJ92").into(),        commitment: CommitmentConfig::finalized().into(),    };    let leader_schedule = client        .get_leader_schedule_with_config(slot_number, config)        .await?;     println!("{:#?}", leader_schedule);     Ok(())}

Parameters

ParameterTypeRequiredDescription
slotu64 | object | nullNoEither the slot used to select the epoch, null to use the current slot at the requested commitment, or a configuration object. If a number, the RPC returns the schedule for the epoch containing that slot. If null or omitted, uses the current epoch. If an object, it has the same shape as config and the slot is omitted.
configobjectNoConfiguration object. Only used when slot is a number or null.
config.commitmentstringNoCommitment level used to select which slot the node reads from. Accepted values: processed, confirmed, finalized (default).
config.identitystringNoReturn only entries for this validator identity, as a base-58 encoded string.

slot as an object

When slot is passed as an object instead of a number or null, it acts as the configuration and the separate config parameter is omitted. The object supports the following fields:

FieldTypeDescription
commitmentstringCommitment level used to select which slot the node reads from for this request.
identitystringValidator identity to filter for, as a base-58 encoded string.

commitment values

ValueDescription
processedReturn data from the highest slot this node has processed on the fork it currently considers best. This is the newest view, but it can still change if the cluster switches forks.
confirmedReturn data from the highest slot that at least two-thirds of active stake has directly voted to confirm. This is more stable than processed, but it is still a weaker guarantee than finalized.
finalizedReturn data from the highest slot that the cluster recognizes as finalized. In practice, this means the slot has reached maximum vote lockout in validators' vote towers and is recognized by at least two-thirds of active stake. This is the strongest commitment level.

Response

response.jsonjson
{  "jsonrpc": "2.0",  "result": {    "4Qkev8aNZcqFNSRhQzwyLMFSsi94jHqE8WNVTJzTP99F": [      0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,      21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38,      39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,      57, 58, 59, 60, 61, 62, 63    ]  },  "id": 1}

The result is null when the requested epoch is not available. Otherwise it is an object where each key is a validator identity (base-58 encoded) and each value is an array of slot indices relative to the first slot of the requested epoch.

FieldTypeDescription
resultobject | nullReturns null if the requested epoch is unavailable. Otherwise an object whose keys are validator identities (base-58 encoded strings) and whose values are arrays of leader slot indices relative to the first slot in the requested epoch.
<identity>number[]Array of slot indices (relative to the epoch's first slot) at which this validator is scheduled to be the leader.