HcsTopicService API Reference
This document provides a detailed API reference for the HcsTopicService
class — a service for managing Hedera Consensus Service (HCS) topics, including creating, updating, deleting topics, and retrieving topic info.
Methods
createTopic
async createTopic(props?: CreateTopicProps): Promise<string>
Creates a new HCS topic.
-
props
(optional): Properties to configure topic creation.
CreateTopicProps
fields:
-
topicMemo
(optional, string): Description or memo for the topic. -
adminKeySigner
(optional, Signer): Signer for a private key that must sign any transaction updating the topic (admin rights). -
submitKey
(optional, PrivateKey | PublicKey): Key permitted to submit messages. -
autoRenewPeriod
(optional, Duration | Long | number): Topic auto-renew period in seconds. -
autoRenewAccountId
(optional, AccountId | string): Account ID to be charged for auto-renewal fees. -
autoRenewAccountKeySigner
(optional, Signer): Signer for the auto-renewal account (required if autoRenewAccountId is provided). -
waitForChangesVisibility
(optional, boolean): If true, waits until the topic visibility is confirmed in the mirror node. -
waitForChangesVisibilityTimeoutMs
(optional, number): Timeout in milliseconds to wait for changes visibility.
-
A promise resolving to the created topic ID as a string.
-
Error if
autoRenewAccountId
is provided withoutautoRenewAccountKey
. -
Error if the topic creation transaction fails.
updateTopic
async updateTopic(props: UpdateTopicProps): Promise<void>
Updates an existing HCS topic.
-
props
(required): Properties for updating the topic.
UpdateTopicProps
fields:
-
topicId
(required, string): The ID of the topic to update. -
currentAdminKeySigner
(required, Signer): Signer for the current admin key required to sign the update transaction. -
topicMemo
(optional, string): New memo for the topic (set empty string to clear). -
submitKey
(optional, PrivateKey): New submit key. -
adminKeySigner
(optional, Signer): Signer for a new admin key that must sign any transaction updating the topic. -
autoRenewPeriod
(optional, Duration | Long | number): New auto-renewal period (default fallback to 90 days if null). -
autoRenewAccountId
(optional, AccountId | string): New auto-renew account ID. -
autoRenewAccountKeySigner
(optional, Signer): Signer for the auto-renewal account (required if autoRenewAccountId is provided). -
expirationTime
(optional, Timestamp | Date): New expiration time. -
waitForChangesVisibility
(optional, boolean): If true, wait until updated topic info is visible in mirror node. -
waitForChangesVisibilityTimeoutMs
(optional, number): Timeout in milliseconds for visibility wait.
-
A promise resolving when the topic update completes.
-
Error if
autoRenewAccountId
is set withoutautoRenewAccountKey
. -
Error if the update transaction fails.
deleteTopic
async deleteTopic(props: DeleteTopicProps): Promise<void>
Deletes an HCS topic.
-
props
(required): Properties for deleting the topic.
DeleteTopicProps
fields:
-
topicId
(required, string): ID of the topic to delete. -
adminKeySigner
(required, Signer): Signer for the current admin key required to sign the delete transaction. -
waitForChangesVisibility
(optional, boolean): Wait until deletion is confirmed visible in mirror node. -
waitForChangesVisibilityTimeoutMs
(optional, number): Timeout in milliseconds to wait for visibility.
-
A promise resolving when deletion is complete.
-
Error if the deletion transaction fails.