> ## 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

> Возвращает текущий слот узла

## Параметры

<ResponseField name="config" type="object" optional>
  <Expandable title="поля config">
    <ResponseField name="commitment" type="string" optional>
      Уровень commitment (processed, confirmed, finalized)
    </ResponseField>
  </Expandable>
</ResponseField>

## Ответ

<ResponseField name="result" type="number">
  Текущий номер слота
</ResponseField>

## Примеры кода

### Базовый запрос

```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

```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"
    }
  ]
}'
```

### Использование 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()
  };
}
```

## Примечания

1. Возвращает текущий слот узла
2. Номер слота увеличивается по мере производства новых блоков
3. Можно указывать различные уровни commitment
4. Ответ приходит немедленно, поскольку считывается из текущего состояния
5. Номер слота используется для различных операций, основанных на времени

## Лучшие практики

1. Кэшируйте номер слота при необходимости
2. Рассмотрите использование подписки через websocket для обновлений в реальном времени
3. Обрабатывайте сетевые ошибки и повторяйте попытки при необходимости
4. Используйте подходящий уровень commitment в зависимости от ваших потребностей
5. Следите за прогрессией слотов для операций, чувствительных ко времени

## Распространённые ошибки

| Код    | Сообщение                    | Решение                                                   |
| ------ | ---------------------------- | --------------------------------------------------------- |
| -32601 | Method not found             | Убедитесь, что вы подключены к узлу Solana RPC            |
| -32602 | Invalid params               | Проверьте параметры config                                |
| -32007 | Slot information unavailable | Узел может выполнять начальную загрузку или синхронизацию |

## Примеры использования

1. **Мониторинг слотов**
   ```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. **Анализ слотов**
   ```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. **Синхронизация слотов**
   ```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
         }
       };
     }
   }
   ```
