sei-agent-kit
Version:
A package for building AI agents on the SEI blockchain
49 lines (48 loc) • 1.8 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.SeiERC721TransferTool = void 0;
const tools_1 = require("langchain/tools");
const zod_1 = require("zod");
const SeiERC721TransferInputSchema = 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 SeiERC721TransferTool extends tools_1.StructuredTool {
constructor(seiKit) {
super();
this.seiKit = seiKit;
this.name = "sei_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 = SeiERC721TransferInputSchema;
}
async _call(input) {
try {
const transfer = await this.seiKit.ERC721Transfer(input.amount, input.recipient, 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.SeiERC721TransferTool = SeiERC721TransferTool;
//# sourceMappingURL=transfer.js.map