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-verify is not working with the error of "Compiled contract deployment bytecode does NOT match the transaction deployment bytecode" #4918

Closed
iris112 opened this issue Feb 22, 2024 · 10 comments
Assignees
Labels
status:needs-more-info There's not enough information to start working on this issue

Comments

@iris112
Copy link

iris112 commented Feb 22, 2024

Version of Hardhat

2.17.3

What happened?

I'm using the [email protected] 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 error.

Reason: Fail - Unable to verify. Compiled contract deployment bytecode does NOT match the transaction deployment bytecode.

Minimal reproduction steps

After deploy the contract on the ethereum mainnet using the hardhat-deploy, I tried run the following command to verify the contract.
npx hardhat verify CONTRACT_ADDRESS

But I'm getting the following error.

[INFO] Sourcify Verification Skipped: Sourcify verification is currently disabled. To enable it, add the following entry to your Hardhat configuration:

sourcify: {
  enabled: true
}

Or set 'enabled' to false to hide this message.

For more information, visit https://hardhat.org/hardhat-runner/plugins/nomicfoundation-hardhat-verify#verifying-on-sourcify
Successfully submitted source code for contract
contracts/src/leverages/SturdyLeverage.sol:SturdyLeverage at 0xC7a65E66CcBA7499B3CED993195f3670dead97dd
for verification on the block explorer. Waiting for verification result...

hardhat-verify found one or more errors during the verification process:

Etherscan:
An unexpected error occurred during the verification process.
Please report this issue to the Hardhat team.
Error Details: An unexpected error occurred during the verification process.
Please report this issue to the Hardhat team.
Error Details: An unexpected error occurred during the verification process.
Please report this issue to the Hardhat team.
Error Details: An unexpected error occurred during the verification process.
Please report this issue to the Hardhat team.
Error Details: The Etherscan API responded with a failure status.
The verification may still succeed but should be checked manually.
Reason: Fail - Unable to verify. Compiled contract deployment bytecode does NOT match the transaction deployment bytecode.

Search terms

No response

@kanej
Copy link
Member

kanej commented Feb 22, 2024

Is this repo open source? Can you point us at it, or share the code of the sturdy leverage contract?

@schaable schaable added status:needs-more-info There's not enough information to start working on this issue and removed status:triaging labels Feb 22, 2024
@iris112
Copy link
Author

iris112 commented Feb 23, 2024

I tried using the Standard-Json-Input file.
I attached the json file.
1.json

@kanej
Copy link
Member

kanej commented Feb 23, 2024

I tried using the Standard-Json-Input file. I attached the json file. 1.json

Have you tried verifying using that json file directly on etherscan? If it gives the same error then this is not a hardhat-verify issue.

The error:

Reason: Fail - Unable to verify. Compiled contract deployment bytecode does NOT match the transaction deployment bytecode.

This suggests that the compiled bytecode for the contract is not exactly the same as the bytecode in the deployment transaction on chain. This can happen if there are any source code changes at all (comments and whitespace included) in any of the files in that json object.

@iris112
Copy link
Author

iris112 commented Feb 23, 2024

Sure, I tried on etherscan and saw the error as well.
But It has the same source code (I checked every files) and I tried to verify the contract right after deploy with same code.
So I'm wondering why the bytecode does NOT match.
I deployed the contract using the hardhat-deploy.

@kanej
Copy link
Member

kanej commented Feb 23, 2024

The bytecode generated subtly changes between tools. If you deployed through HH deploy you should try verifying through Hardhat deploys verification command.

@iris112
Copy link
Author

iris112 commented Feb 23, 2024

when we can use the hardhat-verify?

@iris112
Copy link
Author

iris112 commented Feb 23, 2024

The bytecode generated subtly changes between tools. If you deployed through HH deploy you should try verifying through Hardhat deploys verification command.

I tried using this tool as well, now I'm getting the following error.

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
}

@kanej
Copy link
Member

kanej commented Feb 26, 2024

I am unsure, the complaint is that the libraries object that is being passed in your json input is invalid, it is missing paths. But I have limited knowledge of hardhat-deploy.

I would try on the #hardhat-deploy discord channel, and see if the community has any suggestions.

@iris112
Copy link
Author

iris112 commented Feb 26, 2024

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.
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.

@schaable
Copy link
Member

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.

hi @iris112, that command is part of hardhat-deploy, which is a community plugin. If you need more help, I suggest you to ask on the #hardhat-deploy discord channel or to submit an issue on their repo.

@github-project-automation github-project-automation bot moved this from Backlog to Done in Hardhat Feb 27, 2024
@schaable schaable closed this as not planned Won't fix, can't repro, duplicate, stale Feb 27, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 28, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status:needs-more-info There's not enough information to start working on this issue
Projects
Archived in project
Development

No branches or pull requests

3 participants