getBlocks
Learn getBlocks use cases, code examples, request parameters, response structure, and tips.
The getBlocks RPC method returns a list of confirmed block slot numbers between a specified start_slot and an optional end_slot. It’s useful when you need to know which blocks were confirmed within a certain range—without fetching full block contents.
✅ Common Use Cases
Identify Confirmed Blocks in a Range Quickly fetch all block slots that were successfully confirmed between two slots.
Iterate Over Confirmed Slots Use the list of confirmed slots to loop through and fetch detailed block data later via
getBlock.Audit Block Presence Verify whether blocks exist across a specific slot range for basic validation or reporting.
🛠 Request Parameters
getBlocks accepts the following parameters:
start_slot(u64, required): The first slot of the range (inclusive).end_slot(u64, optional): The last slot of the range (inclusive). If omitted, the method will return confirmed blocks up to the latest available slot. ⚠️ The range betweenstart_slotandend_slotmust not exceed 500,000 slots.commitment(string, optional): Commitment level passed as a field in a config object. If omitted, the node's default is used. Typical values:processedconfirmedfinalized
📦 Response Structure
The result field will be an array of slot numbers (as unsigned 64-bit integers), each representing a confirmed block.
This means blocks were confirmed at these slots—note that some slots may be skipped (e.g., 355104004).
💡 Examples
1. Get Confirmed Blocks in a Slot Range
Get Blocks from Start Slot to Latest Confirmed Slot
Get Blocks Using a Specific Commitment Level
Code Examples
Example Response
🧠 Developer Tips
Range Limit Enforcement The maximum allowed range is 500,000 slots. Splitting larger ranges into chunks is required for historical scans.
Ledger Retention Differences Very old slot data may not be available on all RPC nodes. Empty arrays or errors might be returned for out-of-retention queries.
Consistency with Commitment Block confirmation status can vary depending on the
commitmentlevel and the specific RPC node queried—especially for recent slots.Use as a Prefilter for
getBlockgetBlocksis often used to determine which blocks exist before making multiple calls togetBlockfor deeper inspection.Effective Pagination Strategy For scanning long history segments, implement pagination by dividing your range into multiple sub-ranges of 500,000 slots or fewer.
Last updated