TopicReader API Reference

This document provides a concise API reference for the TopicReader class within the Hedera DID SDK for JavaScript. This class is responsible for reading messages from the Hedera network topic.

Class Diagram

The class diagram below illustrates the core methods of the TopicReader interface for interacting with the Hedera network.

topic reader class diagram

Methods

fetchAllToDate

fetchAllToDate(topicId: string, network: Network): Promise<TopicReaderMessage[]>

Fetches all messages from a topic from the start to the end of the topic.

Parameters
  • topicId: The ID of the topic to fetch messages from.

  • network: The Hedera network to use.

Returns

An array of messages from the topic.

fetchFrom

fetchFrom(topicId: string, network: Network, options: TopicReaderOptions): Promise<TopicReaderMessage[]>

Fetches messages from a topic from a specific start time to an end time.

Parameters
  • topicId: The ID of the topic to fetch messages from.

  • network: The Hedera network to use.

  • options: The options for the fetch. See TopicReaderOptions for more details.

Returns

An array of messages from the topic.

Data Types

TopicReaderOptions

Name Type Description

from

number

The start time of the fetch in seconds. Default is 0.

to

number

The end time of the fetch in seconds. Default is the current time.

Class Implementation

The Hashgraph DID SDK provides the TopicReader class interface and implementations within its resolver package. For further details, refer to the @hashgraph-did-sdk-js/resolver package documentation.