wighawag / hardhat-deploy

hardhat deployment plugin
MIT License
1.2k stars 296 forks source link

Get etherscan-api-key from network config #236

Closed zapaz closed 2 years ago

zapaz commented 2 years ago

As ETHERSCAN_API_KEY may differ from one network to another, put an etherscan option in network config, with highest priority than generic config

hardhat.config.ts may look like this :

...
networks : {
  mainnet: {
    chainId: 1,
    url: `https://eth-mainnet.alchemyapi.io/v2/${process.env.ALCHEMY_API_KEY}`,
    accounts
  },
  rinkeby: {
    chainId: 4,
    url: `https://eth-rinkeby.alchemyapi.io/v2/${process.env.ALCHEMY_API_KEY}`,
    accounts
  },  
  matic: {
    chainId: 137,
    url: `https://polygon-mainnet.infura.io/v3/${process.env.INFURA_API_KEY}`,
    etherscan: { apiKey: process.env.ETHERSCAN_API_KEY_POLYGON },
    accounts
  },
  avalanche: {
    chainId: 43114,
    url: "https://api.avax.network/ext/bc/C/rpc",
    etherscan: { apiKey: process.env.ETHERSCAN_API_KEY_AVALANCHE },
    accounts
  },
}
etherscan: { apiKey: process.env.ETHERSCAN_API_KEY_ETHEREUM }
...
zapaz commented 2 years ago

Follow up of #98

wighawag commented 2 years ago

Thanks @zapaz !

wighawag commented 2 years ago

added in hardhat-deploy 0.9.18