← ClaudeAtlas

hedera-consensus-servicelisted

How to create topics, submit messages, and subscribe to real-time message streams on Hedera using the Hiero JavaScript SDK (@hiero-ledger/sdk). Use this skill whenever the user wants to work with Hedera Consensus Service (HCS), including topic creation, message submission, pub/sub messaging, mirror node subscriptions, chunked large messages, topic fees, or any consensus-related operation in JavaScript or TypeScript. Also trigger when users mention @hashgraph/sdk topic operations, event logging on Hedera, decentralized messaging, audit trails, or ordered message streams.
nickthelegend/xorv · ★ 0 · AI & Automation · score 67
Install: claude install-skill nickthelegend/xorv
# Hedera Consensus Service (HCS) — JavaScript SDK HCS provides a decentralized, ordered message log with consensus timestamps. It works like a pub/sub system: you create **topics**, **submit messages** to them, and **subscribe** to receive messages in real time via mirror nodes. Messages are immutable, ordered, and timestamped by network consensus — useful for audit trails, event logs, supply chain tracking, and decentralized communication. ## Setup All imports come from `@hiero-ledger/sdk`. Two setup patterns: ### Client + setOperator (direct) ```js import { Client, AccountId, PrivateKey } from "@hiero-ledger/sdk"; const client = Client.forName(process.env.HEDERA_NETWORK) .setOperator( AccountId.fromString(process.env.OPERATOR_ID), PrivateKey.fromStringECDSA(process.env.OPERATOR_KEY), ); ``` ### Wallet + LocalProvider (signer-based) ```js import { Wallet, LocalProvider } from "@hiero-ledger/sdk"; const provider = new LocalProvider(); const wallet = new Wallet(process.env.OPERATOR_ID, process.env.OPERATOR_KEY, provider); ``` With the signer pattern, use `freezeWithSigner(wallet)`, `signWithSigner(wallet)`, `executeWithSigner(wallet)`, and `getReceiptWithSigner(wallet)`. ## Creating a Topic ```js import { TopicCreateTransaction } from "@hiero-ledger/sdk"; const { topicId } = await ( await new TopicCreateTransaction() .setTopicMemo("My event log") .setAdminKey(operatorKey) // allows update/delete .setSubmitKey