0

I would like to compile my contracts and to get an output with the opcodes in detail (not just assembly) but with references to the solidity source code at each line. This is the output one gets by default when using the Remix editor and cliking on "details", but I can't find a way to get that using the solc binary: I get either assembly with comments using --asm or opcodes without comments --opcodes. Can I do that?

EDIT: to clarify, what I mean by assembly is something like tag_11 /* "pot.sol":5259:5263 myid */ dup3 /* "pot.sol":5265:5271 result */ dup3 /* "pot.sol":5283:5284 0 */ 0x0 /* "pot.sol":5273:5285 new bytes(0) */

and what I mean by opcodes is something like

SWAP1 contract Coucou{\n address ... DIV contract Coucou{\n address ... PUSH FFFFFFFF contract Coucou{\n address ... AND contract Coucou{\n address ... DUP1 contract Coucou{\n address ... PUSH 26121FF0 contract Coucou{\n address ...

1

Not sure what you mean by assembly vs opcodes. You have the --abi option, that outputs the contract's ABI, and --bin for the binary,

Moreover if you just type solc in your console, you'll see all the options available. In my installation, it shows the following:

Output Components:
  --ast                AST of all source files.  
  --ast-json           AST of all source files in JSON format.
  --ast-compact-json   AST of all source files in a compact JSON format.
  --asm                EVM assembly of the contracts.
  --asm-json           EVM assembly of the contracts in JSON format.
  --opcodes            Opcodes of the contracts.
  --bin                Binary of the contracts in hex.
  --bin-runtime        Binary of the runtime part of the contracts in hex.
  --clone-bin          Binary of the clone contracts in hex.
  --abi                ABI specification of the contracts.
  --hashes             Function signature hashes of the contracts.
  --userdoc            Natspec user documentation of all contracts.
  --devdoc             Natspec developer documentation of all contracts.
  --metadata           Combined Metadata JSON whose Swarm hash is stored on-chain.
  --formal             Translated source suitable for formal analysis.
  • thanks for taking the time to answer. I clarified in my question what I mean by "assembly" vs "opcodes". – user3078439 Jan 18 '18 at 14:19
0

Just with solc cannot do it itself. You need to work with srcmap-runtime. You can run the command like: solc --pretty-json --combined-json srcmap-runtime YourContract.sol

Then you will get something like:

"srcmap-runtime" : "26:184:0:-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;137:71;;8:9:-1;5:2;;;30:1;27;20:12;5:2;137:71:0;;;;;;;;;;;;;;;;;;;;;;;70:57;;8:9:-1;5:2;;;30:1;27;20:12;5:2;70:57:0;;;;;;;;;;;;;;;;;;;;;;;;;;137:71;175:4;198:3;;191:10;;137:71;:::o;70:57::-;118:2;112:3;:8;;;;70:57;:::o"

The notation is documented here : https://solidity.readthedocs.io/en/develop/miscellaneous.html#source-mappings

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.