Overview
HCS provides globally ordered, timestamped messages on topics — ideal for tamper-evident logs without deploying contracts. Pair ledger submissions with Mirror Node reads/subscriptions per Consensus Service SDK docs.
When to use this skill
- Building append-only audit feeds with nanosecond-resolution consensus timestamps.
- Splitting payloads larger than single-message limits using deterministic chunk framing.
Prerequisites
- Operator account with HBAR for topic creation + message submits.
Workflow
Create topic —
TopicCreateTransaction; optionally setsubmitKey,adminKey, memo.Reference: scripts/create-topic.js.
Submit message —
TopicMessageSubmitTransactionwith UTF-8 or binary payloads.Reference: scripts/submit-message.js.
Chunk large payloads — iterate chunks ≤ ~900 bytes payload budget per submit after overhead — verify limits on network release notes.
Reference: scripts/chunked-submit.js.
Subscribe (mirror GRPC) —
TopicMessageQuery.subscribe(client, onErr, onMsg)streams live messages.Reference: scripts/subscribe-topic.js.
Poll REST —
GET /api/v1/topics/{id}/messageswithtopic.timestamppagination parameters.Delete topic —
TopicDeleteTransactionrequires admin key signatures.
Examples
Example 1
“Log ERP audit events with immutable ordering.”
Publish compact JSON lines to HCS; consumers replay via Mirror REST sorted by consensus_timestamp.
Example 2
“Only our payroll signer may publish.”
Set submitKey to payroll public key; rotations via TopicUpdateTransaction.
Example 3
“Payload is a 50 KB JSON file.”
Chunk + store manifest linking chunk sequence — verify ordering during reassembly.
Troubleshooting
| Issue | Tip |
|---|---|
INVALID_CHUNK_TRANSACTION_ID |
Chunk parent mismatch — reuse chunk info header fields |
| Unauthorized submit | Missing/incorrect submit key signature |
References
- Local: references/hcs-use-cases.md, references/chunking.md, references/nano-timestamps.md
- Docs: Create a topic, Submit a message