Learn getBlocksWithLimit use cases, code examples, request parameters, response structure, and tips.
getBlocksWithLimit
RPC method allows you to retrieve a list of confirmed block slot numbers, starting from a specified slot and returning up to a given limit. This is useful when you need a specific number of subsequent confirmed blocks from a certain point in the ledger.
getBlocksWithLimit
method takes the following parameters:
start_slot
(u64, required): The first slot to consider (inclusive).limit
(u64, required): The maximum number of block slots to return. The total number of slots queried (from start_slot
up to limit
blocks after it) must not exceed 500,000 slots.commitment
(string, optional): Specifies the commitment level for the query. If omitted, the default commitment of the node is used. This is passed as the sole field in a configuration object as the last parameter.result
field of the JSON-RPC response will be an array of u64 integers. Each integer in the array represents a confirmed block slot number, starting from start_slot
up to the specified limit
.
start_slot
is 5 and limit
is 3, a possible result is [5, 6, 7]
.280000000
.
290000000
using the confirmed
commitment level.
limit
parameter dictates the maximum number of block slots to return. The 500,000 slot constraint applies to the conceptual range scanned (i.e., from start_slot
to start_slot + limit - 1
). Ensure this conceptual range doesn’t exceed 500,000 slots, even if fewer actual blocks are found and returned within that range.start_slot
might return fewer blocks than the specified limit
, or an empty array, depending on the node’s ledger retention.commitment
level and which node you query, especially for very recent slots.getBlocksWithLimit
is ideal when you know the starting point and need a fixed number of subsequent blocks. If you need all blocks in a known slot range, getBlocks
might be more appropriate.getBlocksWithLimit
RPC method to list a specific number of confirmed block slots on the Solana network.