Parameters

config
object

Configuration object containing the following optional fields:

Response

result
number

Current block height

Code Examples

Basic Request

curl https://rpc.orbitflare.com -X POST -H "Content-Type: application/json" -d '{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "getBlockHeight"
}'

Request with Commitment

curl https://rpc.orbitflare.com -X POST -H "Content-Type: application/json" -d '{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "getBlockHeight",
  "params": [
    {
      "commitment": "finalized"
    }
  ]
}'

Using web3.js

import { Connection } from '@solana/web3.js';

const connection = new Connection('https://rpc.orbitflare.com');

const blockHeight = await connection.getBlockHeight('finalized');
console.log(`Current block height: ${blockHeight}`);

Notes

  1. Block height increases monotonically with each new block
  2. Block height may be different from slot number due to skipped slots
  3. Different nodes may return slightly different heights based on their view of the network
  4. The response is immediate as it reads from the current state

Best Practices

  1. Use appropriate commitment level based on your needs:
    • processed for latest possible height
    • confirmed for high probability finality
    • finalized for guaranteed finality
  2. Consider using getSlot if you need slot numbers instead of block height
  3. For historical queries, use getBlock with specific slots

Common Errors

CodeMessageSolution
-32601Method not foundVerify you’re connected to a Solana RPC node
-32007Block height not availableNode may be bootstrapping or syncing