STRUCTURED
CONSENSUS.
HCS-2 Registries turn the consensus stream into structured databases. Build file systems, identity graphs, and recursive applications without smart contracts.
The Log is the Database.
In traditional databases, you update a record and the old state is gone. On Hedera Consensus Service, history is immutable.
HCS-2 defines a standard way to interpret a stream of messages as a coherent state machine. It is the glue that binds disparate HCS topics into logical applications.
Deterministic State
Anyone replay the log from the beginning arrives at the exact same current state. No central server required.
Verifiable History
Every change is timestamped and signed. You can prove exactly when a user updated their profile or deleted a file.
Lightweight Indexing
Mirror nodes do the heavy lifting. Clients just query the topic messages and apply the HCS-2 rules.
Strict Typing.
Every message in an HCS-2 registry must follow a precise JSON schema. This ensures interoperability across the entire ecosystem.
{
"p": "hcs-2",
"op": "register",
"t_id": "0.0.123456",
"metadata": "hcs://1/0.0.987654",
"m": "User Profile v1"
}CRUD on Consensus.
register
Adds a new entry. Think of this like adding a row to a database table or a file to a folder. The t_id points to content.
update
Modifies an existing entry by referencing its uid. The history remains, but the current state points to the new topic.
delete
Soft delete. Removes an entry from the active set. Indexers stop serving content, but the record remains.
Two Modes.
Defined by the Topic Memo Enum, HCS-2 registries can behave in two distinct ways to suit different use cases.
Indexed (Accumulator)
All messages matter. Order matters. Use for chat logs, activity feeds, and audit trails.
Non-Indexed (Pointer)
Only the last message matters. Use for mutable configurations, Dynamic NFTs (HCS-6), and current status.
Infinite Depth.
The power of HCS-2 lies in its ability to nest. A registry can contain a topic ID that is also a registry.
This creates a Merkle-like DAG (Directed Acyclic Graph) on the consensus layer. You can build entire folder structures, social graphs, or organizational hierarchies.
Practical Example: Organization Tree
{ op: "register", t_id: "0.0.200", m: "Eng Dept" } (On Root Topic){ op: "register", t_id: "0.0.300", m: "Apollo" } (On Eng Topic)Migration Paths.
Topic Rotation
Keys compromised? Post a migrate op pointing to a new secure topic. Clients follow the breadcrumbs.
Snapshotting
Registry too large? Create a new topic with the current state as the genesis message. Link old history.
Forking
Community disagreement? Anyone can read the public topic and create a divergent registry starting from block N.