Skip to main content

HCS‑16 API Reference

Sources

Import PathsDirect link to Import Paths

import {
HCS16Client,
HCS16BrowserClient,
FloraTopicType,
FloraOperation,
buildHcs16CreateFloraTopicTx,
buildHcs16FloraCreatedTx,
buildHcs16TransactionTx,
buildHcs16StateUpdateTx,
buildHcs16FloraJoinRequestTx,
buildHcs16FloraJoinVoteTx,
buildHcs16FloraJoinAcceptedTx,
} from '@hashgraphonline/standards-sdk';

EnumsDirect link to Enums

enum FloraTopicType { COMMUNICATION=0, TRANSACTION=1, STATE=2 }
enum FloraOperation {
FLORA_CREATED = 'flora_created',
TRANSACTION = 'transaction',
STATE_UPDATE = 'state_update',
FLORA_JOIN_REQUEST = 'flora_join_request',
FLORA_JOIN_VOTE = 'flora_join_vote',
FLORA_JOIN_ACCEPTED = 'flora_join_accepted',
}

Message Schema (canonical)Direct link to Message Schema (canonical)

All messages share p: 'hcs-16' and an op from FloraOperation with op-specific fields at the top level.

{ "p":"hcs-16", "op":"flora_created", "operator_id":"0.0.x", "flora_account_id":"0.0.x", "topics": { "communication":"0.0.1", "transaction":"0.0.2", "state":"0.0.3" } }

Server Client (HCS16Client)Direct link to Server Client (HCS16Client)

constructor(config: { network: 'mainnet'|'testnet'; operatorId: string; operatorKey: string; keyType?: 'ed25519'|'ecdsa' })

createFloraTopic(params: { floraAccountId: string; topicType: FloraTopicType; adminKey?: import('@hashgraph/sdk').PublicKey|import('@hashgraph/sdk').KeyList; submitKey?: import('@hashgraph/sdk').PublicKey|import('@hashgraph/sdk').KeyList; autoRenewAccountId?: string; signerKeys?: import('@hashgraph/sdk').PrivateKey[] }): Promise<string>

getRecentMessages(topicId: string, options?: { limit?: number; order?: 'asc'|'desc'; opFilter?: FloraOperation|string }): Promise<Array<{ message: any; consensus_timestamp?: string; sequence_number: number }>>
getLatestMessage(topicId: string, opFilter?: FloraOperation|string): Promise<(any & { consensus_timestamp?: string; sequence_number: number }) | null>

Browser Client (HCS16BrowserClient)Direct link to Browser Client (HCS16BrowserClient)

Wallet‑signed equivalents for creating topics and sending messages:

sendFloraCreated({ topicId, operatorId, floraAccountId, topics }): Promise<void>
sendTransaction({ topicId, operatorId, scheduleId, data? }): Promise<void>
sendStateUpdate({ topicId, operatorId, hash, epoch?, accountId?, topics?, memo?, transactionMemo? }): Promise<void>

Source

Builders (tx.ts)Direct link to Builders (tx.ts)

function buildHcs16CreateFloraTopicTx(params: { floraAccountId: string; topicType: FloraTopicType; adminKey?: any; submitKey?: any; operatorPublicKey?: import('@hashgraph/sdk').PublicKey }): import('@hashgraph/sdk').TopicCreateTransaction;
function buildHcs16FloraCreatedTx(params: { topicId: string; operatorId: string; floraAccountId: string; topics: { communication: string; transaction: string; state: string } }): import('@hashgraph/sdk').TopicMessageSubmitTransaction;
function buildHcs16TransactionTx(params: { topicId: string; operatorId: string; scheduleId: string; data?: string }): import('@hashgraph/sdk').TopicMessageSubmitTransaction;
function buildHcs16StateUpdateTx(params: { topicId: string; operatorId: string; hash: string; epoch?: number; accountId?: string; topics?: string[]; memo?: string; transactionMemo?: string }): import('@hashgraph/sdk').TopicMessageSubmitTransaction;
function buildHcs16FloraJoinRequestTx(params: { topicId: string; operatorId: string; accountId: string; connectionRequestId: number; connectionTopicId: string; connectionSeq: number }): import('@hashgraph/sdk').TopicMessageSubmitTransaction;
function buildHcs16FloraJoinVoteTx(params: { topicId: string; operatorId: string; accountId: string; approve: boolean; connectionRequestId: number; connectionSeq: number }): import('@hashgraph/sdk').TopicMessageSubmitTransaction;
function buildHcs16FloraJoinAcceptedTx(params: { topicId: string; operatorId: string; members: string[]; epoch?: number }): import('@hashgraph/sdk').TopicMessageSubmitTransaction;

ValidationDirect link to Validation

  • Topic memos use numeric enum encoding: hcs-16:<floraId>:<type> or equivalent per spec section.
  • Messages validate p and op and include op‑specific data payloads.

ExampleDirect link to Example

const c = new HCS16Client({ network: 'testnet', operatorId, operatorKey });
const cTopic = await c.createFloraTopic({ floraAccountId: '0.0.600', topicType: FloraTopicType.COMMUNICATION });
await c.sendFloraCreated({
topicId: cTopic,
operatorId,
floraAccountId: '0.0.600',
topics: { communication: cTopic, transaction: '0.0.700', state: '0.0.701' },
});