Closed matmilbury closed 2 years ago
ETHERSCAN_API_KEY takes precedence (See : https://github.com/wighawag/hardhat-deploy/blob/240de8a0d70b313617ea179872c51457186ef91c/src/index.ts#L837-L841), use a different env variable name if you want to keep you config as is
@wighawag I know, I already looked in the code 😄
I suggest updating that behavior to:
const etherscanApiKey =
args.apiKey ||
hre.network.verify?.etherscan?.apiKey ||
hre.config.verify?.etherscan?.apiKey ||
process.env.ETHERSCAN_API_KEY;
I disagree, env variable should take precedence over configuration files
I respectfully disagree.
But hey, you're the boss here.
I'd at least recommend documenting this bahvior to save folks from debugging and digging through the source code when the verification doesn't work the way they configured.
This is expected behaviour in my opinion and what most tool do (git, node,....)
Simply because an env variable is more specific that a config file (env var are specific to a specific shell session, while a config file is more general)
I ll close this but feel free to create a PR for improving the doc
Describe the bug I have both
ETHERSCAN_API_KEY
andBSCSCAN_API_KEY
specified in my.env
file.I also have this in my configuration:
When I run
yarn hardhat --network bsc etherscan-verify
, it tries to useETHERSCAN_API_KEY
instead ofBSCSCAN_API_KEY
.Expected behavior hardhat config should take presedence over env variable.