0

If I deploy a contract on MyEtherWallet.com how can I find out what compiler version was used, for verifying the code on etherscan, etc.?

3

In order to deploy contract on MyEtherWallet, you need the bytecode. The bytecode contains the solidity pragma version in the metadata which is converted into the object parameter in the bytecode you get itself.

It will compile using whatever is set as the pragma.

As for verification. You will need to know what pragma was set in the solidity code itself.


Example Contract:

pragma solidity ^0.4.23;


contract Stack {
    address public owner = msg.sender;
}

Example Bytecode:

{
    "linkReferences": {},
    "object": "6080604052336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555034801561005057600080fd5b5060e98061005f6000396000f300608060405260043610603f576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680638da5cb5b146044575b600080fd5b348015604f57600080fd5b5060566098565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff16815600a165627a7a7230582014af0b7dee656067826398e451ee6dfdad4c1976579492127de9c0b4d9c8c9be0029",
    "opcodes": "PUSH1 0x80 PUSH1 0x40 MSTORE CALLER PUSH1 0x0 DUP1 PUSH2 0x100 EXP DUP2 SLOAD DUP2 PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF MUL NOT AND SWAP1 DUP4 PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF AND MUL OR SWAP1 SSTORE POP CALLVALUE DUP1 ISZERO PUSH2 0x50 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP PUSH1 0xE9 DUP1 PUSH2 0x5F PUSH1 0x0 CODECOPY PUSH1 0x0 RETURN STOP PUSH1 0x80 PUSH1 0x40 MSTORE PUSH1 0x4 CALLDATASIZE LT PUSH1 0x3F JUMPI PUSH1 0x0 CALLDATALOAD PUSH29 0x100000000000000000000000000000000000000000000000000000000 SWAP1 DIV PUSH4 0xFFFFFFFF AND DUP1 PUSH4 0x8DA5CB5B EQ PUSH1 0x44 JUMPI JUMPDEST PUSH1 0x0 DUP1 REVERT JUMPDEST CALLVALUE DUP1 ISZERO PUSH1 0x4F JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP PUSH1 0x56 PUSH1 0x98 JUMP JUMPDEST PUSH1 0x40 MLOAD DUP1 DUP3 PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF AND PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF AND DUP2 MSTORE PUSH1 0x20 ADD SWAP2 POP POP PUSH1 0x40 MLOAD DUP1 SWAP2 SUB SWAP1 RETURN JUMPDEST PUSH1 0x0 DUP1 SWAP1 SLOAD SWAP1 PUSH2 0x100 EXP SWAP1 DIV PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF AND DUP2 JUMP STOP LOG1 PUSH6 0x627A7A723058 KECCAK256 EQ 0xaf SIGNEXTEND PUSH30 0xEE656067826398E451EE6DFDAD4C1976579492127DE9C0B4D9C8C9BE0029 ",
    "sourceMap": "27:57:0:-;;;71:10;48:33;;;;;;;;;;;;;;;;;;;;27:57;8:9:-1;5:2;;;30:1;27;20:12;5:2;27:57:0;;;;;;;"
}
  • Thank you. If I set the pragma to ^0.4.18 but there are multiple versions with 0.4.18 to select in etherscan, like so: i.imgur.com/sE8n6xW.png How do i know which version to pick? – John Murphy May 9 '18 at 15:38
  • @JohnMurphy it would most likely be the 0.4.18 commit. Nightly builds usually require you to clone specifically for the development of the next version. – ReyHaynes May 9 '18 at 15:42
  • there's no info inside the object that determine which compiler has been used. Only the object field is the bytecode, the other info are added by the compiler and are not required to deploy the contract – mirg May 9 '18 at 15:45
  • 1
    @mirg The end of bytecode contains the hash of the metadata, which contains the compiler version and other information. See: Contract Metadata – ReyHaynes May 9 '18 at 15:48
  • @ReyHaynes thanks didn't know that! Cool. I'm scared that the post here is outdated then ethereum.stackexchange.com/questions/3482/… but still you need to guess which compiler has been used since is an hash right? – mirg May 9 '18 at 15:52
0

When you deploy on MyEtherWallet you post your bytecode. There's no way to detect which compiler version has generated the provided bytecode. You can find more info here

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.