Developer Fundamentals

4. Tracking Movements

Learn how to query smart contract events and track native VET transfers.

Prerequisites

Listening to the Chain (Logs & VET)

Smart contracts love to talk! They emit Events to signal that something happened.

Apps can "listen" to these signals in two ways:

  1. Historical: Filter logs from the past using filterEventLogs.

  2. Real-time: Use WebSockets to hear events the moment they happen!

Watch Out! ⚠️

VET is the native currency, so it doesn't have a smart contract address. You can't find VET transfers in contract logs!

Instead, we use a dedicated method: filterTransferLogs.

// Find native VET transfers
const logs = await thor.logs.filterTransferLogs({
    criteriaSet: [{ recipient: '0x...' }]
});
// Find native VET transfers
const logs = await thor.logs.filterTransferLogs({
    criteriaSet: [{ recipient: '0x...' }]
});
// Find native VET transfers
const logs = await thor.logs.filterTransferLogs({
    criteriaSet: [{ recipient: '0x...' }]
});

Nice! This allows you to build analytics tools, heatmaps, and portfolio trackers.