HCS‑18 API Reference
Sources
- Module folder: GitHub
- base-client.ts: GitHub
- sdk.ts: GitHub
- browser.ts: GitHub
- tx.ts: GitHub
- types.ts: GitHub
Import PathsDirect link to Import Paths
- TypeScript
- Go
- Python
import {
HCS18Client,
HCS18BrowserClient,
DiscoveryOperation,
type SDKHCS18ClientConfig,
type BrowserHCS18ClientConfig,
type DiscoveryMessage,
type AnnounceData,
type ProposeData,
type RespondData,
type CompleteData,
type WithdrawData,
buildHcs18DiscoveryMemo,
buildHcs18CreateDiscoveryTopicTx,
buildHcs18SubmitDiscoveryMessageTx,
buildHcs18AnnounceMessage,
buildHcs18ProposeMessage,
buildHcs18RespondMessage,
buildHcs18CompleteMessage,
buildHcs18WithdrawMessage,
} from '@hashgraphonline/standards-sdk';
NewClient(config ClientConfig) (*Client, error)
Client.CreateDiscoveryTopic / SubmitMessage
Client.Announce / Propose / Respond / Complete / Withdraw
Client.GetRecentMessages
BuildCreateDiscoveryTopicTx(CreateDiscoveryTopicTxParams) *hedera.TopicCreateTransaction
BuildSubmitDiscoveryMessageTx(topicID, DiscoveryMessage, txMemo) (*hedera.TopicMessageSubmitTransaction, error)
BuildAnnounceMessage(AnnounceData) DiscoveryMessage
BuildProposeMessage(ProposeData) DiscoveryMessage
BuildRespondMessage(RespondData) DiscoveryMessage
BuildCompleteMessage(CompleteData) DiscoveryMessage
BuildWithdrawMessage(WithdrawData) DiscoveryMessage
from standards_sdk_py.hcs18 import Hcs18Client
# Equivalent Python usage — see Python SDK docs for details
EnumsDirect link to Enums
- TypeScript
- Go
- Python
enum DiscoveryOperation {
ANNOUNCE = 'announce',
PROPOSE = 'propose',
RESPOND = 'respond',
COMPLETE = 'complete',
WITHDRAW = 'withdraw',
}
// See standards-sdk-go for full Go API types and methods
from standards_sdk_py.hcs18 import Hcs18Client
# Equivalent Python usage — see Python SDK docs for details
Message Schema (canonical)Direct link to Message Schema (canonical)
{ "p":"hcs-18", "op":"announce", "data": { /* per op */ }, "m":"optional" }
Server Client (HCS18Client)Direct link to Server Client (HCS18Client)
- TypeScript
- Go
- Python
constructor(config: SDKHCS18ClientConfig)
createDiscoveryTopic(options?: { ttlSeconds?: number; adminKey?: any; submitKey?: any; memoOverride?: string }): Promise<{ topicId: string; receipt: import('@hashgraph/sdk').TransactionReceipt }>
announce(params: { discoveryTopicId: string; data: AnnounceData; memo?: string }): Promise<{ receipt: import('@hashgraph/sdk').TransactionReceipt; sequenceNumber?: number }>
propose(params: { discoveryTopicId: string; data: ProposeData; memo?: string }): Promise<{ receipt: import('@hashgraph/sdk').TransactionReceipt; sequenceNumber?: number }>
respond(params: { discoveryTopicId: string; data: RespondData; memo?: string }): Promise<import('@hashgraph/sdk').TransactionReceipt>
complete(params: { discoveryTopicId: string; data: CompleteData; memo?: string }): Promise<import('@hashgraph/sdk').TransactionReceipt>
withdraw(params: { discoveryTopicId: string; data: WithdrawData; memo?: string }): Promise<import('@hashgraph/sdk').TransactionReceipt>
getDiscoveryMessages(topicId: string, options?: { limit?: number; order?: 'asc'|'desc' }): Promise<DiscoveryMessage[]>
isProposalReady(proposal: ProposeData): boolean
// See standards-sdk-go for full Go API types and methods
from standards_sdk_py.hcs18 import Hcs18Client
# Equivalent Python usage — see Python SDK docs for details
Source
Browser Client (HCS18BrowserClient)Direct link to Browser Client (HCS18BrowserClient)
Wallet‑signed equivalents for announce, propose, respond, complete, and withdraw.
Source
Builders (tx.ts)Direct link to Builders (tx.ts)
- TypeScript
- Go
- Python
function buildHcs18DiscoveryMemo(ttlSeconds?: number, memoOverride?: string): string;
function buildHcs18CreateDiscoveryTopicTx(params: { ttlSeconds?: number; adminKey?: any; submitKey?: any; operatorPublicKey?: import('@hashgraph/sdk').PublicKey; memoOverride?: string }): import('@hashgraph/sdk').TopicCreateTransaction;
function buildHcs18SubmitDiscoveryMessageTx(params: { topicId: string; message: DiscoveryMessage; transactionMemo?: string }): import('@hashgraph/sdk').TopicMessageSubmitTransaction;
function buildHcs18AnnounceMessage(data: AnnounceData): DiscoveryMessage;
function buildHcs18ProposeMessage(data: ProposeData): DiscoveryMessage;
function buildHcs18RespondMessage(data: RespondData): DiscoveryMessage;
function buildHcs18CompleteMessage(data: CompleteData): DiscoveryMessage;
function buildHcs18WithdrawMessage(data: WithdrawData): DiscoveryMessage;
// See standards-sdk-go for full Go API types and methods
from standards_sdk_py.hcs18 import Hcs18Client
# Equivalent Python usage — see Python SDK docs for details
Source
ExampleDirect link to Example
- TypeScript
- Go
- Python
const c = new HCS18Client({ network: 'testnet', operatorId, operatorKey });
const topicId = await c.createDiscoveryTopic({ ttlSeconds: 300 }).then(r => r.topicId);
await c.announce({ discoveryTopicId: topicId!, data: { account: '0.0.111', petal: { name: 'A', priority: 700 }, capabilities: { protocols: ['hcs-16','hcs-18'] } } });
// See standards-sdk-go for full Go API types and methods
from standards_sdk_py.hcs18 import Hcs18Client
# Equivalent Python usage — see Python SDK docs for details