HCS‑16 API Reference
Sources
- Module folder: GitHub
- base-client.ts: GitHub
- sdk.ts: GitHub
- browser.ts: GitHub
- tx.ts: GitHub
- types.ts: GitHub
Import PathsDirect link to Import Paths
- TypeScript
- Go
import {
HCS16Client,
HCS16BrowserClient,
FloraTopicType,
FloraOperation,
buildHcs16CreateFloraTopicTx,
buildHcs16FloraCreatedTx,
buildHcs16TransactionTx,
buildHcs16StateUpdateTx,
buildHcs16FloraJoinRequestTx,
buildHcs16FloraJoinVoteTx,
buildHcs16FloraJoinAcceptedTx,
} from '@hashgraphonline/standards-sdk';
NewClient(config ClientConfig) (*Client, error)
Client.CreateFloraTopic / CreateFloraAccount / CreateFloraAccountWithTopics
Client.SendFloraCreated / SendTransaction / SendStateUpdate
Client.SendFloraJoinRequest / SendFloraJoinVote / SendFloraJoinAccepted
Client.SignSchedule / PublishFloraCreated / CreateFloraProfile
Client.GetRecentMessages / GetLatestMessage
Client.AssembleKeyList / AssembleSubmitKeyList / ParseTopicMemo
BuildCreateFloraTopicTx / BuildCreateTransactionTopicTx / BuildCreateFloraAccountTx
BuildMessageTx / BuildFloraCreatedTx / BuildTransactionTx / BuildStateUpdateTx
BuildFloraJoinRequestTx / BuildFloraJoinVoteTx / BuildFloraJoinAcceptedTx
BuildScheduleAccountKeyUpdateTx / BuildScheduleTopicKeyUpdateTx
FloraTopicTypes: FloraTopicTypeCommunication, FloraTopicTypeTransaction, FloraTopicTypeState
FloraOperations: FloraOperationFloraCreated, FloraOperationTransaction, FloraOperationStateUpdate, etc.
EnumsDirect link to Enums
- TypeScript
- Go
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',
}
// See standards-sdk-go for full Go API types and methods
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)
- TypeScript
- Go
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>
// See standards-sdk-go for full Go API types and methods
Browser Client (HCS16BrowserClient)Direct link to Browser Client (HCS16BrowserClient)
Wallet‑signed equivalents for creating topics and sending messages:
- TypeScript
- Go
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>
// See standards-sdk-go for full Go API types and methods
Source
Builders (tx.ts)Direct link to Builders (tx.ts)
- TypeScript
- Go
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;
// See standards-sdk-go for full Go API types and methods
ValidationDirect link to Validation
- Topic memos use numeric enum encoding:
hcs-16:<floraId>:<type>or equivalent per spec section. - Messages validate
pandopand include op‑specificdatapayloads.
ExampleDirect link to Example
- TypeScript
- Go
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' },
});
// See standards-sdk-go for full Go API types and methods