Blocks & Slots
getBlocks
Returns a list of confirmed blocks between two slots
Parameters
Start slot (inclusive)
End slot (inclusive)
Configuration object containing the following optional fields:
Response
Array of block slots in ascending order
Code Examples
Basic Request
Request with Commitment
Using web3.js
Notes
- Returns confirmed blocks between the specified slots
- Results are returned in ascending order
- The range is inclusive of both start and end slots
- Some slots may be skipped (no block produced)
- The response is immediate as it reads from the current state
Best Practices
- Use appropriate commitment level based on your needs:
processed
for latest blocksconfirmed
for high probability finalityfinalized
for guaranteed finality
- Keep the slot range reasonable to avoid timeouts
- Consider using
getBlocksWithLimit
for pagination - Cache results when appropriate to reduce RPC load
- Handle skipped slots in your application logic
Common Errors
Code | Message | Solution |
---|---|---|
-32602 | Invalid param: startSlot must be less than endSlot | Ensure startSlot is less than endSlot |
-32602 | Invalid param: slot range too large | Reduce the slot range size |
-32601 | Method not found | Verify you’re connected to a Solana RPC node |
-32007 | Block information unavailable | Node may be bootstrapping or range is too old |
Use Cases
-
Block Range Analysis
-
Block History Tracking
-
Block Gap Detection