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

# getBlocks

> İki slot arasındaki onaylanmış blokların listesini döndürür

## Parametreler

<ParamField query="startSlot" type="number" required>
  Başlangıç slotu (dahil)
</ParamField>

<ParamField query="endSlot" type="number" required>
  Bitiş slotu (dahil)
</ParamField>

<ParamField query="config" type="object" optional>
  Aşağıdaki isteğe bağlı alanları içeren yapılandırma nesnesi:

  <Expandable title="config fields">
    <ParamField query="commitment" type="string" optional>
      Kullanılacak onay seviyesi:

      * `processed`: En son blok (onaylanmamış)
      * `confirmed`: Süper çoğunluk tarafından onaylanmış
      * `finalized`: Süper çoğunluk tarafından sonuçlandırılmış
    </ParamField>
  </Expandable>
</ParamField>

## Yanıt

<ResponseField name="result" type="array">
  Artan sırayla blok slotları dizisi
</ResponseField>

## Kod Örnekleri

### Temel İstek

```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": "getBlocks",
  "params": [
    100000000,
    100000100
  ]
}'
```

### Onay Seviyesiyle İstek

```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": "getBlocks",
  "params": [
    100000000,
    100000100,
    {
      "commitment": "finalized"
    }
  ]
}'
```

### web3.js Kullanımı

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

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

// Get blocks in range
const blocks = await connection.getBlocks(100000000, 100000100);
console.log('Blocks:', blocks);

// Get finalized blocks
const finalizedBlocks = await connection.getBlocks(100000000, 100000100, 'finalized');
console.log('Finalized blocks:', finalizedBlocks);
```

## Notlar

1. Belirtilen slotlar arasındaki onaylanmış blokları döndürür
2. Sonuçlar artan sırayla döndürülür
3. Aralık hem başlangıç hem de bitiş slotlarını kapsar
4. Bazı slotlar atlanmış olabilir (blok üretilmemiş)
5. Mevcut durumdan okuduğu için yanıt anında gelir

## En İyi Uygulamalar

1. İhtiyacınıza göre uygun onay seviyesini kullanın:
   * En son bloklar için `processed`
   * Yüksek olasılıklı kesinlik için `confirmed`
   * Garantili kesinlik için `finalized`
2. Zaman aşımını önlemek için slot aralığını makul tutun
3. Sayfalama için `getBlocksWithLimit` kullanmayı düşünün
4. RPC yükünü azaltmak için uygun durumlarda sonuçları önbelleğe alın
5. Uygulama mantığınızda atlanan slotları yönetin

## Yaygın Hatalar

| Kod    | Mesaj                                              | Çözüm                                               |
| ------ | -------------------------------------------------- | --------------------------------------------------- |
| -32602 | Invalid param: startSlot must be less than endSlot | startSlot'un endSlot'tan küçük olduğundan emin olun |
| -32602 | Invalid param: slot range too large                | Slot aralığı boyutunu küçültün                      |
| -32601 | Method not found                                   | Bir Solana RPC düğümüne bağlı olduğunuzu doğrulayın |
| -32007 | Block information unavailable                      | Düğüm başlatılıyor veya aralık çok eski olabilir    |

## Kullanım Senaryoları

1. **Blok Aralığı Analizi**
   ```typescript theme={null}
   async function analyzeBlockRange(startSlot: number, endSlot: number) {
     const blocks = await connection.getBlocks(startSlot, endSlot);
     const totalSlots = endSlot - startSlot + 1;
     const skippedSlots = totalSlots - blocks.length;
     
     console.log(`Total slots: ${totalSlots}`);
     console.log(`Blocks produced: ${blocks.length}`);
     console.log(`Skipped slots: ${skippedSlots}`);
     console.log(`Block production rate: ${(blocks.length / totalSlots) * 100}%`);
   }
   ```

2. **Blok Geçmişi Takibi**
   ```typescript theme={null}
   interface BlockHistory {
     startSlot: number;
     endSlot: number;
     blocks: number[];
     timestamp: Date;
   }

   async function trackBlockHistory(startSlot: number, endSlot: number) {
     const blocks = await connection.getBlocks(startSlot, endSlot);
     const history: BlockHistory = {
       startSlot,
       endSlot,
       blocks,
       timestamp: new Date()
     };
     
     storeBlockHistory(history);
     return history;
   }
   ```

3. **Blok Boşluğu Tespiti**
   ```typescript theme={null}
   async function detectBlockGaps(startSlot: number, endSlot: number) {
     const blocks = await connection.getBlocks(startSlot, endSlot);
     const gaps = [];
     
     for (let i = 0; i < blocks.length - 1; i++) {
       const current = blocks[i];
       const next = blocks[i + 1];
       if (next - current > 1) {
         gaps.push({
           start: current + 1,
           end: next - 1,
           length: next - current - 1
         });
       }
     }
     
     return gaps;
   }
   ```
