pharos-agent-kit
Version:
Connect AI Agents to Pharos protocols
48 lines (47 loc) • 1.65 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.PharosERC721MintTool = void 0;
const tools_1 = require("langchain/tools");
const zod_1 = require("zod");
const PharosERC721MintInputSchema = zod_1.z.object({
recipient: zod_1.z.string(),
tokenAddress: zod_1.z.string(),
tokenId: zod_1.z.string().or(zod_1.z.number()),
});
class PharosERC721MintTool extends tools_1.StructuredTool {
constructor(pharosKit) {
super();
this.pharosKit = pharosKit;
this.name = "pharos_erc721_mint";
this.description = `Mint an NFT (ERC721 token).
Parameters:
- recipient: The wallet address that will receive the minted NFT.
- tokenAddress: The NFT contract address.
- tokenId: The ID of the NFT to mint.`;
this.schema = PharosERC721MintInputSchema;
}
async _call(input) {
try {
const mint = await this.pharosKit.mintERC721(input.recipient, input.tokenAddress, BigInt(input.tokenId));
if (mint === "") {
throw new Error("Minting failed");
}
return JSON.stringify({
status: "success",
mint,
recipient: input.recipient,
tokenAddress: input.tokenAddress,
tokenId: input.tokenId,
});
}
catch (error) {
return JSON.stringify({
status: "error",
message: error.message,
code: error.code || "UNKNOWN_ERROR",
});
}
}
}
exports.PharosERC721MintTool = PharosERC721MintTool;
//# sourceMappingURL=mint.js.map