Blocks & Slots
getBlocksWithLimit
Returns a list of confirmed blocks starting at the given slot
Parameters
Start slot (inclusive)
Maximum number of blocks to return
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 starting from the specified slot
- Results are returned in ascending order
- The limit controls the maximum number of blocks to return
- 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 limit reasonable to avoid timeouts
- Use this method for pagination instead of
getBlocks
- Cache results when appropriate to reduce RPC load
- Handle skipped slots in your application logic
Common Errors
Code | Message | Solution |
---|---|---|
-32602 | Invalid param: limit must be positive | Ensure limit is greater than 0 |
-32602 | Invalid param: limit too large | Reduce the limit size |
-32601 | Method not found | Verify you’re connected to a Solana RPC node |
-32007 | Block information unavailable | Node may be bootstrapping or slot is too old |
Use Cases
-
Block Pagination
-
Recent Block History
-
Block Streaming