I would like to compile a contract written in Solidity (or even just the part relating to a single method) to study it and understand if I can optimize it. I already managed to get the bytecode as binary or in its assembly representation using solc but I would prefer to keep the original source in the assembly like comments, line per line, similar to what happens with gcc -S.

Moreover, I can't understand if the solc compiler uses the Yul language as intermediate representation between Solidity and assembly during the compilation, in case it did, how can I view this representation?

2 Answers 2


Probably, the closest you will get is to use --asm output from solc.

With solc 0.8 you can get the intermediate Yul representation with --ir.

The command

solc -o build --asm --ir MetaCoin.sol

should generate MetaCoin.evm and MetaCoin.yul files in build directory.


If you want to manually optimize solc --asm output you can do it with my EVM assembler :) https://github.com/RafaelSalguero/evm-assembler

It's compatible with solc --asm output

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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