> ## Documentation Index
> Fetch the complete documentation index at: https://docs.orbitflare.com/llms.txt
> Use this file to discover all available pages before exploring further.

# getSlot

> Returns the current slot of the node

## Parameters

<ResponseField name="config" type="object" optional>
  <Expandable title="config fields">
    <ResponseField name="commitment" type="string" optional>
      Commitment level (processed, confirmed, finalized)
    </ResponseField>
  </Expandable>
</ResponseField>

## Response

<ResponseField name="result" type="number">
  Current slot number
</ResponseField>

## Code Examples

### Basic Request

```bash theme={null}
curl https://fra.rpc.orbitflare.com?api_key=YOUR-API-KEY -X POST -H "Content-Type: application/json" -d '{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "getSlot",
  "params": []
}'
```

### Request with Commitment

```bash theme={null}
curl https://fra.rpc.orbitflare.com?api_key=YOUR-API-KEY -X POST -H "Content-Type: application/json" -d '{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "getSlot",
  "params": [
    {
      "commitment": "confirmed"
    }
  ]
}'
```

### Using web3.js

```typescript theme={null}
import { Connection } from '@solana/web3.js';

const connection = new Connection('https://fra.rpc.orbitflare.com?api_key=YOUR-API-KEY');

// Get current slot
const slot = await connection.getSlot();
console.log('Current slot:', slot);

// Get slot with commitment
async function getSlotWithCommitment(
  commitment: 'processed' | 'confirmed' | 'finalized' = 'confirmed'
) {
  const slot = await connection.getSlot(commitment);
  return {
    slot,
    commitment,
    timestamp: Date.now()
  };
}
```

## Notes

1. Returns the current slot of the node
2. The slot number increases as new blocks are produced
3. Different commitment levels can be specified
4. The response is immediate as it reads from the current state
5. The slot number is used for various time-based operations

## Best Practices

1. Cache the slot number when appropriate
2. Consider using websocket subscription for real-time updates
3. Handle network errors and retry when appropriate
4. Use appropriate commitment level based on your needs
5. Monitor slot progression for time-sensitive operations

## Common Errors

| Code   | Message                      | Solution                                     |
| ------ | ---------------------------- | -------------------------------------------- |
| -32601 | Method not found             | Verify you're connected to a Solana RPC node |
| -32602 | Invalid params               | Check config parameters                      |
| -32007 | Slot information unavailable | Node may be bootstrapping or syncing         |

## Use Cases

1. **Slot Monitoring**
   ```typescript theme={null}
   interface SlotInfo {
     slot: number;
     commitment: string;
     metadata: {
       timestamp: number;
       previousSlot: number | null;
       slotProgression: number;
     };
   }

   class SlotMonitor {
     private previousSlot: number | null = null;
     
     async monitorSlot(
       commitment: 'processed' | 'confirmed' | 'finalized' = 'confirmed',
       interval: number = 1000
     ): Promise<SlotInfo> {
       const slot = await connection.getSlot(commitment);
       const timestamp = Date.now();
       
       const info: SlotInfo = {
         slot,
         commitment,
         metadata: {
           timestamp,
           previousSlot: this.previousSlot,
           slotProgression: this.previousSlot !== null
             ? slot - this.previousSlot
             : 0
         }
       };
       
       this.previousSlot = slot;
       return info;
     }
   }
   ```

2. **Slot Analysis**
   ```typescript theme={null}
   interface SlotAnalysis {
     currentSlot: number;
     slotProgression: {
       average: number;
       min: number;
       max: number;
       samples: number;
     };
     timeDistribution: {
       slotsPerSecond: number;
       slotsPerMinute: number;
       slotsPerHour: number;
     };
     metadata: {
       startTime: number;
       duration: number;
     };
   }

   async function analyzeSlots(
     commitment: 'processed' | 'confirmed' | 'finalized' = 'confirmed',
     duration: number = 60000
   ): Promise<SlotAnalysis> {
     const startTime = Date.now();
     const startSlot = await connection.getSlot(commitment);
     const progressions: number[] = [];
     let previousSlot = startSlot;
     
     while (Date.now() - startTime < duration) {
       const currentSlot = await connection.getSlot(commitment);
       progressions.push(currentSlot - previousSlot);
       previousSlot = currentSlot;
       await new Promise(resolve => setTimeout(resolve, 1000));
     }
     
     const totalProgression = progressions.reduce((sum, p) => sum + p, 0);
     const durationSeconds = (Date.now() - startTime) / 1000;
     
     return {
       currentSlot: previousSlot,
       slotProgression: {
         average: totalProgression / progressions.length,
         min: Math.min(...progressions),
         max: Math.max(...progressions),
         samples: progressions.length
       },
       timeDistribution: {
         slotsPerSecond: totalProgression / durationSeconds,
         slotsPerMinute: (totalProgression / durationSeconds) * 60,
         slotsPerHour: (totalProgression / durationSeconds) * 3600
       },
       metadata: {
         startTime,
         duration: Date.now() - startTime
       }
     };
   }
   ```

3. **Slot Synchronization**
   ```typescript theme={null}
   interface SlotSync {
     currentSlot: number;
     targetSlot: number;
     difference: number;
     estimatedTime: number;
     metadata: {
       timestamp: number;
       commitment: string;
     };
   }

   class SlotSynchronizer {
     private readonly targetSlotsPerSecond = 2; // Solana's target slot rate
     
     async checkSynchronization(
       commitment: 'processed' | 'confirmed' | 'finalized' = 'confirmed'
     ): Promise<SlotSync> {
       const currentSlot = await connection.getSlot(commitment);
       const targetSlot = Math.floor(
         (Date.now() / 1000) * this.targetSlotsPerSecond
       );
       
       return {
         currentSlot,
         targetSlot,
         difference: currentSlot - targetSlot,
         estimatedTime: Math.abs(currentSlot - targetSlot) / this.targetSlotsPerSecond,
         metadata: {
           timestamp: Date.now(),
           commitment
         }
       };
     }
   }
   ```
