Given the following contract:

pragma solidity ^0.4.11;

contract Simple {
    bytes32 public v;
    function set(bytes32 _v) {
        v = _v;

When disassembling, neither remix, solc or evm can properly intepret the trailing end of the code. Additionally, the code seems unreachable (it follows a JUMP instruction), and what it seems to do doesn't make much sense.

Similar trailing code is produced when compiling with solc and remix, prefixed and suffixed similarly but contents are slightly different:


In disassembly, the prefixing bytecode is intepreted by all as:

 push6 0x627a7a723058 

When compiled with remix, the "assembly" field in the web GUI describes the part as a ".data" tag:

 SSTORE             v = _v
      POP           v = _v
    tag 10          function set(bytes32 _v) {\n        ...
      JUMPDEST          function set(bytes32 _v) {\n        ...
      POP           function set(bytes32 _v) {\n        ...
      JUMP [out]            function set(bytes32 _v) {\n        ...

Thus hinting that this is not code at all, but some form of data field. If so, what is this used for?, generally and in this specific example?

  • remix: 0.4.14+commit.c2215d46.Emscripten.clang
  • evm: 1.7.0-unstable (git commit 3d32690b)
  • solc: 0.4.14-develop.2017.7.27+commit.16ca1eea.Linux.g++

Runtime bytecode (from remix):


1 Answer 1


This is the Swarm hash. It is documented at https://solidity.readthedocs.io/en/develop/metadata.html

Extract follows

Contract Metadata

The Solidity compiler automatically generates a JSON file, the contract metadata, that contains information about the current contract. It can be used to query the compiler version, the sources used, the ABI and NatSpec documentation in order to more safely interact with the contract and to verify its source code.

The compiler appends a Swarm hash of the metadata file to the end of the bytecode (for details, see below) of each contract, so that you can retrieve the file in an authenticated way without having to resort to a centralized data provider.

The format looks like this:

enter image description here

If you were to separately upload the metadata file to Swarm then future users of your contract could find it via this reference in the contract code.

Update Aug 2019

Since solidity 0.5.9, the metadata format looks like this:

solidity 0.5.9

And also a word of caution:

The compiler currently uses the “swarm version 0” hash of the metadata, but this might change in the future, so do not rely on this sequence to start with 0xa2 0x65 'b' 'z' 'z' 'r' '0'. We might also add additional data to this CBOR structure, so the best option is to use a proper CBOR parser.

  • In solidity 0.5.10, I see 0xa2 instead of 0xa1 for the first byte and 0x32 instead of 0x29 for the last byte Commented Aug 21, 2019 at 21:01
  • Update: Indeed they upgraded the contract metadata spec in solidity 0.5.9. Commented Aug 30, 2019 at 15:36

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.