>

>

1. Where do Events Live?

The Anatomy of an Event

Every time a smart contract does something important, it "emits" an event. But where does that data go? 🕵️‍♂️

Think of a Transaction Object as the envelope you sent. It shows your intent.

But the Transaction Receipt is the official record of what actually happened. This is where the events live!

In VeChainThor, these events are stored in the outputs field of the receipt.

To see them, you first need to connect to the network. "In JavaScript, this means..." initializing your client.

import { ThorClient } from '@vechain/sdk-network';
const thor = ThorClient.at('https://testnet.vechain.org');

// Fetch the result of the execution
const txReceipt = await thor.transactions.getTransactionReceipt(txId);
console.log(txReceipt.outputs); // Here are your events!
import { ThorClient } from '@vechain/sdk-network';
const thor = ThorClient.at('https://testnet.vechain.org');

// Fetch the result of the execution
const txReceipt = await thor.transactions.getTransactionReceipt(txId);
console.log(txReceipt.outputs); // Here are your events!
import { ThorClient } from '@vechain/sdk-network';
const thor = ThorClient.at('https://testnet.vechain.org');

// Fetch the result of the execution
const txReceipt = await thor.transactions.getTransactionReceipt(txId);
console.log(txReceipt.outputs); // Here are your events!

Nice! Just remember to check if reverted is false. If a transaction fails, those events never actually happened!