10grans-ng/scripts/deploy-l1.ts

35 lines
955 B
TypeScript
Raw Normal View History

2023-08-20 13:46:39 +00:00
import { ethers } from "hardhat";
import fs from "fs/promises";
async function main() {
const env = process.env.NODE_ENV || "local";
if (!process.env.TOKEN_NAME) throw "Token name not defined";
if (!process.env.TOKEN_SYMBOL) throw "Token symbol not defined";
if (!process.env.TOKEN_AMOUNT) throw "Token amount not defined";
const tokenAmount = parseInt(process.env.TOKEN_AMOUNT);
const L1Token = await ethers.deployContract(
"L1Token",
[
process.env.TOKEN_NAME,
process.env.TOKEN_SYMBOL,
tokenAmount,
]
);
await L1Token.waitForDeployment();
const deployedAddress = await L1Token.getAddress();
console.log(`L1 token deployed to: ${deployedAddress}`);
await fs.writeFile(`.l1-token-address.${env}`, deployedAddress);
}
// We recommend this pattern to be able to use async/await everywhere
// and properly handle errors.
main().catch((error) => {
console.error(error);
process.exitCode = 1;
});