@hashgraphonline/standards-agent-kit
Version:
A modular SDK for building on-chain autonomous agents using Hashgraph Online Standards, including HCS-10 for agent discovery and communication.
55 lines (54 loc) • 2.25 kB
JavaScript
import { z } from "zod";
import { BaseHCS6TransactionTool } from "./standards-agent-kit.es27.js";
const RegisterDynamicHashinalSchema = z.object({
metadata: z.record(z.unknown()).describe("Metadata object for the hashinal (e.g., name, description, attributes)"),
data: z.object({
base64: z.string().optional().describe("Base64 encoded data for the hashinal"),
url: z.string().optional().describe("URL to fetch data from"),
mimeType: z.string().optional().describe("MIME type of the data")
}).optional().describe("Data to inscribe with the hashinal"),
memo: z.string().optional().describe("Optional memo for the registration"),
ttl: z.number().min(3600).default(86400).describe("Time-to-live in seconds for the inscription"),
registryTopicId: z.string().optional().describe("Registry topic ID to use. If not provided, a new registry will be created"),
submitKey: z.string().optional().describe("Submit key for the registry (required if registry has a submit key)")
});
class RegisterDynamicHashinalTool extends BaseHCS6TransactionTool {
constructor(params) {
super(params);
this.name = "registerDynamicHashinal";
this.description = "Create and register a new dynamic hashinal that can be updated over time";
this.schema = RegisterDynamicHashinalSchema;
}
async _call(params) {
try {
const result = await this.hcs6Builder.register({
metadata: params.metadata,
data: params.data,
memo: params.memo,
ttl: params.ttl,
registryTopicId: params.registryTopicId,
submitKey: params.submitKey
});
if (!result.success || !result.registryTopicId || !result.inscriptionTopicId) {
throw new Error(result.error || "Failed to register dynamic hashinal");
}
return {
status: "success",
data: {
registryTopicId: result.registryTopicId,
inscriptionTopicId: result.inscriptionTopicId,
transactionId: result.transactionId
}
};
} catch (error) {
return {
status: "error",
message: error instanceof Error ? error.message : "Unknown error"
};
}
}
}
export {
RegisterDynamicHashinalTool
};
//# sourceMappingURL=standards-agent-kit.es29.js.map