# Hcs Consensus

> Use Hedera Consensus Service — create/update/delete topics, submit messages with optional submit keys, subscribe via TopicMessageQuery, REST pagination for topic messages, chunk oversized payloads past transaction limits, ordered timestamps for audit trails. Use when user mentions HCS, consensus topic, submit message, mirror subscribe topic, ordered log, event sourcing, audit log chain, supply chain provenance, chunked messages.

- Skill: `evaluris-solutions/hcs-consensus` (Agent Skill, multi-file: 8 files)
- Install (CLI): `npx skillmds@latest add evaluris-solutions/hcs-consensus`
- Raw SKILL.md: https://api.skillmd.com/api/skills/evaluris-solutions/hcs-consensus/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Security
- Author: Evaluris-Solutions (https://skillmd.com/u/evaluris-solutions)
- Updated: 2026-09-22
- Page: https://skillmd.com/skills/evaluris-solutions/hcs-consensus

---


## 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](https://docs.hedera.com/hedera/sdks-and-apis/sdks/consensus-service.md).

## 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

1. **Create topic** — `TopicCreateTransaction`; optionally set `submitKey`, `adminKey`, memo.

   Reference: [scripts/create-topic.js](scripts/create-topic.js).

2. **Submit message** — `TopicMessageSubmitTransaction` with UTF-8 or binary payloads.

   Reference: [scripts/submit-message.js](scripts/submit-message.js).

3. **Chunk large payloads** — iterate chunks ≤ ~900 bytes payload budget per submit after overhead — verify limits on network release notes.

   Reference: [scripts/chunked-submit.js](scripts/chunked-submit.js).

4. **Subscribe (mirror GRPC)** — `TopicMessageQuery.subscribe(client, onErr, onMsg)` streams live messages.

   Reference: [scripts/subscribe-topic.js](scripts/subscribe-topic.js).

5. **Poll REST** — `GET /api/v1/topics/{id}/messages` with `topic.timestamp` pagination parameters.

6. **Delete topic** — `TopicDeleteTransaction` requires 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/hcs-use-cases.md), [references/chunking.md](references/chunking.md), [references/nano-timestamps.md](references/nano-timestamps.md)
- Docs: [Create a topic](https://docs.hedera.com/hedera/sdks-and-apis/sdks/consensus-service/create-a-topic.md), [Submit a message](https://docs.hedera.com/hedera/sdks-and-apis/sdks/consensus-service/submit-a-message.md)

