>

>

3. Finding Blocks Fast

Shortcuts and Aliases

Sometimes, you don't know the block number. You just want the "latest" one! 🏃‍♂️

VeChainThor uses Reserved Block Aliases to help you find what you need without guessing.

Think of these like "bookmarks" for your blockchain library:

  • "best": Points to the most recent block produced (the one that is ~10 seconds old).

  • "finalized": Points to the latest block that is irreversible and checkpointed by the consensus.

  • "genesis": Points to Block 0— the very first block ever created.

// Grab the pulse of the network right now
const latestBlock = await thor.blocks.getBlockCompressed('best');
// Grab the pulse of the network right now
const latestBlock = await thor.blocks.getBlockCompressed('best');
// Grab the pulse of the network right now
const latestBlock = await thor.blocks.getBlockCompressed('best');

Nice! You're a natural at this.

Using "best" allows your app to stay reactive, while "finalized" ensures the data you are reading can never be changed.