Parameters

This method does not accept any parameters.

Response

result
number

The lowest slot that the node has information about in its ledger

Code Examples

Basic Request

curl https://rpc.orbitflare.com -X POST -H "Content-Type: application/json" -d '{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "minimumLedgerSlot"
}'

Using web3.js

import { Connection } from '@solana/web3.js';

const connection = new Connection('https://rpc.orbitflare.com');

// Get minimum ledger slot
const minSlot = await connection.minimumLedgerSlot();
console.log('Minimum ledger slot:', minSlot);

// Get minimum ledger slot with analysis
async function getMinimumLedgerSlotWithAnalysis() {
  const minSlot = await connection.minimumLedgerSlot();
  const currentSlot = await connection.getSlot();
  
  return {
    slots: {
      minimum: minSlot,
      current: currentSlot,
      difference: currentSlot - minSlot
    },
    metadata: {
      timestamp: Date.now()
    }
  };
}

Notes

  1. Returns the lowest slot in the node’s ledger
  2. The response is immediate as it reads from the current state
  3. The minimum slot can change as the ledger is pruned
  4. Slots below this value are not accessible
  5. The value may vary between nodes based on their configuration

Best Practices

  1. Use this method to determine ledger boundaries
  2. Cache results when appropriate to reduce RPC load
  3. Monitor for changes in minimum slot
  4. Consider using websocket subscription for real-time updates
  5. Handle network errors and retry when appropriate

Common Errors

CodeMessageSolution
-32601Method not foundVerify you’re connected to a Solana RPC node
-32603Internal errorNode may be bootstrapping or syncing

Use Cases

  1. Ledger Analysis

    interface LedgerAnalysis {
      slots: {
        minimum: number;
        current: number;
        difference: number;
      };
      metrics: {
        pruningRate: number;
        retentionPeriod: number;
      };
      metadata: {
        timestamp: number;
      };
    }
    
    class LedgerAnalyzer {
      private readonly slotsPerSecond = 2; // Solana's target slots per second
      
      async analyzeLedger(): Promise<LedgerAnalysis> {
        const minSlot = await connection.minimumLedgerSlot();
        const currentSlot = await connection.getSlot();
        const difference = currentSlot - minSlot;
        
        return {
          slots: {
            minimum: minSlot,
            current: currentSlot,
            difference
          },
          metrics: {
            pruningRate: difference / this.slotsPerSecond, // seconds
            retentionPeriod: difference / (this.slotsPerSecond * 3600) // hours
          },
          metadata: {
            timestamp: Date.now()
          }
        };
      }
    }
    
  2. Ledger Monitoring

    interface LedgerStatus {
      slots: {
        minimum: number;
        previous: number;
        difference: number;
      };
      history: Array<{
        timestamp: number;
        minimum: number;
      }>;
    }
    
    class LedgerMonitor {
      private previousMinSlot: number | null = null;
      private history: Array<{
        timestamp: number;
        minimum: number;
      }> = [];
      
      async monitorLedger(): Promise<LedgerStatus | null> {
        const minSlot = await connection.minimumLedgerSlot();
        const now = Date.now();
        
        this.history.push({
          timestamp: now,
          minimum: minSlot
        });
        
        if (this.previousMinSlot === null) {
          this.previousMinSlot = minSlot;
          return null;
        }
        
        const status: LedgerStatus = {
          slots: {
            minimum: minSlot,
            previous: this.previousMinSlot,
            difference: minSlot - this.previousMinSlot
          },
          history: this.history
        };
        
        this.previousMinSlot = minSlot;
        return status;
      }
    }
    
  3. Ledger Planning

    interface LedgerPlan {
      slots: {
        minimum: number;
        current: number;
        difference: number;
      };
      recommendations: Array<{
        type: 'fetch' | 'wait' | 'error';
        reason: string;
      }>;
      metadata: {
        timestamp: number;
      };
    }
    
    class LedgerPlanner {
      private readonly maxSlotRange = 1000000; // Maximum slots to search
      
      async planLedgerOperation(
        targetSlot: number
      ): Promise<LedgerPlan> {
        const minSlot = await connection.minimumLedgerSlot();
        const currentSlot = await connection.getSlot();
        const now = Date.now();
        
        const recommendations: Array<{
          type: 'fetch' | 'wait' | 'error';
          reason: string;
        }> = [];
        
        if (targetSlot < minSlot) {
          recommendations.push({
            type: 'error',
            reason: `Target slot ${targetSlot} is below minimum ledger slot ${minSlot}`
          });
        } else if (targetSlot > currentSlot) {
          recommendations.push({
            type: 'wait',
            reason: `Target slot ${targetSlot} has not been reached yet`
          });
        } else if (currentSlot - targetSlot > this.maxSlotRange) {
          recommendations.push({
            type: 'error',
            reason: `Target slot ${targetSlot} is too far in the past`
          });
        } else {
          recommendations.push({
            type: 'fetch',
            reason: 'Target slot is within valid range'
          });
        }
        
        return {
          slots: {
            minimum: minSlot,
            current: currentSlot,
            difference: currentSlot - minSlot
          },
          recommendations,
          metadata: {
            timestamp: now
          }
        };
      }
    }