Why does Ethereum store bytecode on the blockchain and not the sourcecode, what's the tradeoff?

As far as I know sourcecode does not need as much storage.


Source code is for humans to read and write. Bytecode is for machines.

From Wikipedia:

In computing, source code is any collection of computer instructions, possibly with comments, written using a human-readable programming language, usually as plain text. ... The source code is often transformed by an assembler or compiler into binary machine code understood by the computer. The machine code might then be stored for execution at a later time.

That's exactly what's going on here.

Also consider that different versions of the Solidity compiler output different bytecode. It's easy to specify exactly what each piece of bytecode should do, but would be very hard to incorporate a human readable language into the EVM.

  • Would it be correct to say source code needs less storage space on the blockchain, but does not perform so well in terms of performance? – Ini Mar 22 '18 at 20:43
  • 1
    hmmm, I just checked source code and binary size of the greeter.sol example contract. I was surprised that source was larger... so it seems that in the case of solidity output, you are correct. – maurelian Mar 23 '18 at 20:02

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.