Skip to main content

Browser — HCS‑16BrowserClient

This guide mirrors the Node flows but shows the wallet‑signed path. Transactions are built once (in tx.ts) and executed via a DAppSigner or compatible wallet connector.

1) Create Topics and AnnounceDirect link to 1) Create Topics and Announce

import type { DAppSigner } from '@hashgraph/hedera-wallet-connect';
import { HCS16BrowserClient, FloraTopicType } from '@hashgraphonline/standards-sdk';

const client = new HCS16BrowserClient({ network: 'testnet', signer });
const cTopic = await client.createFloraTopic({ floraAccountId, topicType: FloraTopicType.COMMUNICATION });
const tTopic = await client.createFloraTopic({ floraAccountId, topicType: FloraTopicType.TRANSACTION });
const sTopic = await client.createFloraTopic({ floraAccountId, topicType: FloraTopicType.STATE });

await client.sendFloraCreated({
topicId: cTopic,
operatorId,
floraAccountId,
topics: { communication: cTopic, transaction: tTopic, state: sTopic },
});

Notes:

  • Under the hood, createFloraTopic freezes and executes with the signer.
  • You can pass admin/submit keys based on your policy; omit for public topics.

2) Propose a TransactionDirect link to 2) Propose a Transaction

await client.sendTransaction({
topicId: tTopic,
operatorId,
scheduleId: '0.0.1234@1726357200.000000000',
data: 'release funds for invoice #42',
});

3) Publish a State UpdateDirect link to 3) Publish a State Update

await client.sendStateUpdate({
topicId: sTopic,
operatorId,
hash: '0x…',
epoch: 7,
memo: 'post‑proposal state',
});

Reading MessagesDirect link to Reading Messages

const recent = await client.getRecentMessages(cTopic, { limit: 10, order: 'desc', opFilter: 'flora_created' });
const latest = await client.getLatestMessage(cTopic, 'flora_created');

Use the browser client when you need on‑device signing and user consent flows; keep logic identical to Node by relying on the same builders and message shapes.