Blocks & Slots
getBlockHeight
Returns the current block height of the node
Parameters
Configuration object containing the following optional fields:
Response
Current block height
Code Examples
Basic Request
Request with Commitment
Using web3.js
Notes
- Block height increases monotonically with each new block
- Block height may be different from slot number due to skipped slots
- Different nodes may return slightly different heights based on their view of the network
- The response is immediate as it reads from the current state
Best Practices
- Use appropriate commitment level based on your needs:
processed
for latest possible heightconfirmed
for high probability finalityfinalized
for guaranteed finality
- Consider using
getSlot
if you need slot numbers instead of block height - For historical queries, use
getBlock
with specific slots
Common Errors
Code | Message | Solution |
---|---|---|
-32601 | Method not found | Verify you’re connected to a Solana RPC node |
-32007 | Block height not available | Node may be bootstrapping or syncing |