sei-agent-kit
Version:
A package for building AI agents on the SEI blockchain
46 lines (45 loc) • 1.67 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.SeiERC20TransferTool = void 0;
const tools_1 = require("langchain/tools");
const zod_1 = require("zod");
const SeiERC20TransferInputSchema = zod_1.z.object({
amount: zod_1.z.string().min(1, "Amount must not be empty"),
recipient: zod_1.z.string(),
ticker: zod_1.z.string().optional(),
});
class SeiERC20TransferTool extends tools_1.StructuredTool {
constructor(seiKit) {
super();
this.seiKit = seiKit;
this.name = "sei_erc20_transfer";
this.description = `Transfer tokens to another Sei wallet.
Parameters:
- amount: The amount of tokens to transfer as a string (e.g., "1.5") (required).
- recipient: The recipient's wallet address (required).
- ticker: Optional. The token symbol/ticker (e.g., "USDC"). Do not specify for native SEI token transfers.`;
this.schema = SeiERC20TransferInputSchema;
}
async _call(input) {
try {
const transfer = await this.seiKit.ERC20Transfer(input.amount, input.recipient, input.ticker);
if (!transfer) {
throw new Error("Transfer failed");
}
return JSON.stringify({
status: "success",
transfer,
token: input?.ticker ?? "SEI",
});
}
catch (error) {
return JSON.stringify({
status: "error",
message: error.message,
code: error?.code ?? "UNKNOWN_ERROR",
});
}
}
}
exports.SeiERC20TransferTool = SeiERC20TransferTool;
//# sourceMappingURL=transfer.js.map