#7730·hardhat

Improve error message when contracts are compiled with one profile but verified with another

Author: schaableCreated Nov 27, 2025Updated Aug 25, 2026
Labelsarea:hardhat-verify_priority:P2

Describe the issue

If a contract is compiled with one build profile but verified with another, users get a generic bytecode mismatch error:

HHE80024: The contract verification status polling encountered an error:  "Fail - Unable to verify. Compiled contract deployment bytecode does NOT match the transaction deployment bytecode.". Verification may still succeed.

This happens because the contract passes our internal bytecode comparison (which only checks the executable section) but fails on Etherscan, which compares the full bytecode including metadata. We should detect this profile mismatch earlier and throw a clear error explaining that the deployed contract was compiled with a different build profile than the one being used for verification.

Reproduction steps:

  1. Run pnpm hardhat compile (uses default build profile)
  2. Deploy via a task or script (uses default build profile)
  3. Run pnpm hardhat verify ADDRESS (uses the production profile by default)

Originally reported in https://github.com/NomicFoundation/hardhat/pull/7577