3

I am compiling in solidity browser and then compiling the same exact code in truffle.

The code is the following:

pragma solidity ^0.4.11;
contract double{function d(int256 a)constant returns(int256){return a*2;}}

The resulting bytecodes are different from each other.

Truffle:
0x60606040523415600e57600080fd5b5b60978061001d6000396000f300606060405263ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416636482e6268114603c575b600080fd5b3415604657600080fd5b604f6004356061565b60405190815260200160405180910390f35b600281025b9190505600a165627a7a723058203747098ed60838a4e4a3a8ba05db5e7f3eeb60237761809e1f89f6007b52938e0029


Solidity Browser:
6060604052341561000f57600080fd5b5b60ab8061001e6000396000f30060606040526000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680636482e62614603d575b600080fd5b3415604757600080fd5b605b60048080359060200190919050506071565b6040518082815260200191505060405180910390f35b60006002820290505b9190505600a165627a7a72305820e77f3602d7e14b8ffd5ef32976d823a77ab5c91be0a1cad7a188ff3bdba9d4ea0029

Is there anything else I need to do in truffle so I can make it compile exactly the say solidity browser does?

  • are you using same compiler? – Badr Bellaj Aug 7 '17 at 22:51
  • I am using truffle as it comes and using solidity browser as it comes... The compliver version is the same in both pragma solidity ^0.4.11; – Dino Anastos Aug 8 '17 at 0:02
2

using ^0.4.11 means your contract will be compiled using by the compiler 0.4.11 or a newer version (current version is 0.4.15). so I think truffle and solidity browser are using different compiler. you need to check which version is used.
Truffle : How do I find the exact solidity compiler version used by truffle?
Remix : enter image description here

  • Unfortunately matching up the compiler versions still did not produce the same result in the bytecode. – Dino Anastos Aug 9 '17 at 2:24
  • have you enabled the optimization in remix? – Badr Bellaj Aug 10 '17 at 13:39

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.