@hashgraphonline/standards-sdk
Version:
The Hashgraph Online Standards SDK provides a complete implementation of the Hashgraph Consensus Standards (HCS), giving developers all the tools needed to build applications on Hedera.
248 lines • 13 kB
TypeScript
import { Client, PrivateKey, KeyList, Transaction, TransactionReceipt, PublicKey } from '@hashgraph/sdk';
import { RetrievedInscriptionResult } from '@kiloscribe/inscription-sdk';
import { Logger } from '../utils';
import { HCS10BaseClient } from './base-client';
import { HCSClientConfig, CreateAccountResponse, CreateAgentResponse, CreateMCPServerResponse, StoreHCS11ProfileResponse, AgentRegistrationResult, HandleConnectionRequestResponse, WaitForConnectionConfirmationResponse, GetAccountAndSignerResponse, AgentCreationState, RegistrationProgressCallback, InscribePfpResponse, MCPServerCreationState } from './types';
import { InboundTopicType, AgentMetadata, MCPServerBuilder } from '../hcs-11';
import { FeeConfigBuilderInterface, TopicFeeConfig } from '../fees';
import { AgentBuilder } from '../hcs-11/agent-builder';
export declare class HCS10Client extends HCS10BaseClient {
private client;
private operatorPrivateKey;
private operatorAccountId;
protected network: string;
protected logger: Logger;
protected guardedRegistryBaseUrl: string;
private hcs11Client;
private keyType;
constructor(config: HCSClientConfig);
initializeOperator(): Promise<{
accountId: string;
privateKey: string;
keyType: 'ed25519' | 'ecdsa';
client: Client;
}>;
getClient(): Client;
/**
* Creates a new Hedera account
* @param initialBalance Optional initial balance in HBAR (default: 50)
* @returns Object with account ID and private key
*/
createAccount(initialBalance?: number): Promise<CreateAccountResponse>;
/**
* Creates an inbound topic for an agent
* @param accountId The account ID associated with the inbound topic
* @param topicType Type of inbound topic (public, controlled, or fee-based)
* @param ttl Optional Time-To-Live for the topic memo, defaults to 60
* @param feeConfigBuilder Optional fee configuration builder for fee-based topics
* @returns The topic ID of the created inbound topic
*/
createInboundTopic(accountId: string, topicType: InboundTopicType, ttl?: number, feeConfigBuilder?: FeeConfigBuilderInterface): Promise<string>;
/**
* Creates a new agent with inbound and outbound topics
* @param builder The agent builder object
* @param ttl Optional Time-To-Live for the topic memos, defaults to 60
* @param existingState Optional existing state to resume from
* @returns Object with topic IDs
*/
createAgent(builder: AgentBuilder, ttl?: number, existingState?: Partial<AgentCreationState>, progressCallback?: RegistrationProgressCallback): Promise<CreateAgentResponse>;
/**
* Inscribes a profile picture to Hedera
* @param buffer Profile picture buffer
* @param fileName Filename
* @returns Response with topic ID and transaction ID
*/
inscribePfp(buffer: Buffer, fileName: string): Promise<InscribePfpResponse>;
/**
* Stores an HCS-11 profile for an agent
* @param agentName Agent name
* @param agentBio Agent description
* @param inboundTopicId Inbound topic ID
* @param outboundTopicId Outbound topic ID
* @param capabilities Agent capability tags
* @param metadata Additional metadata
* @param pfpBuffer Optional profile picture buffer
* @param pfpFileName Optional profile picture filename
* @returns Response with topic IDs and transaction ID
*/
storeHCS11Profile(agentName: string, agentBio: string, inboundTopicId: string, outboundTopicId: string, capabilities: number[], metadata: AgentMetadata, pfpBuffer?: Buffer, pfpFileName?: string, existingPfpTopicId?: string): Promise<StoreHCS11ProfileResponse>;
private setupFees;
private setupExemptKeys;
/**
* Handles a connection request from another account
* @param inboundTopicId Inbound topic ID of your agent
* @param requestingAccountId Requesting account ID
* @param connectionRequestId Connection request ID
* @param connectionFeeConfig Optional fee configuration for the connection topic
* @param ttl Optional ttl parameter with default
* @returns Response with connection details
*/
handleConnectionRequest(inboundTopicId: string, requestingAccountId: string, connectionRequestId: number, connectionFeeConfig?: FeeConfigBuilderInterface, ttl?: number): Promise<HandleConnectionRequestResponse>;
/**
* Confirms a connection request from another account
* @param inboundTopicId Inbound topic ID
* @param connectionTopicId Connection topic ID
* @param connectedAccountId Connected account ID
* @param connectionId Connection ID
* @param memo Memo for the connection request
* @param submitKey Optional submit key
* @returns Sequence number of the confirmed connection
*/
confirmConnection(inboundTopicId: string, connectionTopicId: string, connectedAccountId: string, connectionId: number, memo: string, submitKey?: PrivateKey): Promise<number>;
sendMessage(connectionTopicId: string, data: string, memo?: string, submitKey?: PrivateKey, options?: {
progressCallback?: RegistrationProgressCallback;
waitMaxAttempts?: number;
waitIntervalMs?: number;
}): Promise<TransactionReceipt>;
createTopic(memo: string, adminKey?: boolean | PublicKey | KeyList, submitKey?: boolean | PublicKey | KeyList, feeConfig?: TopicFeeConfig): Promise<string>;
submitPayload(topicId: string, payload: object | string, submitKey?: PrivateKey, requiresFee?: boolean): Promise<TransactionReceipt>;
inscribeFile(buffer: Buffer, fileName: string, options?: {
progressCallback?: RegistrationProgressCallback;
waitMaxAttempts?: number;
waitIntervalMs?: number;
}): Promise<RetrievedInscriptionResult>;
/**
* Waits for confirmation of a connection request
* @param inboundTopicId Inbound topic ID
* @param connectionRequestId Connection request ID
* @param maxAttempts Maximum number of attempts
* @param delayMs Delay between attempts in milliseconds
* @returns Connection confirmation details
*/
waitForConnectionConfirmation(inboundTopicId: string, connectionRequestId: number, maxAttempts?: number, delayMs?: number, recordConfirmation?: boolean): Promise<WaitForConnectionConfirmationResponse>;
getAccountAndSigner(): GetAccountAndSignerResponse;
/**
* Creates and registers an agent with a Guarded registry.
*
* This function performs the following steps:
* 1. Creates a new account if no existing account is provided.
* 2. Initializes an HCS10 client with the new account.
* 3. Creates an agent on the client.
* 4. Registers the agent with the Hashgraph Online Guarded Registry.
*
* @param builder The agent builder object
* @param options Optional configuration including progress callback and state management
* @returns Agent registration result
*/
createAndRegisterAgent(builder: AgentBuilder, options?: {
baseUrl?: string;
progressCallback?: RegistrationProgressCallback;
existingState?: AgentCreationState;
initialBalance?: number;
}): Promise<AgentRegistrationResult>;
/**
* Registers an agent with the guarded registry
* @param accountId Account ID to register
* @param inboundTopicId Inbound topic ID for the agent
* @param network Network type ('mainnet' or 'testnet')
* @param options Optional configuration including progress callback and confirmation settings
* @returns Registration result
*/
registerAgentWithGuardedRegistry(accountId: string, network?: string, options?: {
progressCallback?: RegistrationProgressCallback;
maxAttempts?: number;
delayMs?: number;
existingState?: AgentCreationState;
}): Promise<AgentRegistrationResult>;
/**
* Registers an agent with the guarded registry. Should be called by a registry.
* @param registryTopicId - The topic ID of the guarded registry.
* @param accountId - The account ID of the agent
* @param inboundTopicId - The topic ID of the inbound topic
* @param memo - The memo of the agent
* @param submitKey - The submit key of the agent
*/
registerAgent(registryTopicId: string, accountId: string, inboundTopicId: string, memo: string, submitKey?: PrivateKey): Promise<void>;
getInboundTopicType(topicId: string): Promise<InboundTopicType>;
getNetwork(): string;
getLogger(): Logger;
/**
* Public method to get the operator account ID configured for this client instance.
* @returns The operator account ID string, or null if not set.
*/
getOperatorAccountId(): string | null;
/**
* Creates a scheduled transaction from a transaction object
* @param transaction The transaction to schedule
* @param memo Optional memo to include with the scheduled transaction
* @param expirationTime Optional expiration time in seconds from now
* @returns Object with schedule ID and transaction ID
*/
private createScheduledTransaction;
/**
* Sends a transaction operation on a connection topic
* @param connectionTopicId Connection topic ID
* @param scheduleId Schedule ID of the scheduled transaction
* @param data Human-readable description of the transaction, can also be a JSON string or HRL
* @param submitKey Optional submit key
* @param options Optional parameters including memo (timestamp is no longer used here)
* @returns Transaction receipt
*/
sendTransactionOperation(connectionTopicId: string, scheduleId: string, data: string, submitKey?: PrivateKey, options?: {
memo?: string;
}): Promise<TransactionReceipt>;
/**
* Creates and sends a transaction operation in one call
* @param connectionTopicId Connection topic ID for sending the transaction operation
* @param transaction The transaction to schedule
* @param data Human-readable description of the transaction, can also be a JSON string or HRL
* @param options Optional parameters for schedule creation and operation memo
* @returns Object with schedule details (including scheduleId and its transactionId) and HCS-10 operation receipt
*/
sendTransaction(connectionTopicId: string, transaction: Transaction, data: string, options?: {
scheduleMemo?: string;
expirationTime?: number;
submitKey?: PrivateKey;
operationMemo?: string;
schedulePayerAccountId?: string;
}): Promise<{
scheduleId: string;
transactionId: string;
receipt: TransactionReceipt;
}>;
/**
* Creates a new MCP server with inbound and outbound topics.
*
* This method creates communication topics and profiles required for an MCP server,
* registers the profile with the server's account, and handles profile picture
* inscriptions if provided.
*
* @param builder The MCP server builder object
* @param ttl Optional Time-To-Live for the topic memos, defaults to 60
* @param existingState Optional existing state to resume from
* @returns Object with topic IDs
*/
createMCPServer(builder: MCPServerBuilder, ttl?: number, existingState?: Partial<MCPServerCreationState>, progressCallback?: RegistrationProgressCallback): Promise<CreateMCPServerResponse>;
/**
* Creates the base topic structure for an entity (agent or MCP server).
*
* @param ttl Time-To-Live for topic memos
* @param existingTopics Object containing any existing topic IDs to reuse
* @param accountId The account ID associated with the entity
* @param inboundTopicType Type of inbound topic
* @param feeConfig Optional fee configuration for fee-based topics
* @param pfpBuffer Optional profile picture buffer
* @param pfpFileName Optional profile picture filename
* @param progressCallback Optional callback for reporting progress
* @returns Object with created topic IDs
*/
private _createEntityTopics;
/**
* Creates and registers an MCP server with a Guarded registry.
*
* This function creates a new account if needed, initializes an HCS10 client,
* creates an MCP server with inbound and outbound topics, and registers
* it with the Hashgraph Online Guarded Registry.
*
* @param builder The MCP server builder object with configuration
* @param options Optional settings for registration process
* @returns Registration result with success status and metadata
*/
createAndRegisterMCPServer(builder: MCPServerBuilder, options?: {
baseUrl?: string;
progressCallback?: RegistrationProgressCallback;
existingState?: MCPServerCreationState;
initialBalance?: number;
}): Promise<AgentRegistrationResult>;
}
//# sourceMappingURL=sdk.d.ts.map