Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hardhat etherscan-verify is not working with the error of "Compiled contract deployment bytecode does NOT match the transaction deployment bytecode" #516

Open
iris112 opened this issue Feb 27, 2024 · 0 comments

Comments

@iris112
Copy link

iris112 commented Feb 27, 2024

Describe the bug

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant