Developer Fundamentals
-- I. Read Blocks
Learn how to retrieve and interpret block data on VeChainThor using compressed and expanded methods to support real-time blockchain interactions in your app.
Understanding Blocks on VeChainThor
Now that you understand VeChainThor fundamentals and how to connect, it's time to explore how to retrieve and interpret onchain data. This chapter focuses on accessing blocks, transactions, accounts, and contract states to power your applications with real-time blockchain insights.
A block is a change to the blockchain storage with a batch of changes that happen simultaneously. With VeChain, a new block is generated approximately every 10 seconds, even if no transactions have been published.
The most relevant information for interacting with blocks includes:
number: the number of the block
id: a unique ID representing the block
parentID: the previous block that the block is based on
timestamp: the Unix time at which the block was stored
isFinalized: is the block securely finalized in a snapshot
transactions: contains either all transaction IDs or full transaction details, including receipts
A block can be requested by its number, ID, or, additionally, the reserved words "best" and "finalized" reference the latest or epoch-ending blocks.
Test It Yourself
The snippet below shows how you can make a request to the blockchain and receive a compressed and expanded response (you'll learn more about the response types later in this lesson):
There are two methods to obtain block details:
The compressed version includes all data and only the transaction IDs.
The expanded version also encompasses full transaction details along with the generated outputs.
The JSON-API formats below represent both types of responses:
Compressed response – Provides a minimal set of block details.
The expanded response also returns the full details of each transaction in the block.
There are specific keywords associated with special blocks:
Genesis – refers to the initial block (number 0) on a chain, serving to identify the available chain on a network.
Best – represents the most recent block, typically having a maximum age of 10 seconds, as a new block is added every 10 seconds.
Final – denotes the most recent finalized block, marking the end of an epoch. It is guaranteed that there will be no further re-ordering or changes. A checkpoint happens every 180 blocks, and the finalization of a checkpointed block occurs again after 180 blocks.
Join our Telegram