>

>

1. The Anatomy of a Transaction

Reading the Ledger

Every dApp eventually needs to know what happened on-chain. Whether it’s tracking a payment or confirming a smart contract call, reading transactions is key!

In VeChainThor, a transaction is a request to change the state of the blockchain. Think of it as sending a set of instructions to the network.

But here is the cool part: VeChain allows multi-clause structures.

Imagine sending one envelope that contains three different letters to three different people. That is a multi-clause transaction! It lets you perform multiple operations (like transferring VET to different people) in one go.

When you look at the data, you’ll see two main parts:

  1. The Transaction Object: This shows the intent (what was sent).

  2. The Transaction Receipt: This shows the result (what actually happened).

Nice! To see this in action, we use the ThorClient. In JavaScript, this means connecting to a node (like the Testnet) and asking for a specific ID.

import { ThorClient } from '@vechain/sdk-network';
const thor = ThorClient.at('https://testnet.vechain.org');
const txId = '0xfbcb2591...'; // A unique hash
// 1. Check the intent
const tx = await thor.transactions.getTransaction(txId);
// 2. Check the result
const txReceipt = await thor.transactions.getTransactionReceipt(txId);
import { ThorClient } from '@vechain/sdk-network';
const thor = ThorClient.at('https://testnet.vechain.org');
const txId = '0xfbcb2591...'; // A unique hash
// 1. Check the intent
const tx = await thor.transactions.getTransaction(txId);
// 2. Check the result
const txReceipt = await thor.transactions.getTransactionReceipt(txId);
import { ThorClient } from '@vechain/sdk-network';
const thor = ThorClient.at('https://testnet.vechain.org');
const txId = '0xfbcb2591...'; // A unique hash
// 1. Check the intent
const tx = await thor.transactions.getTransaction(txId);
// 2. Check the result
const txReceipt = await thor.transactions.getTransactionReceipt(txId);

Almost there! The receipt will tell you if the transaction was reverted (failed) or if it successfully emitted outputs like logs and events.


Technical Note: Transactions are state-change requests; Receipts are the results of those requests. VeChainThor’s multi-clause feature allows for efficient bundling of operations.
Don't forget to check the getTransactionReceipt! A transaction might be "confirmed" in a block but still be reverted (failed) internally.