0

I'm noticing a difference in the binary generated using the same solc compiler in local and with Remix.

Here's the source code:

pragma solidity 0.8.20;
contract HelloWorld {}

I compiled it in local using solc 0.8.20+commit.a1b79de6.Darwin.appleclang with the following command: solc --bin --evm-version=shanghai src/HelloWorld.sol

Then I compiled it using remix:

enter image description here

Using solc in local I get: 6080604052348015600e575f80fd5b50603e80601a5f395ff3fe60806040525f80fdfea26469706673582212207b2707958b214a2fbb3ee97873fd5450b38f093d306ca27f3ab234659b8a6f8064736f6c63430008140033

Using Remix: 6080604052348015600e575f80fd5b50603e80601a5f395ff3fe60806040525f80fdfea2646970667358221220d6df573e47185fc28b4a57d786409da70c81ef5acd34160533da68ef8405873c64736f6c63430008140033

At first sight the outputs look identical but they are different. I used the same compiler version, same evm version and no optimization, so I wonder what else could cause this difference?

2
  • While you've mentioned using the same compiler version and EVM version, differences in the compilation environment can still exist. For example, Remix might use a different operating system or underlying dependencies compared to your local environment, which could affect the compilation process. Commented Mar 19 at 15:24
  • I can see this part of the bytecode is same, even in my case when I compiled: 6080604052348015600e575f80fd5b50603e80601a5f395ff3fe60806040525f80fdfea2646970667358221220.............64736f6c63430008140033 Commented Mar 19 at 15:31

1 Answer 1

0

It's just the metadata part of the bytecode that is different. Contracts compiled with solidity all have a metadata part at the end of the bytecode: https://docs.soliditylang.org/en/latest/metadata.html#encoding-of-the-metadata-hash-in-the-bytecode

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.