getBlockHeight
Last updated:
`getBlockHeight` returns the current block height as a `u64` integer. The block height is the count of **confirmed blocks** below the current block — it increments by one for every block that is actually produced.
Use it when you need a monotonic, gap-free measure of chain progress. A common use is to compare a transaction's `lastValidBlockHeight` against the current height to decide whether the transaction's blockhash has expired.
**Distinguish from `getSlot`:** block height counts only the blocks that were produced, while a slot is a fixed ~400 ms time unit that advances even when its leader skips block production. Because skipped slots increment the slot but not the block height, the slot value is always **greater than or equal to** the block height.
All Solana JSON-RPC methods POST to the same base path `/v1/sol`; the `method` field in the request body selects the call.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| config | CommitmentConfig | No |
Returns
| Field | Type |
|---|---|
| result | integer |
Examples
curl https://<your-endpoint>/ \
-X POST -H 'Content-Type: application/json' \
-d '{"jsonrpc":"2.0","id":1,"method":"getBlockHeight","params":[]}'const res = await fetch("https://<your-endpoint>/", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
"id": 1,
"method": "getBlockHeight",
"params": [],
"jsonrpc": "2.0"
}),
});
const data = await res.json();import requests
resp = requests.post("https://<your-endpoint>/", json={"id":1,"method":"getBlockHeight","params":[],"jsonrpc":"2.0"})
print(resp.json()){
"id": 1,
"result": 405776334,
"jsonrpc": "2.0"
}Usage
- Transport: HTTP (JSON-RPC).
- Networks: mainnet, devnet, testnet.
- Credit cost: 1 per call.
FAQ
- What does getBlockHeight do?
- Returns the current block height of the node — the number of confirmed blocks beneath the latest confirmed block.
- How many credits does getBlockHeight cost?
- getBlockHeight costs 1 credit(s) per call on Triport by default.
- Is getBlockHeight available over WebSocket?
- getBlockHeight is an HTTP JSON-RPC method.