Skip to main content

Node — Registry + Bridges

1. Instantiate the Node Client

import { HCS7Client, HCS7ConfigType } from '@hashgraphonline/standards-sdk';

const hcs7 = new HCS7Client({
network: 'testnet',
operatorId: process.env.HEDERA_ACCOUNT_ID!,
operatorKey: process.env.HEDERA_PRIVATE_KEY!,
});

The client wraps all topic/transaction plumbing: memo generation (hcs-7:indexed:{ttl}), signing, and receipt handling. Call hcs7.close() when you finish.

2. Create a Registry Topic

const registry = await hcs7.createRegistry({ ttl: 86_400, submitKey: true });
if (!registry.success || !registry.topicId) throw new Error(registry.error);

console.log('Registry Topic:', registry.topicId);
  • ttl must be ≥ 3600 seconds.
  • submitKey: true reuses the operator key as the topic submit key. Pass a PrivateKey or string to use a dedicated key.

3. Register EVM + WASM Configs

await hcs7.registerConfig({
registryTopicId: registry.topicId,
memo: 'LaunchPage minted',
config: {
type: HCS7ConfigType.EVM,
contractAddress: '0x1d67aaf7f7e8d806bbeba24c4dea24808e1158b8',
abi: {
name: 'minted',
inputs: [],
outputs: [{ name: '', type: 'uint64' }],
stateMutability: 'view',
type: 'function',
},
},
});

await hcs7.registerConfig({
registryTopicId: registry.topicId,
memo: 'mint router',
config: {
type: HCS7ConfigType.WASM,
wasmTopicId: '0.0.5269810',
inputType: {
stateData: {
minted: 'number',
tokensRemaining: 'number',
},
},
outputType: {
type: 'string',
format: 'topic-id',
},
},
});

Each registration writes a register-config message into the same HCS‑7 topic the toolkit polls.

4. Register Metadata Targets

await hcs7.registerMetadata({
registryTopicId: registry.topicId,
metadataTopicId: '0.0.3717738',
weight: 1,
tags: ['odd'],
memo: 'odd artwork',
});

await hcs7.registerMetadata({
registryTopicId: registry.topicId,
metadataTopicId: '0.0.3717746',
weight: 1,
tags: ['even'],
memo: 'even artwork',
});

5. Query the Registry

const topic = await hcs7.getRegistry(registry.topicId, { limit: 50 });
topic.entries.forEach(entry => {
console.log(entry.sequenceNumber, entry.message.op, entry.message.m);
});

getRegistry reads the Mirror Node, validates each message against the HCS‑7 schema, and returns typed entries.

6. Use the Bridges for State + Routing

EVMBridge

import { EVMBridge } from '@hashgraphonline/standards-sdk/hcs-7/evm-bridge';

const evm = new EVMBridge('testnet');
const { result } = await evm.executeCommand({
c: {
contractAddress: '0x1d67aaf7f7e8d806bbeba24c4dea24808e1158b8',
abi: {
name: 'minted',
inputs: [],
outputs: [{ name: '', type: 'uint64' }],
stateMutability: 'view',
type: 'function',
},
},
});

console.log('Minted so far:', result.values?.[0]);

Swap in RedisCache if you need a shared cache across processes:

import { RedisCache } from '@hashgraphonline/standards-sdk/hcs-7/redis-cache';
const evm = new EVMBridge('testnet', undefined, new RedisCache({ host: '127.0.0.1' }));

WasmBridge

import { WasmBridge } from '@hashgraphonline/standards-sdk/hcs-7/wasm-bridge';

const wasm = new WasmBridge();
const wasmBytes = await fetch('https://kiloscribe.com/api/inscription-cdn/0.0.5269810?network=testnet').then(r => r.arrayBuffer());
await wasm.initWasm(wasmBytes);

const messages = await hcs7.getRegistry(registry.topicId, { limit: 100 });
const stateData = {
minted: '42',
tokensRemaining: '58',
};

const topicId = wasm.executeWasm(stateData, messages.entries.map(e => e.message));
console.log('Selected metadata topic:', topicId);

7. Low-Level Transactions

When you need to integrate with other toolchains (e.g., schedule a submit in HCS‑10 or build transactions inside the Agent Kit), use the helpers in src/hcs-7/tx.ts.

  • buildHcs7CreateRegistryTx
  • buildHcs7SubmitMessageTx
  • buildHcs7EvmMessageTx
  • buildHcs7WasmMessageTx

Each helper serializes the payload (p: 'hcs-7', op, etc.) so you only need to sign/send it with the Hedera SDK or another orchestration tool.