Function splitMetadataHash

  • Splits buffer into the executable EVM bytecode and the embedded metadata hash. The metadata hash may be placed by the Solidity compiler as a compilation fingerprint. It may include the compiler version and the hash of the compilation input, i.e. the source code and compilation settings.

    The bytecode might have been compiled with no metadata or with a different language that does not include metadata. In this case the metadata property is undefined and the bytecode property is the original buffer.

    The metadata hash is placed at the end of the EVM bytecode and encoded using CBOR. We use cbor-js to decode the metadata hash. If metadata contains an IPFS hash, it is encoded using base 58. We use base58-js to encode the IPFS hash. If metadata contains a Swarm hash, i.e. bzzr0 or bzzr1, it is encoded using hexadecimal.

    Parameters

    • buffer: string | Uint8Array | ArrayLike<number>

      the contract or library bytecode to test for metadata hash.

    Returns {
        bytecode: Uint8Array;
        metadata: Metadata | undefined;
    }

    An object where the bytecode is the executable code and metadata is the metadata hash when the metadata is present.

Generated using TypeDoc v0.25.2