12

When I deploy a contract with Truffle that has an import statement, and try to verify it on etherscan, my understanding is that I need to paste in the contents of the imported file.

I get an error on etherscan that the bytecodes of the concatenated and deployed files are not the same. The strange thing is that if I deploy the contract (with imports) on remix then the bytecode matches with the concatenated source file.

Example

Here is a minimal example of contracts that exhibit this behaviour.

Combined.sol is the concatenated file, and Outer.sol contains the contract that is deployed.

Here is what I am doing that gets an error:

  1. Deploy Outer.sol with truffle
  2. Go to deployed contract address on etherscan
  3. Input the Concatenated.sol source code and hit verify

Error, bytecodes do not match.

More info

  • Using compiler 0.4.11 in remix and truffle.
  • Ubuntu 16.04.
  • On Kovan, not that it should matter.
  • Deployed contract
  • 1
    For me verification of concatenated contracts used to work like a charm. Can you provide the address of the deployed minimal example on the Kovan network so I can investigate the case? – Jakub Wojciechowski Jul 5 '17 at 13:04
  • @JakubWojciechowski Updated answer with address of deployed contract – Travis Jacobs Jul 5 '17 at 13:52
  • When verifying the code on Etherscan, have you tried both with and without optimizations enabled? – DeviateFish Jul 8 '17 at 5:35
9
+50

Currently etherscan does not support verification of multifile contracts. But there is discussion on etherscan's reddit about this issue.

Concatenating files into one worked some time ago, but since version 0.4.7 Solidity includes hash of contract's metadata at the end of compiled contract. As this metadata contains file names and hashes, you may get the same bytecode after concatenating and compiling but this hash will be different.

I think motivation behind adding hash of this metadata to deployed contract is to make source verification automatic as each deployed contract contains swarm-link to sources, compiler version and compilation options.

  • So basically the verification feature is pretty much useless since solidity 0.4.7 ? – Nikita Fuchs Nov 7 '17 at 10:17

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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