You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
Incorrect evaluation of the etherscanApiKey when verifying contracts.
To Reproduce
Steps to reproduce the behavior:
Attempt to verify a contract on a different network than mainnet (base, arbitrum, polygon, etc.) with correctly set hardhat configuration (hh.network.verify.etherscan.apiKey) and valid api key leads to error: failed to submit : "NOTOK" : "Invalid API Key"
Expected behavior
Should verify contract as expected.
** More context **
The code down below (line 857 in index.ts) evaluates the etherscanApiKey based on 4 fields in the order:
command line argument apiKey
If ETHERSCAN_API_KEY is present
hre.network.verify.etherscan.apiKey
hre.config.verify.etherscan.apiKey
Which means if you have set ETHERSCAN_API_KEY for mainnet, and an api key for another network in the hardhat config, the api key deduced will be the mainnet one and the verification will fail with invalid key.
.setAction(async (args, hre) => {
const etherscanApiKey =
args.apiKey ||
process.env.ETHERSCAN_API_KEY ||
hre.network.verify?.etherscan?.apiKey ||
hre.config.verify?.etherscan?.apiKey;
if (!etherscanApiKey) {
throw new Error(
`No Etherscan API KEY provided. Set it through command line option, in hardhat.config.ts, or by setting the "ETHERSCAN_API_KEY" env variable`
);
}
const solcInputsPath = await deploymentsManager.getSolcInputPath();
await submitSources(hre, solcInputsPath, {
contractName: args.contractName,
etherscanApiKey,
license: args.license,
fallbackOnSolcInput: args.solcInput,
forceLicense: args.forceLicense,
sleepBetween: args.sleep,
apiUrl: args.apiUrl || hre.network.verify?.etherscan?.apiUrl,
writePostData: args.writePostData,
});
});
versions
hardhat-deploy [0.11.44]
hardhat [2.15.0]
nodejs [16.18.01]
The text was updated successfully, but these errors were encountered:
Describe the bug
Incorrect evaluation of the etherscanApiKey when verifying contracts.
To Reproduce
Steps to reproduce the behavior:
Attempt to verify a contract on a different network than mainnet (base, arbitrum, polygon, etc.) with correctly set hardhat configuration (
hh.network.verify.etherscan.apiKey
) and valid api key leads to error:failed to submit : "NOTOK" : "Invalid API Key"
Expected behavior
Should verify contract as expected.
** More context **
The code down below (line 857 in index.ts) evaluates the
etherscanApiKey
based on 4 fields in the order:Which means if you have set
ETHERSCAN_API_KEY
for mainnet, and an api key for another network in the hardhat config, the api key deduced will be the mainnet one and the verification will fail with invalid key.versions
The text was updated successfully, but these errors were encountered: