HCS-17 Transactions
Note
- These builders are for direct transaction construction (e.g., with the Standards Agent Kit or custom pipelines).
- For most applications, prefer the higher‑level client (Node/Go) or browser client (wallet).
Sources
All transaction construction is centralized in builders. Clients never assemble JSON payloads themselves. Builders return Hedera SDK transaction instances ready to be signed and executed.
Create TopicDirect link to Create Topic
- TypeScript
- Go
import { buildHcs17CreateTopicTx } from '@hashgraphonline/standards-sdk';
const tx = buildHcs17CreateTopicTx({
ttl: 86400,
adminKey: true,
submitKey: true,
});
// Node: await tx.execute(client)
// Browser: await (await tx.freezeWithSigner(signer)).executeWithSigner(signer)
This builder encodes the memo as hcs-17:<type>:<ttl> using numeric enums (HCS17TopicType.STATE = 0).
import "github.com/hashgraph-online/standards-sdk-go/pkg/hcs17"
tx := hcs17.BuildCreateStateTopicTx(hcs17.CreateTopicOptions{
TTLSeconds: 86400,
AdminKey: operatorPublicKey,
SubmitKey: operatorPublicKey,
})
response, _ := tx.Execute(hederaClient)
receipt, _ := response.GetReceipt(hederaClient)
Memo is automatically set to hcs-17:0:<ttl>.
Submit State Hash MessageDirect link to Submit State Hash Message
- TypeScript
- Go
import { buildHcs17MessageTx } from '@hashgraphonline/standards-sdk';
const tx = buildHcs17MessageTx({
topicId: '0.0.7777',
stateHash: 'ab…',
accountId: '0.0.1234',
topics: ['0.0.2001', '0.0.2002'],
memo: 'optional app memo',
transactionMemo: 'HCS-17 publish',
});
msg := client.CreateStateHashMessage(
"ab…", // state hash
"0.0.1234", // account ID
[]string{"0.0.2001", "0.0.2002"}, // topics
"optional app memo",
nil, // epoch (optional)
)
tx, err := hcs17.BuildStateHashMessageTx("0.0.7777", msg, "HCS-17 publish")
if err != nil {
log.Fatal(err)
}
response, _ := tx.Execute(hederaClient)
The builder constructs the canonical HCS‑17 payload internally:
{
"p": "hcs-17",
"op": "state_hash",
"state_hash": "…",
"topics": ["…"],
"account_id": "…",
"timestamp": "ISO8601",
"m": "…"
}
Execution PatternsDirect link to Execution Patterns
- TypeScript
- Go
- Node:
await tx.execute(client).then(r => r.getReceipt(client)) - Browser:
await (await tx.freezeWithSigner(signer)).executeWithSigner(signer)thengetReceiptWithSigner
response, err := tx.Execute(hederaClient)
if err != nil {
log.Fatal(err)
}
receipt, err := response.GetReceipt(hederaClient)