mirror of
https://github.com/d0zingcat/solana-agent-kit.git
synced 2026-05-13 23:16:55 +00:00
36 lines
995 B
TypeScript
36 lines
995 B
TypeScript
import { PublicKey } from "@solana/web3.js";
|
|
import { Tool } from "langchain/tools";
|
|
import { SolanaAgentKit } from "../../agent";
|
|
|
|
export class SolanaGetMainDomain extends Tool {
|
|
name = "solana_get_main_domain";
|
|
description = `Get the main/favorite domain for a given wallet address.
|
|
|
|
Inputs:
|
|
owner: string, eg "4Be9CvxqHW6BYiRAxW9Q3xu1ycTMWaL5z8NX4HR3ha7t" (required)`;
|
|
|
|
constructor(private solanaKit: SolanaAgentKit) {
|
|
super();
|
|
}
|
|
|
|
async _call(input: string): Promise<string> {
|
|
try {
|
|
const ownerPubkey = new PublicKey(input.trim());
|
|
const mainDomain =
|
|
await this.solanaKit.getMainAllDomainsDomain(ownerPubkey);
|
|
|
|
return JSON.stringify({
|
|
status: "success",
|
|
message: "Main domain fetched successfully",
|
|
domain: mainDomain,
|
|
});
|
|
} catch (error: any) {
|
|
return JSON.stringify({
|
|
status: "error",
|
|
message: error.message,
|
|
code: error.code || "FETCH_MAIN_DOMAIN_ERROR",
|
|
});
|
|
}
|
|
}
|
|
}
|