@agentek/tools
Version:
Blockchain tools for AI agents
53 lines • 2.17 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.intentCreateCoinToken = void 0;
const client_js_1 = require("../client.js");
const zod_1 = require("zod");
const viem_1 = require("viem");
const constants_js_1 = require("./constants.js");
const utils_js_1 = require("../utils.js");
const intentCreateCoinTokenParameters = zod_1.z.object({
chainId: zod_1.z.number().describe("The chainId to deploy on e.g. 1 (mainnet), 8453 (base)"),
name: zod_1.z.string().describe("Token name"),
symbol: zod_1.z.string().describe("Token symbol"),
tokenURI: zod_1.z.string().describe("Metadata URI"),
owner: utils_js_1.addressSchema.describe("Owner address"),
supply: zod_1.z.string().describe("Initial supply as a human readable string (e.g., '1000')"),
});
exports.intentCreateCoinToken = (0, client_js_1.createTool)({
name: "intentCreateCoinToken",
description: "Creates a new ERC6909 token inside the Coins contract with a name, symbol, metadata URI, owner, and initial supply.",
parameters: intentCreateCoinTokenParameters,
execute: async (client, args) => {
const { chainId, name, symbol, tokenURI, owner, supply } = args;
const walletClient = client.getWalletClient(chainId);
const data = (0, viem_1.encodeFunctionData)({
abi: constants_js_1.coinsAbi,
functionName: "create",
args: [name, symbol, tokenURI, owner, (0, viem_1.parseEther)(supply)],
});
const ops = [
{
target: constants_js_1.COINS_ADDRESS,
value: "0",
data,
},
];
const description = `🪙 Creating "${name}" token (${symbol}) \n💰 Initial supply: ${supply} \n👤 Owner: ${owner}`;
if (!walletClient) {
return {
intent: description,
ops,
chain: chainId,
};
}
const hash = await client.executeOps(ops, chainId);
return {
intent: description,
ops,
chain: chainId,
hash,
};
},
});
//# sourceMappingURL=intents.js.map