STRUCTURED
CONSENSUS.

HCS-2 Registries turn the consensus stream into structured databases. Build file systems, identity graphs, and recursive applications without smart contracts.

CONCEPT

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.

SCHEMA

Strict Typing.

Every message in an HCS-2 registry must follow a precise JSON schema. This ensures interoperability across the entire ecosystem.

pProtocol. Always "hcs-2".
opOperation. register | update | delete.
t_idTarget Topic ID (The Pointer).
uidUnique Identifier for updates.
{
  "p": "hcs-2",
  "op": "register",
  "t_id": "0.0.123456",
  "metadata": "hcs://1/0.0.987654",
  "m": "User Profile v1"
}
OPERATIONS

CRUD on Consensus.

R
R

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.

U
U

update

Modifies an existing entry by referencing its uid. The history remains, but the current state points to the new topic.

D
D

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.

ENUM 0
ENUM 1

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.

RECURSION

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

Root Registry (Company)0.0.100
Engineering Dept0.0.200
{ op: "register", t_id: "0.0.200", m: "Eng Dept" } (On Root Topic)
Apollo Project (Docs)0.0.300
{ 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.

DEVELOPER TOOLS

Build with the SDK.

Create Registry

create-registry.ts
import { HCS2 } from '@hashgraph/standards';Click to copy
const regId = await HCS2.createRegistry(client, {Click to copy
adminKey: myKey,Click to copy
submitKey: myKey,Click to copy
memo: "My Registry"Click to copy
});Click to copy

Register Entry

register.ts
await HCS2.register(client, regId, {Click to copy
t_id: "0.0.12345",Click to copy
metadata: "hcs://1/0.0.999",Click to copy
memo: "New Item"Click to copy
});Click to copy