diff --git a/deploy/deploy-metadata.js b/deploy/deploy-metadata.js new file mode 100644 index 0000000..69f9472 --- /dev/null +++ b/deploy/deploy-metadata.js @@ -0,0 +1,35 @@ +const hre = require('hardhat'); +// const { ethers } = hre; +const { getChainId } = hre; + +module.exports = async ({ deployments, getNamedAccounts }) => { + const networkName = hre.network.name; + console.log(`running ${networkName} deploy script`); + const chainId = await getChainId(); + console.log('network id ', chainId); + if (chainId !== hre.config.networks[networkName].chainId.toString()) { + console.log(`network chain id: ${hre.config.networks[networkName].chainId}, your chain id ${chainId}`); + console.log('skipping wrong chain id deployment'); + return; + } + + const { deploy } = deployments; + const { deployer } = await getNamedAccounts(); + + const contractName = 'AddressTokenMetadata'; + const contract = await deploy('AddressTokenMetadata', { + from: deployer, + contract: contractName, + skipIfAlreadyDeployed: true, + }); + + console.log(`${contractName} deployed to: ${contract.address}`); + + if (chainId !== '31337') { + await hre.run('verify:verify', { + address: contract.address, + }); + } +}; + +module.exports.skip = async () => true; diff --git a/hardhat.networks.js b/hardhat.networks.js index 97f985f..97e7ad5 100644 --- a/hardhat.networks.js +++ b/hardhat.networks.js @@ -1,18 +1,23 @@ const networks = { - // Uncomment this to use hardhat forking // hardhat: { // forking: { // url: process.env.MAINNET_RPC_URL, + // httpHeaders: { + // 'auth-key': process.env.RPC_AUTH_HEADER, + // }, // }, // chainId: Number(process.env.FORK_CHAIN_ID) || 31337, // }, }; -const etherscan = { apiKey: {} }; +const etherscan = { apiKey: {}, customChains: [] }; function register (name, chainId, url, privateKey, etherscanNetworkName, etherscanKey) { if (url && privateKey && etherscanKey) { networks[name] = { url, + httpHeaders: { + 'auth-key': process.env.RPC_AUTH_HEADER, + }, chainId, accounts: [privateKey], }; @@ -36,10 +41,11 @@ register('kovan', 42, process.env.KOVAN_RPC_URL, process.env.KOVAN_PRIVATE_KEY, register('optimistic', 10, process.env.OPTIMISTIC_RPC_URL, process.env.OPTIMISTIC_PRIVATE_KEY, 'optimisticEthereum', process.env.OPTIMISTIC_ETHERSCAN_KEY); register('matic', 137, process.env.MATIC_RPC_URL, process.env.MATIC_PRIVATE_KEY, 'polygon', process.env.MATIC_ETHERSCAN_KEY); register('arbitrum', 42161, process.env.ARBITRUM_RPC_URL, process.env.ARBITRUM_PRIVATE_KEY, 'arbitrumOne', process.env.ARBITRUM_ETHERSCAN_KEY); -register('xdai', 100, process.env.XDAI_RPC_URL, process.env.XDAI_PRIVATE_KEY, 'xdai', process.env.XDAI_ETHERSCAN_KEY); +register('xdai', 100, process.env.XDAI_RPC_URL, process.env.XDAI_PRIVATE_KEY, 'gnosis', process.env.XDAI_ETHERSCAN_KEY); register('avax', 43114, process.env.AVAX_RPC_URL, process.env.AVAX_PRIVATE_KEY, 'avalanche', process.env.AVAX_ETHERSCAN_KEY); register('fantom', 250, process.env.FANTOM_RPC_URL, process.env.FANTOM_PRIVATE_KEY, 'opera', process.env.FANTOM_ETHERSCAN_KEY); register('aurora', 1313161554, process.env.AURORA_RPC_URL, process.env.AURORA_PRIVATE_KEY, 'aurora', process.env.AURORA_ETHERSCAN_KEY); +register('base', 8453, process.env.BASE_RPC_URL, process.env.BASE_PRIVATE_KEY, 'base', process.env.BASE_ETHERSCAN_KEY); registerCustom('klaytn', 8217, process.env.KLAYTN_RPC_URL, process.env.KLAYTN_PRIVATE_KEY, process.env.KLAYTN_ETHERSCAN_KEY, 'https://scope.klaytn.com/', 'https://scope.klaytn.com/'); module.exports = {