Blocks & Slots
getSlot
Returns the current slot of the node
Parameters
Response
Current slot number
Code Examples
Basic Request
Request with Commitment
Using web3.js
Notes
- Returns the current slot of the node
- The slot number increases as new blocks are produced
- Different commitment levels can be specified
- The response is immediate as it reads from the current state
- The slot number is used for various time-based operations
Best Practices
- Cache the slot number when appropriate
- Consider using websocket subscription for real-time updates
- Handle network errors and retry when appropriate
- Use appropriate commitment level based on your needs
- Monitor slot progression for time-sensitive operations
Common Errors
Code | Message | Solution |
---|---|---|
-32601 | Method not found | Verify you’re connected to a Solana RPC node |
-32602 | Invalid params | Check config parameters |
-32007 | Slot information unavailable | Node may be bootstrapping or syncing |
Use Cases
-
Slot Monitoring
-
Slot Analysis
-
Slot Synchronization