queryNetwork/tip

Query the network layer's current tip

Query the current tip from the network layer. This returns the latest block known to the network, including additional metadata about the node's sync status.

Request

{
  "jsonrpc": "2.0",
  "method": "queryNetwork/tip"
}

No parameters required.

Loading...

Response

{
  "jsonrpc": "2.0",
  "method": "queryNetwork/tip",
  "result": {
    "slot": 123456789,
    "id": "8e8c93fb4a7c7e5a1a3e5f9b2c4d6e8f0a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d",
    "height": 10234567
  }
}

Response Fields

FieldTypeDescription
slotnumberCurrent slot number
idstringBlock hash (64 hex characters)
heightnumberBlock height (blocks since genesis)

Code Examples

async function getNetworkTip() {
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/tip'
  })
});

const { result } = await response.json();
return result;
}

const tip = await getNetworkTip();
console.log('Slot:', tip.slot);
console.log('Height:', tip.height);
console.log('Block ID:', tip.id);

Comparing Tip Queries

QueryReturnsUse Case
queryNetwork/tipNetwork layer tip with heightGeneral purpose, includes block height
queryLedgerState/tipLedger state tipLedger queries, state calculations

The network tip may be slightly ahead of the ledger tip during block processing.

Sync Status Check

async function checkSyncStatus() {
  const tip = await getNetworkTip();

  // Calculate expected slot based on current time
  const SHELLEY_START_SLOT = 4492800;
  const SHELLEY_START_TIME = new Date('2020-07-29T21:44:51Z').getTime();
  const now = Date.now();

  const expectedSlot = SHELLEY_START_SLOT + Math.floor((now - SHELLEY_START_TIME) / 1000);
  const slotDiff = expectedSlot - tip.slot;

  if (slotDiff < 100) {
    console.log('Node is fully synced');
  } else if (slotDiff < 7200) {
    console.log(`Node is ${slotDiff} slots behind (~${Math.round(slotDiff / 60)} minutes)`);
  } else {
    console.log(`Node is syncing: ${slotDiff} slots behind`);
  }

  return {
    currentSlot: tip.slot,
    expectedSlot,
    slotsBehind: slotDiff,
    height: tip.height
  };
}

For chain synchronization and real-time block monitoring, use WebSocket connections with findIntersection and nextBlock instead of polling the tip.

Use Cases

  • Health monitoring - Check if node is synced
  • Dashboard displays - Show current blockchain stats
  • TTL calculation - Determine transaction expiry slots
  • Epoch tracking - Calculate current epoch from slot

Full Ogmios API Reference

Was this page helpful?