mirror of
https://github.com/d0zingcat/solana-agent-kit.git
synced 2026-05-30 15:11:22 +00:00
32 lines
831 B
TypeScript
32 lines
831 B
TypeScript
import { Tool } from "langchain/tools";
|
|
import { SolanaAgentKit } from "../../agent";
|
|
|
|
export class SolanaTokenDataByTickerTool extends Tool {
|
|
name = "solana_token_data_by_ticker";
|
|
description = `Get the token data for a given token ticker
|
|
|
|
Inputs: ticker is required.
|
|
ticker: string, eg "USDC" (required)`;
|
|
|
|
constructor(private solanaKit: SolanaAgentKit) {
|
|
super();
|
|
}
|
|
|
|
protected async _call(input: string): Promise<string> {
|
|
try {
|
|
const ticker = input.trim();
|
|
const tokenData = await this.solanaKit.getTokenDataByTicker(ticker);
|
|
return JSON.stringify({
|
|
status: "success",
|
|
tokenData,
|
|
});
|
|
} catch (error: any) {
|
|
return JSON.stringify({
|
|
status: "error",
|
|
message: error.message,
|
|
code: error.code || "UNKNOWN_ERROR",
|
|
});
|
|
}
|
|
}
|
|
}
|