Class AddressableEntityHash

Represents an addressable entity hash in the Casper network. This class extends the Hash class to include a prefix indicating it is an addressable entity, adding specific methods and properties for managing such hashes.

Hierarchy

  • Hash
    • AddressableEntityHash

Constructors

Properties

originPrefix: string

Stores the prefix of the original hash string if it had one. Defaults to addressable-entity- if not provided.

ByteHashLen: number = 32

The fixed length of the hash in bytes.

StringHashLen: number = 64

The fixed length of the hash string representation in hexadecimal characters.

Methods

  • Compares this Hash instance with another Hash instance for equality.

    Returns

    True if the hashes are equal, false otherwise.

    Parameters

    • other: Hash

      The other Hash to compare with.

    Returns boolean

  • Converts the Hash instance to a byte array.

    Returns

    The byte array representation of the hash.

    Returns Uint8Array

  • Converts the Hash instance to a hexadecimal string.

    Returns

    The hexadecimal string representation of the hash.

    Returns string

  • Serializes the AddressableEntityHash to its JSON representation. The JSON representation includes the original prefix if it was specified.

    Returns

    A string combining the prefix (if present) and the hexadecimal representation of the hash.

    Returns string

  • Returns the addressable entity hash as a prefixed string. Always includes the addressable-entity- prefix.

    Returns

    The prefixed hexadecimal string representation of the hash.

    Returns string

  • Creates an array of Hash instances from a byte array.

    Returns

    An array of Hash instances created from the byte array.

    Throws

    Error if the byte array length is not a multiple of the hash length.

    Parameters

    • byteArray: Uint8Array

      The byte array containing multiple hash values.

    Returns Hash[]

  • Creates a Hash instance from a Buffer.

    Returns

    A new Hash instance.

    Throws

    Error if the buffer length is less than the required hash length.

    Parameters

    • buffer: Buffer

      The Buffer containing the hash bytes.

    Returns Hash

  • Creates a Hash instance from a byte array.

    Returns

    A result object containing the new Hash instance and the remaining bytes.

    Throws

    Error if the byte array length does not match the expected hash length.

    Parameters

    • source: Uint8Array

      The byte array representing the hash.

    Returns IResultWithBytes<Hash>

  • Parses a hexadecimal string to create an AddressableEntityHash instance. Checks if the input string starts with the addressable-entity- prefix, removing it if present.

    Returns

    A new AddressableEntityHash instance.

    Parameters

    • source: string

      The hexadecimal string representation of the hash, with or without the prefix.

    Returns AddressableEntityHash

Generated using TypeDoc