-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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 and foundry, contract compile bytecode different #5559
Comments
different how? metadata hash? |
I tried another simple contract which has shorter bytecode. This is contract code:
Hardhat compiled bytecode:
foundry bytecode:
|
These are different metadata hashes. The trailing If that's the only difference the actual executable code is identical and this difference is expected. The metadata hash is a function of various things, including filepaths, so if foundry and hardhat handle e.g. remappings differently you'll get a different hash. Note that both foundry and hardhat provide options to turns off this bytecode hash if you'd like to remove the discrepancy. Going to close this since this is solved, but feel free to ask any more questions :) |
Component
Forge
Have you ensured that all of these are up to date?
What version of Foundry are you on?
forge 0.2.0 (394f217 2023-03-21T00:11:00.708322Z)
What command(s) is the bug in?
forge test
Operating System
None
Describe the bug
I'm developing contracts on a hardhat project, and I want to write test for it by foundry. The problem I'm facing is: In my contract, I will create a new child contract with the same salt + constructor params, but when running it on foundry and hardhat, it provides different addresses. After looking for the issue, I found that bytecode of child contract from foundry and hardhat is not the same, it means the bytecode which is compiled by foundry (in
out
) and hardhat (inartifacts
) are different. My test in hardhat worked well, I can predict the child contract address byethers.utils.getCreate2Address
in js.I wonder if there is any difference between the hardhat config and foundry toml, but after many try with many kinds of config, the problem is still there.
Is there any way to ensure that the config of hardhat and foundry execute the same.
This is my smart contract code:
hardhat config:
foundry config
Forge version:
0.2.0
Hardhat version:
2.14.0
The text was updated successfully, but these errors were encountered: