import*as dotenv from"dotenv";import { HardhatUserConfig, task } from"hardhat/config";import"@nomiclabs/hardhat-etherscan";import"@nomiclabs/hardhat-waffle";import"@typechain/hardhat";import"hardhat-gas-reporter";import"solidity-coverage";dotenv.config();// This is a sample Hardhat task. To learn how to create your own go to// <https://hardhat.org/guides/create-task.html>task("accounts","Prints the list of accounts",async (taskArgs, hre) => {constaccounts=awaithre.ethers.getSigners();for (constaccountof accounts) {console.log(account.address); }});// You need to export an object to set up your config// Go to <https://hardhat.org/config/> to learn moreconstconfig:HardhatUserConfig= { solidity:"0.8.9", networks: { titan: { url:`${process.env.ETH_NODE_URI_TITAN}`, accounts: [`${process.env.PRIVATE_KEY}`], chainId:55004 }, titangoerli: { url:`${process.env.ETH_NODE_URI_TITAN_GOERLI}`, accounts: [`${process.env.PRIVATE_KEY}`], chainId:5050 }, }, gasReporter: { enabled:process.env.REPORT_GAS!==undefined, currency:"USD", }, etherscan: { apiKey: { "titangoerli":"verify","titan":"verify" } , customChains: [ { network:"titangoerli", chainId:5050, urls: { apiURL:"<https://goerli.explorer.tokamak.network/api>", browserURL:"<https://goerli.explorer.tokamak.network>" } }, { network:"titan", chainId:55004, urls: { apiURL:"<https://explorer.titan.tokamak.network/api>", browserURL:"<https://explorer.titan.tokamak.network>" } } ] },};exportdefault config;
위에서 작성한 L2CustomERC20 컨트랙트를 배포하는 샘플 스크립트입니다. scripts/deploy.ts
import { ethers } from"hardhat";asyncfunctionmain() {constL1TokenAddress="0x07865c6e87b9f70255377e024ace6630c1eaa37f";constTokenName="USDC Sample";constTokenSymbol="USDC";// We get the contract to deployconstL2CustomERC20Factory=awaitethers.getContractFactory("L2CustomERC20");constL2CustomERC20=awaitL2CustomERC20Factory.deploy( L1TokenAddress, TokenName, TokenSymbol );awaitL2CustomERC20.deployed();console.log("L2CustomERC20 deployed to:",L2CustomERC20.address);}// 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;});