wighawag / hardhat-deploy

hardhat deployment plugin
MIT License
1.17k stars 283 forks source link

fix etherscan api key evaluation order #503

Closed ivanzhelyazkov closed 6 months ago

ivanzhelyazkov commented 6 months ago

Fix etherscan api key evaluation order - based on #502

wighawag commented 6 months ago

I disagree with the solution:

The env variable should have higher properties than config

ivanzhelyazkov commented 6 months ago

Okay, but it overrides different network api keys.

Consider a setup where you have an ETHERSCAN_API_KEY env and BASESCAN_API_KEY env - you've set the basescan api key to be read in the network as per the documentation, but the etherscan api key overrides it, failing the verification and potentially causing hours of debugging.

This way a multi-network deployment setup has to be configured specifically with mainnet api key env name different than ETHERSCAN_API_KEY, otherwise it won't work.

wighawag commented 6 months ago

BASESCAN_API_KEY is not read by hardhat-deploy

The way I handle etherscan api keys across multiple network is to have a env loader that use .env.<network-name> files and set ETHERSCAN_API_KEY for each network this way

You can also use your own env var setup and use the hardhat.config to use them per network

ivanzhelyazkov commented 6 months ago

Ah I see, thanks for the clarification. Are there docs for this ?

wighawag commented 6 months ago

No unfortunately, there is no doc for this yet.

ivanzhelyazkov commented 6 months ago

Maybe I can add this to the readme instead ?

ivanzhelyazkov commented 6 months ago

PR implemented: https://github.com/wighawag/hardhat-deploy/pull/504 Closing this