Transaction Builders
The HCS-21 module exposes low-level helpers for composing adapter registry transactions (custom batching, fee schedules, or advanced signing flows).
Sources
Create Registry TopicDirect link to Create Registry Topic
Creates a TopicCreateTransaction with the correct memo format (hcs-21:<indexed>:<ttl>:<type>:<meta>) and optional admin/submit keys.
- TypeScript
- Go
- Python
import {
buildHcs21CreateRegistryTx,
HCS21TopicType,
Logger,
} from '@hashgraphonline/standards-sdk';
import { PublicKey } from '@hashgraph/sdk';
const logger = new Logger({ module: 'hcs-21-tx', level: 'info' });
const tx = buildHcs21CreateRegistryTx({
ttl: 3600,
indexed: 0,
type: HCS21TopicType.ADAPTER_REGISTRY,
adminKey: PublicKey.fromString(myAdminKey),
submitKey: PublicKey.fromString(mySubmitKey),
});
const response = await tx.setTransactionMemo('flora adapter registry').execute(client);
const receipt = await response.getReceipt(client);
logger.info('topic ready', { topicId: receipt.topicId?.toString() });
import "github.com/hashgraph-online/standards-sdk-go/pkg/hcs21"
memo, err := hcs21.BuildRegistryMemo(3600, true, hcs21.TopicTypeAdapterRegistry, "")
if err != nil {
log.Fatal(err)
}
tx, err := hcs21.BuildCreateRegistryTopicTx(hcs21.CreateRegistryTopicTxParams{
Memo: memo,
AdminKey: operatorPublicKey,
SubmitKey: operatorPublicKey,
})
if err != nil {
log.Fatal(err)
}
response, _ := tx.Execute(hederaClient)
receipt, _ := response.GetReceipt(hederaClient)
memo = hcs21.build_registry_memo(3600, True, hcs21.TOPIC_TYPE_ADAPTER_REGISTRY)
tx = hcs21.build_create_registry_topic_tx(memo=memo, admin_key=operatorPublicKey, submit_key=operatorPublicKey)
response = tx.execute(hederaClient)
receipt = response.get_receipt(hederaClient)
Adapter Declaration MessageDirect link to Adapter Declaration Message
Wraps a validated AdapterDeclaration into a TopicMessageSubmitTransaction.
- TypeScript
- Go
- Python
import {
AdapterDeclaration,
buildHcs21MessageTx,
} from '@hashgraphonline/standards-sdk';
const declaration: AdapterDeclaration = {
p: 'hcs-21',
op: 'register',
adapter_id: 'oci/@hashgraphonline/x402-bazaar-adapter@1.3.2',
entity: 'agent',
package: {
registry: 'oci',
name: '@hashgraphonline/x402-bazaar-adapter',
version: '1.3.2',
integrity: 'sha384-demo-digest',
},
manifest: 'hcs://1/0.0.600777',
config: {
type: 'flora',
account: '0.0.9001',
threshold: '2-of-3',
ctopic: '0.0.9101',
ttopic: '0.0.9102',
stopic: '0.0.9103',
},
state_model: 'hcs-21.entity-consensus@1',
};
const tx = buildHcs21MessageTx({
topicId: '0.0.700999',
declaration,
transactionMemo: 'adapter declaration',
});
await (await tx.execute(client)).getReceipt(client);
declaration := hcs21.AdapterDeclaration{
Protocol: "hcs-21",
Op: "register",
AdapterID: "oci/@hashgraphonline/x402-bazaar-adapter@1.3.2",
Entity: "agent",
Package: hcs21.PackageInfo{
Registry: "oci",
Name: "@hashgraphonline/x402-bazaar-adapter",
Version: "1.3.2",
Integrity: "sha384-demo-digest",
},
Manifest: "hcs://1/0.0.600777",
Config: map[string]any{
"type": "flora",
"account": "0.0.9001",
"threshold": "2-of-3",
"ctopic": "0.0.9101",
"ttopic": "0.0.9102",
"stopic": "0.0.9103",
},
StateModel: "hcs-21.entity-consensus@1",
}
tx, err := hcs21.BuildDeclarationMessageTx("0.0.700999", declaration, "adapter declaration")
if err != nil {
log.Fatal(err)
}
response, _ := tx.Execute(hederaClient)
declaration = hcs21.AdapterDeclaration{
# Protocol: "hcs-21",
# Op: "register",
# AdapterID: "oci/@hashgraphonline/x402-bazaar-adapter@1.3.2",
# Entity: "agent",
# Package: hcs21.PackageInfo{
# Registry: "oci",
# Name: "@hashgraphonline/x402-bazaar-adapter",
# Version: "1.3.2",
# Integrity: "sha384-demo-digest",
# Manifest: "hcs://1/0.0.600777",
# Config: map[string]any{
# StateModel: "hcs-21.entity-consensus@1",
tx = hcs21.build_declaration_message_tx("0.0.700999", declaration, "adapter declaration")
response = tx.execute(hederaClient)
Combine these builders with other Standards SDK utilities whenever you need full control over transaction signing.