getEpochSchedule

Learn getEpochSchedule use cases, code examples, request parameters, response structure, and tips.

The getEpochSchedule RPC method returns information about the epoch schedule configuration from the cluster’s genesis settings. It outlines how epochs are structured, including slot counts and leader scheduling mechanics. This data is essential for aligning application logic with Solana’s timing model.


✅ Common Use Cases

  • Predict Epoch Boundaries Determine the number of slots in an epoch to estimate how soon the current epoch will end and when the next will begin.

  • Understand Leader Schedule Offsets Retrieve the leaderScheduleSlotOffset to know how far in advance validator leader schedules are generated.

  • Analyze Network Initialization Identify whether the network used a warmup phase, and if so, when full-length epochs began (via firstNormalEpoch and firstNormalSlot).

  • Build Monitoring and Analytics Tools Use epoch timing details to visualize epoch transitions and validate synchronization behaviors across clusters.


🛠 Request Parameters

This method does not require any parameters.


📦 Response Structure

The response object contains the following fields:

Field
Type
Description

slotsPerEpoch

u64

Number of slots in a full epoch (post-warmup).

leaderScheduleSlotOffset

u64

Number of slots before an epoch when its leader schedule is generated.

warmup

bool

true if the cluster had shorter initial epochs that ramped up gradually.

firstNormalEpoch

u64

First epoch with full-length slots (slotsPerEpoch).

firstNormalSlot

u64

The slot at which firstNormalEpoch begins.


💡 Example: Get Epoch Schedule

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "getEpochSchedule"
}

Code Examples

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

async function getEpochSchedule(rpcUrl) {
  try {
    const response = await fetch(rpcUrl, {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
      },
      body: JSON.stringify({
        jsonrpc: '2.0',
        id: 1,
        method: 'getEpochSchedule'
      }),
    });

    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';

getEpochSchedule(RPC_URL);

Example Response

{
  "jsonrpc": "2.0",
  "result": {
    "firstNormalEpoch": 0,
    "firstNormalSlot": 0,
    "leaderScheduleSlotOffset": 432000,
    "slotsPerEpoch": 432000,
    "warmup": false
  },
  "id": 1
}

🧠 Developer Tips

  • Epoch Schedule Is Static This data comes from the cluster’s genesis configuration and typically does not change unless there’s a protocol upgrade or network reset.

  • Cluster-Specific Behavior Parameters like slotsPerEpoch and warmup vary between Mainnet, Testnet, and Devnet. Always query the correct environment.

  • Warmup Epoch Calculations If warmup is true, early epochs use exponentially increasing lengths:

    iniCopyEditslots = 2^N * MINIMUM_SLOTS_PER_EPOCH

    where N is the epoch index, starting from 0. MINIMUM_SLOTS_PER_EPOCH is usually 32.

  • Use for Time Estimation Combine with getEpochInfo to estimate time remaining in the current epoch or project when epoch transitions will occur.

Last updated