-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy.js
30 lines (24 loc) · 1.03 KB
/
deploy.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// Import Hardhat Runtime Environment
const hre = require("hardhat");
async function main() {
// Get the ContractFactory for your ERC20 contract
const ERC20 = await hre.ethers.getContractFactory("ERC20");
// Define constructor arguments
const tokenName = Buffer.from('MyToken','utf-8'); // Token name
const tokenSymbol = Buffer.from('MTK','utf-8'); // Token symbol
const decimals = 18; // Decimals
const totalSupplyAmount = ethers.utils.parseUnits("1000000", decimals); // Total supply (1 million tokens)
// Deploy the contract with constructor arguments
const erc20 = await ERC20.deploy(tokenName, tokenSymbol, decimals, totalSupplyAmount);
// Wait for the deployment to be confirmed
await erc20.deployed();
// Log the address of the deployed contract
console.log(`ERC20 Token deployed to: ${erc20.address}`);
}
// Execute the main function and handle errors
main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error);
process.exit(1);
});