circle-infogetBlocksWithLimit

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

The getBlocksWithLimit RPC method retrieves a list of confirmed block slot numbers, starting from a specified slot and returning up to a defined limit. It’s especially useful when you need a fixed number of confirmed blocks following a known slot, without fetching full block data.


✅ Common Use Cases

  • Fetch a Fixed Number of Blocks Retrieve a specific number of confirmed block slots beginning at a particular start slot.

  • Paginated Block Scanning Process the blockchain in manageable chunks—ideal for block explorers or analytics pipelines.

  • Recent Block Monitoring Quickly get the most recent confirmed blocks following a known anchor slot.


🛠 Request Parameters

getBlocksWithLimit accepts the following arguments:

  • start_slot (u64, required): The first slot to start the query (inclusive).

  • limit (u64, required): The maximum number of block slots to return. ⚠️ The conceptual slot range (start_slot to start_slot + limit - 1) must not exceed 500,000 slots.

  • commitment (string, optional): Commitment level for block confirmation:

    • finalized (default)

    • confirmed

    • processed If provided, this must be wrapped in a configuration object as the last parameter.


📦 Response Structure

The result field contains an array of confirmed block slot numbers, up to the requested limit.

Example:

If start_slot is 355104000and limit is 5, this array represents the confirmed blocks found in that range.

💡 Examples

1. Fetch 5 Confirmed Blocks from a Start Slot

  1. Fetch 3 Confirmed Blocks with a Specific Commitment Level

Code Examples

Example Respose

🧠 Developer Tips

  • Understand Range Constraints The conceptual range scanned is from start_slot to start_slot + limit - 1. This must be ≤ 500,000 slots, regardless of how many actual blocks are returned.

  • Ledger Retention Limits RPC nodes (like CoinVera) may not retain block info for very old slots. If start_slot is too far in the past, the method might return fewer blocks than expected—or none at all.

  • Block Confirmation Levels The blocks returned reflect those confirmed at the specified commitment level. Recently confirmed blocks may vary slightly across nodes and configurations.

  • Choosing the Right Method Use getBlocksWithLimit when you:

    • Know where to start

    • Want a fixed number of results For scanning a known range, use getBlocks instead.

Last updated