Reading and Listening to Transactions on VeChainThor
Blockchain applications often need to answer two simple questions: what happened, and when? Whether you're building dashboards, smart contract backends, or user wallets, getting transaction data is critical.
This guide walks you through two essential ways to work with transaction data on VeChainThor:
Reading transactions to inspect on-chain history
Listening for transactions in real time to power reactive applications
Let’s break down how each works, when to use them, and how to get started.
What Is a Transaction on VeChain?
A transaction on VeChainThor represents a request to make a change on the blockchain. This can be:
A simple VET transfer
A contract deployment
A function call to an existing smart contract
Each transaction can include multiple instructions (known as clauses), meaning a single transaction can interact with multiple recipients.
Key fields to understand:
id: The unique hash of the transaction
chainTag: Identifier of the blockchain network
blockRef: The block this transaction references
expiration: Number of blocks until the transaction becomes invalid
dependsOn: If present, the transaction ID this one depends on
origin: The address that initiated the transaction
meta: Block-level info, including timestamp and block number
reverted: Whether the transaction was reverted (failed)
clauses: List of instructions and data sent
outputs: All events or VET transfers triggered by the clauses
Full Transaction Details
When reading a transaction, there are two key components:
Transaction Object: Contains input data and metadata
Transaction Receipt: Contains results of execution, including:
Events emitted
VET transfers
Deployed contract addresses
Whether the transaction reverted
Code Example: Reading a Transaction
Listening Instead of Reading
While reading transactions gives you access to past and static data, sometimes you need to respond to blockchain activity as it happens. For example, tracking token movements in real time. That’s where listening comes in.
VeChain offers a native WebSocket-based system for subscribing to VET transfers.
You can connect to a node and subscribe to live VET transfer events like this:
This will return every VET transfer on the network as a JSON string.
To narrow your stream and only receive transfers relevant to your dApp, use the SDK’s helper:
Each message includes:
You can decode the amount like this:
This is especially useful in dApps that need to track payments or wallet activity in real time.
For more practical examples and testable snippets, explore the full Developer Fundamentals module on the VeChain Builders Academy.
Join our Telegram