getBlocks — Solana RPC Method
getBlocks returns a list of slot numbers that contain confirmed blocks within a given range. Skipped slots are excluded from the result. This is the standard way to discover which slots in a range actually produced blocks.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
start_slot | u64 | Yes | Start slot, inclusive. |
end_slot | u64 | No | End slot, inclusive. Must be within 500,000 slots of start_slot. If omitted, defaults to the highest confirmed slot. |
commitment | string | No | confirmed or finalized. processed is not supported. Default: finalized. |
Request
curl -X POST https://api.mainnet-beta.solana.com \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "getBlocks",
"params": [311857920, 311857930]
}'
TypeScript (@solana/kit)
import { createSolanaRpc } from "@solana/kit";
const rpc = createSolanaRpc("https://api.mainnet-beta.solana.com");
const blocks = await rpc
.getBlocks(311857920n, 311857930n)
.send();
console.log(`Blocks found: ${blocks.length}`);
// e.g. [311857920, 311857921, 311857923, 311857924, ...]
Response
{
"jsonrpc": "2.0",
"result": [
311857920, 311857921, 311857923, 311857924,
311857925, 311857926, 311857927, 311857929, 311857930
],
"id": 1
}
| Field | Type | Description |
|---|---|---|
result | u64[] | Array of slot numbers that contain confirmed blocks. Skipped slots are not included. |
In this example, slots 311857922 and 311857928 were skipped — no block was produced in those slots.
Common errors
- Range too large —
end_slotmust be within 500,000 slots ofstart_slot. Exceeding this limit returns an error. - Slots too old — if the requested range is older than the node’s available ledger data, the result may be empty or incomplete.
- processed not supported — using
commitment: "processed"returns an error. Useconfirmedorfinalized.
Performance
The response size depends on the range and the skip rate. A 500,000-slot range at a ~5% skip rate returns approximately 475,000 slot numbers. For large ranges, consider using getBlocksWithLimit to paginate results. The 500,000-slot cap (approximately 2.3 days at 400ms slots) exists to prevent excessive load on the node.
FAQ
What is the maximum range I can query? 500,000 slots, which is approximately 2.3 days of Solana time at 400ms per slot.
Why are some slots missing from the result? Missing slots are skipped slots — no validator produced a block in that slot. This is normal; Solana’s skip rate is typically 3-8% on mainnet.
How do I scan the entire ledger?
Paginate using 500,000-slot windows. Set start_slot to the end of the previous range + 1 and call again. Alternatively, use getBlocksWithLimit which returns a fixed number of results starting from a given slot.
What is the difference between getBlocks and getBlocksWithLimit?
getBlocks takes a start and end slot. getBlocksWithLimit takes a start slot and a count of how many blocks to return. Use getBlocksWithLimit when you want a fixed page size rather than a fixed slot range.
Does this method return the block data?
No. getBlocks returns only slot numbers. To get the actual block contents, call getBlock for each slot.
Parameters
| Parameter | Type | Required | Description | Default |
|---|---|---|---|---|
start_slot | u64 | Yes | Start slot (inclusive). | — |
end_slot | u64 | No | End slot (inclusive). Must be no more than 500,000 slots higher than start_slot. | — |
commitment | string | No | confirmed or finalized. processed is not supported. | finalized |
Updated: