-
Notifications
You must be signed in to change notification settings - Fork 46
truffle compile generates bytecode different from solc #77
Comments
OK, the answer is yes, this is just metadata. |
Second thought, why should Truffle generate different metadata than Solc? |
Update: |
Update #2: I have located the reason for which It is located in the
I order to prevent this undesired impact, the above code should be extended to:
As you can see, on each iteration, if a key represents an absolute path, then I replace it with a relative path:
It took me several hours to find the source of this problem and fix it. With this "patch" applied, the only remaining feature which preserves the undesired behavior of The fix for this one is much more straightforward (just look for this field in Truffle's source code). |
Update #3: Turns out the the fix above "causes havoc" when running Therefore, a safer fix for this would be to use:
And then, only when specifically desired, call |
Thanks for documenting this! |
I got the same issue. The bytecode generated is different from Waffle. This is critical when CREATE2 relies on the bytecode generated by different frameworks. |
Facing the same issue, too annoying |
trufflesuite/truffle#4119 has now been implemented in Truffle meaning that there are no more absolute paths in metadata and bytecode does not depend on the project location. It will still be different from what solc produces by default due to the The bytecode can be reproduced if you use For example, if you have {
"language": "Solidity",
"sources": {
"project:/contracts/C.sol": { "content": "import \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";" },
"project:/contracts/D.sol": { "content": "contract D {}" },
"@openzeppelin/contracts/token/ERC20/IERC20.sol": { "content": "interface IERC20 { ... }" },
},
"settings": {"outputSelection": {"*": {"*": ["metadata", "evm.bytecode"]}}}
} |
The
bytecode
generated bytruffle compile
and thebin
generated bysolc
are always different.I am using:
package.json
, relies on solc v0.4.24)It appears that the difference is always in the 64 characters which appear right before the last 4 characters in each output. Is that possibly just metadata?
Anyhow, you can reproduce this as follows:
Input file MyContract.sol:
Truffle command-line:
Solc command-line:
Truffle output file MyContract.json:
Solc output file MyContract.bin:
The difference:
The text was updated successfully, but these errors were encountered: