FlowVault Technical Documentation

Historical Indexing

Guide for retrieving and indexing historical FlowVault events using Stacks node APIs, Hiro API, and chain event streaming.

Audience: Data engineers and backend developersMode: Reference

Overview

Since Stacks does not maintain public SQL databases of transaction event logs by default, developers query transaction state and logs through Hiro's public API or by tracking print events on local Stacks nodes.

Hiro Explorer

For manual verification, search for the deployed FlowVault contract principal STD7QG84VQQ0C35SZM2EYTHZV4M8FQ0R7YNSQWPD.flowvault-v2 in the Hiro Explorer. Under the Transactions tab, you can view all deposit and withdrawal events. Selecting an individual transaction displays the emitted print events and their payload keys.

Hiro API Endpoint

To programmatically retrieve historical events, query the Hiro API's transactions endpoint. This endpoint returns the execution results and raw events for contract calls.

Request URL

GET https://api.testnet.hiro.so/extended/v1/address/STD7QG84VQQ0C35SZM2EYTHZV4M8FQ0R7YNSQWPD.flowvault-v2/transactions

Filtering Events

Iterate through the returned transaction list and check for transaction objects matching:

  • tx_status: "success"
  • events: An array containing objects where event_type is "smart_contract_log".

Inside the contract log event, the payload is serialized as a hex Cl-value inside the value.hex field. The SDK can parse this value back into standard JSON objects.

Recommended Indexing Workflow

  1. Initial Sync: Query all historical transactions for the contract address using pagination.
  2. Event Decoding: Parse the event hex values to filter by event name (e.g. "deposit" or "withdraw").
  3. Database Storage: Store the depositor, locked amount, hold amount, unlock blocks, and transaction IDs into your relational database.
  4. Real-time Streaming: Integrate WebSockets or a chain-event stream listener (such as Hiro's Chainhook) to listen for new block transactions and update your dashboard database in real-time.