Simple question, but I couldn’t find the answer anywhere. How to get the exact bytecode of a smart contract (not creation bytecode) when the source code of contract is available on https://etherscan.io ?

This is for already deployed contracts.

  • Even without any constructor, the creation bytecode contains more function than the resulting contract. – user2284570 Jun 1 '18 at 12:38
  • Why don't you want the creation bytecode? It is the code of the contract, so...? – Florian Castelain Jun 1 '18 at 13:19
  • 1
    @Andromelus : creation bytecode contains the code of the contract, but it’s not the contract… ethereum.stackexchange.com/q/23092/25002 – user2284570 Jun 1 '18 at 13:22
  • The creation bycode is the contract. You are taking the comment made in the answer too far implying that these are two different things. The deployed contract seems to be missing only the opcodes of the constructor, so having the creation bycode you have everything you need. – Jaime Jun 1 '18 at 14:46
  • @Jaime : which require assembly knowledge to get where the actual contract starts from. – user2284570 Jun 1 '18 at 16:07

When deploying through Truffle you can use the contracts .json file located in /build/contracts which contains "bytecode": 0x... and "deployedbytecode": 0x.... What you want to look at is the deployedbytecode

| improve this answer | |
  • Thuffle is pretty hard to get running on Windows. Do you have on online service for this ? – user2284570 Jun 1 '18 at 13:08
  • If you go to remix and then to the compile tab you can check the details of your smart contract. If you scroll down a bit you'll see a part saying Runtime bytecode I hope that is what you're looking for. – Gabe Jun 1 '18 at 13:13
  • Without knowing compiler optimization flags, this won’t got far. – user2284570 Jun 1 '18 at 13:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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