pharos-agent-kit
Version:
Connect AI Agents to Pharos protocols
39 lines (38 loc) • 1.32 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.PharosERC721BalanceTool = void 0;
const tools_1 = require("langchain/tools");
const zod_1 = require("zod");
const PharosERC721BalanceInputSchema = zod_1.z.object({
tokenAddress: zod_1.z.string(),
});
class PharosERC721BalanceTool extends tools_1.StructuredTool {
constructor(pharosKit) {
super();
this.pharosKit = pharosKit;
this.name = "pharos_erc721_balance";
this.description = `Get the balance of ERC721 tokens (NFTs) for the connected wallet.
Parameters:
- tokenAddress: The contract address of the NFT collection.`;
this.schema = PharosERC721BalanceInputSchema;
}
async _call(input) {
try {
const balance = await this.pharosKit.getERC721Balance(input.tokenAddress);
return JSON.stringify({
status: "success",
balance,
tokenAddress: input.tokenAddress,
});
}
catch (error) {
return JSON.stringify({
status: "error",
message: error.message,
code: error.code || "UNKNOWN_ERROR",
});
}
}
}
exports.PharosERC721BalanceTool = PharosERC721BalanceTool;
//# sourceMappingURL=balance.js.map