Token-Creator/scripts/create-token.js
2024-08-25 14:33:55 +03:00

23 lines
700 B
JavaScript

const TokenFactory = artifacts.require("TokenFactory");
module.exports = async function(callback) {
try {
const tokenFactory = await TokenFactory.deployed();
const tokenName = "My Token";
const tokenSymbol = "MTK";
const initialSupply = web3.utils.toWei("1000000", "ether"); // 1 million tokens
console.log(`Creating token: ${tokenName} (${tokenSymbol})`);
const tx = await tokenFactory.createToken(tokenName, tokenSymbol, initialSupply);
console.log(`Token created! Transaction: ${tx.tx}`);
console.log(`Token address: ${tx.logs[0].args.tokenAddress}`);
callback();
} catch (error) {
console.error(error);
callback(error);
}
};