`hardhat etherscan-verify` is not working with the error of "Compiled contract deployment bytecode does NOT match the transaction deployment bytecode" #516
The bytecode generated subtly changes between tools. If you deployed through HH deploy you should try verifying through Hardhat deploys verification command.
Using this tool, I'm trying to verify the deployed contract on the etherscan.
In the past, I can successfully verify every deployed contracts but now I can't verify and I'm getting the following error.
I tried soon after deploy contract without any code changes.
verifying SturdyLeverage (0xC7a65E66CcBA7499B3CED993195f3670dead97dd) ...
waiting for result...
Failed to verify contract SturdyLeverage: NOTOK, Fail - Unable to verify. Solidity Compilation Error: Library entry is not a JSON object.
{
"apikey": "XXXXXX",
"module": "contract",
"action": "verifysourcecode",
"contractaddress": "0xC7a65E66CcBA7499B3CED993195f3670dead97dd",
"sourceCode": "...",
"codeformat": "solidity-standard-json-input",
"contractname": "contracts/src/leverages/SturdyLeverage.sol:SturdyLeverage",
"compilerversion": "v0.8.21+commit.d9974bed",
"licenseType": 13
}
Falling back on solcInput. etherscan seems to sometime require full solc-input with all source files, even though this should not be needed. See https://github.com/ethereum/solidity/issues/9573
verifying SturdyLeverage (0xC7a65E66CcBA7499B3CED993195f3670dead97dd) ...
waiting for result...
Failed to verify contract SturdyLeverage: NOTOK, Fail - Unable to verify. Please check for missing Library or invalid name (i.e names are case senstive). Library was required but suitable match not found
{
"apikey": "XXXXXX",
"module": "contract",
"action": "verifysourcecode",
"contractaddress": "0xC7a65E66CcBA7499B3CED993195f3670dead97dd",
"sourceCode": "...",
"codeformat": "solidity-standard-json-input",
"contractname": "contracts/src/leverages/SturdyLeverage.sol:SturdyLeverage",
"compilerversion": "v0.8.21+commit.d9974bed",
"licenseType": 13
}
When I try directly on the etherscan using the Standard-Json-Input file.
I'm getting the following error.
Unable to verify. Compiled contract deployment bytecode does NOT match the transaction deployment bytecode.
I don't understand why the bytecode NOT match.
versions
hardhat-deploy [0.11.43]
hardhat [2.18.1]
nodejs [18.17.0]
Additional context
I tried using the following command.
npx hardhat --network main etherscan-verify --contract-name SturdyLeverage --solc-input --write-post-data
And got the above same error as well.
But I can get the post-data in etherscan_requests/main/SturdyLeverage.json
SturdyLeverage.json
Looks like, in the json file, there is no problem for the libraries.
Describe the bug
Using this tool, I'm trying to verify the deployed contract on the etherscan. In the past, I can successfully verify every deployed contracts but now I can't verify and I'm getting the following error. I tried soon after deploy contract without any code changes.
When I try directly on the etherscan using the Standard-Json-Input file. I'm getting the following error.
Unable to verify. Compiled contract deployment bytecode does NOT match the transaction deployment bytecode.
I don't understand why the bytecode NOT match.versions
Additional context I tried using the following command.
npx hardhat --network main etherscan-verify --contract-name SturdyLeverage --solc-input --write-post-data
And got the above same error as well. But I can get the post-data in etherscan_requests/main/SturdyLeverage.json SturdyLeverage.json Looks like, in the json file, there is no problem for the libraries.