import { Contract } from 'ethers' ; import { config , ethers , network } from 'hardhat' ; import fs from 'fs' ; async function main ( ) { fs . unlinkSync ( `${ config . paths . artifacts }/contracts/addresses/${ network . name }ContractAddress.ts` ) ; const GreeterContract = await ethers . getContractFactory ( 'Greeter' ) ; const contract = await GreeterContract . deploy ( 'Hello, Hardhat!' ) ; await contract . deployed ( ) ; console . log ( 'Greeter deployed to:' , contract . address ) ; const MyNFTContract = await ethers . getContractFactory ( 'MyNFT' ) ; const myNFTContractDeployement = await MyNFTContract . deploy ( ) ; await myNFTContractDeployement . deployed ( ) ; console . log ( 'MyNFT deployed to:' , myNFTContractDeployement . address ) ; const MulticallContract = await ethers . getContractFactory ( 'Multicall' ) ; const multiCallContract = await MulticallContract . deploy ( ) ; await multiCallContract . deployed ( ) ; console . log ( 'Multicall deployed to:' , multiCallContract . address ) ; saveFrontendFiles ( contract , "GreeterContract" ) ; saveFrontendFiles ( myNFTContractDeployement , "MyNFTContract" ) ; saveFrontendFiles ( multiCallContract , "MulticallContract" ) ; } function saveFrontendFiles ( contract , contractName ) { fs . appendFileSync ( `${ config . paths . artifacts }/contracts/addresses/${ network . name }ContractAddress.ts` , `export const ${ contractName }Address = '${ contract . address }'\n` ) ; } main ( ) . then ( ( ) => process . exit ( 0 ) ) . catch ( ( error ) => { console . error ( error ) ; process . exit ( 1 ) ; } ) ;