getLeaderSchedule

Explore getLeaderSchedule: use cases, examples, parameters, responses, and expert tips.

The getLeaderSchedule RPC method retrieves the mapping of block production responsibilities to validators for a specific epoch. This data is vital for analyzing validator activity, predicting leader roles, and building advanced Solana network tooling.


🔍 Common Use Cases

  • Network Monitoring: Examine how leadership is distributed among validators during an epoch.

  • Advanced Transaction Routing: In low-latency applications, developers may attempt to align transactions with current or upcoming leaders.

  • Validator Uptime and Performance: Cross-reference scheduled leadership slots with actual block production to evaluate validator reliability.

  • Epoch Role Analysis: Understand the order and frequency with which each validator is assigned leadership duties.


📥 Request Parameters

You can pass up to two optional arguments:

  • slot (u64, optional): The slot used to determine which epoch’s schedule to return. If omitted, the current epoch is used.

  • config (object, optional):

    • commitment (string): Choose from finalized, confirmed, or processed. Defaults to the node’s commitment.

    • identity (string): Base-58 encoded validator public key. If provided, limits the result to only the specified validator’s slots.


📤 Response Structure

  • null: Returned if the schedule is unavailable (e.g. querying a future epoch not yet calculated).

  • Object: A mapping where:

    • Key = Validator public key (base-58)

    • Value = Array of slot indices (relative to the start of the epoch) during which that validator is the leader.

📌 Example: If an epoch begins at slot 1000, and a validator’s array is [0, 1, 5], that validator leads slots 1000, 1001, and 1005.


💡 Examples

  1. Fetch the Full Leader Schedule for the Current Epoch Query with no parameters to get all validators and their assigned slots.

{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "getLeaderSchedule"
}
  1. Fetch a Validator's Schedule for a Specific Epoch Provide a slot number (e.g., 200000) and a validator identity to see only their assignments for that epoch.

{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "getLeaderSchedule",
    "params": [
      200000,
      { "identity": "VALIDATOR_PUBKEY" }
    ]
}

Code Examples

const fetch = require('node-fetch');

async function getLeaderSchedule(rpcUrl) {
  try {
    const response = await fetch(rpcUrl, {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
      },
      body: JSON.stringify({
        jsonrpc: '2.0',
        id: 1,
        method: 'getLeaderSchedule',
        "params": [
            null,
            {
              "commitment": "processed",
              "identity": "dv2eQHeP4RFrJZ6UeiZWoc3XTtmtZCUKxxCApCDcRNV"
            }
          ]
      }),
    });

    const data = await response.json();
    
    // Print the exact full response
    console.log('Full RPC Response:');
    console.log(JSON.stringify(data, null, 2));
    
    return data;
  } catch (error) {
    console.error('Error getting health:', error.message);
    return null;
  }
}

// Example usage
const RPC_URL = 'https://rpc.coinvera.io/?x-api-key=your-coinvera-x-api-key';

getLeaderSchedule(RPC_URL);

Example Response

{
  "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
}

🛠 Developer Tips

  • Epoch Calculation: Use getEpochInfo to determine the exact start and end slots for a given epoch.

  • Unavailable Data: If requesting a future epoch, the method may return null until the leader schedule is computed.

  • Relative Indexing: Slot numbers in the response are relative to the epoch’s start—not global slot numbers.

  • Large Payloads: Without an identity filter, responses can be large, especially on Mainnet with many active validators.


This guide equips you to effectively use getLeaderSchedule to explore validator assignments and strengthen your interaction with the Solana cluster’s consensus mechanism.

Last updated