sei-agent-kit
Version:
A package for building AI agents on the SEI blockchain
46 lines (45 loc) • 1.59 kB
JavaScript
import { StructuredTool } from "langchain/tools";
import { z } from "zod";
const SeiERC721TransferInputSchema = z.object({
amount: z.string().min(1, "Amount must not be empty"),
recipient: z.string(),
tokenAddress: z.string(),
tokenId: z.string().min(1, "Token ID must not be empty"),
});
export class SeiERC721TransferTool extends StructuredTool {
seiKit;
name = "sei_erc721_transfer";
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.`;
schema = SeiERC721TransferInputSchema;
constructor(seiKit) {
super();
this.seiKit = seiKit;
}
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",
});
}
}
}
//# sourceMappingURL=transfer.js.map