pharos-agent-kit
Version:
Connect AI Agents to Pharos protocols
49 lines (48 loc) • 1.85 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.PharosERC721TransferTool = void 0;
const tools_1 = require("langchain/tools");
const zod_1 = require("zod");
const PharosERC721TransferInputSchema = zod_1.z.object({
amount: zod_1.z.string().min(1, "Amount must not be empty"),
recipient: zod_1.z.string(),
tokenAddress: zod_1.z.string(),
tokenId: zod_1.z.string().min(1, "Token ID must not be empty"),
});
class PharosERC721TransferTool extends tools_1.StructuredTool {
constructor(pharosKit) {
super();
this.pharosKit = pharosKit;
this.name = "pharos_erc721_transfer";
this.description = `Transfer an NFT (ERC721 token) to another wallet address.
Parameters:
- amount: The amount to transfer as a string (typically "1" for NFTs).
- recipient: The recipient's wallet address.
- tokenAddress: The NFT contract address.
- tokenId: The ID of the specific NFT to transfer as a string.`;
this.schema = PharosERC721TransferInputSchema;
}
async _call(input) {
try {
const transfer = await this.pharosKit.transferERC721(input.recipient, Number(input.amount), input.tokenAddress, input.tokenId);
if (!transfer) {
throw new Error("Transfer failed");
}
return JSON.stringify({
status: "success",
transfer,
tokenAddress: input.tokenAddress,
tokenId: input.tokenId,
});
}
catch (error) {
return JSON.stringify({
status: "error",
message: error.message,
code: error.code || "UNKNOWN_ERROR",
});
}
}
}
exports.PharosERC721TransferTool = PharosERC721TransferTool;
//# sourceMappingURL=transfer.js.map