queryNetwork/blockHeight
Query the current blockchain height
Query the current block height of the Cardano blockchain. This returns the absolute block number since genesis.
Request
{
"jsonrpc": "2.0",
"method": "queryNetwork/blockHeight"
}No parameters required.
Loading...
Response
{
"jsonrpc": "2.0",
"method": "queryNetwork/blockHeight",
"result": 10234567
}Response Fields
| Field | Type | Description |
|---|---|---|
result | number | Current block height (blocks since genesis) |
Code Examples
async function getBlockHeight() {
const response = await fetch('https://api.nacho.builders/v1/ogmios', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'apikey': process.env.NACHO_API_KEY
},
body: JSON.stringify({
jsonrpc: '2.0',
method: 'queryNetwork/blockHeight'
})
});
const { result } = await response.json();
return result;
}
const height = await getBlockHeight();
console.log('Current block height:', height.toLocaleString());Block Height vs Slot Number
| Concept | Description |
|---|---|
| Block Height | Sequential count of blocks (no gaps) |
| Slot Number | Time slots (many are empty, no block) |
Slots advance every second, but blocks are only produced when a stake pool is selected as leader (~20 seconds average).
async function getBlockInfo() {
const [height, tip] = await Promise.all([
getBlockHeight(),
getLedgerTip()
]);
const slotUtilization = height / tip.slot;
console.log('Block height:', height);
console.log('Current slot:', tip.slot);
console.log('Slot utilization:', (slotUtilization * 100).toFixed(2), '%');
}Block height is useful for tracking chain progress, while slot numbers are used for time-based operations like transaction TTL.
Use Cases
- Sync monitoring - Track node synchronization progress
- Block explorers - Display current chain height
- Analytics - Calculate block production statistics
- Health checks - Verify node is receiving new blocks
Full Ogmios API Reference
Was this page helpful?