Server — HCS‑2 Client
- TypeScript
- Go
- Python
import 'dotenv/config';
import { HCS2Client, HCS2RegistryType } from '@hashgraphonline/standards-sdk';
const client = new HCS2Client({
network: 'testnet',
operatorId: process.env.HEDERA_ACCOUNT_ID!,
operatorKey: process.env.HEDERA_PRIVATE_KEY!,
});
const reg = await client.createRegistry({ registryType: HCS2RegistryType.INDEXED, ttl: 86400 });
await client.registerEntry(reg.topicId!, {
targetTopicId: '0.0.700123',
metadata: 'https://example.com/meta.json',
});
import "github.com/hashgraph-online/standards-sdk-go/pkg/hcs2"
client, err := hcs2.NewClient(hcs2.ClientConfig{
Network: "testnet",
OperatorAccountID: os.Getenv("HEDERA_ACCOUNT_ID"),
OperatorPrivateKey: os.Getenv("HEDERA_PRIVATE_KEY"),
})
if err != nil {
log.Fatal(err)
}
reg, err := client.CreateRegistry(ctx, hcs2.CreateRegistryOptions{
RegistryType: hcs2.RegistryTypeIndexed,
TTL: 86400,
})
if err != nil {
log.Fatal(err)
}
_, err = client.RegisterEntry(ctx, reg.TopicID, hcs2.RegisterEntryOptions{
TargetTopicID: "0.0.700123",
Metadata: "https://example.com/meta.json",
}, "")
import os
from standards_sdk_py.hcs2 import Hcs2Client, Hcs2RegistryType
client = Hcs2Client(
operator_id=os.environ["HEDERA_ACCOUNT_ID"],
operator_key=os.environ["HEDERA_PRIVATE_KEY"],
network="testnet",
)
reg = client.create_registry(registry_type=Hcs2RegistryType.INDEXED, ttl=86400)
client.register_entry(
reg["topicId"],
target_topic_id="0.0.700123",
metadata="https://example.com/meta.json",
)