Class AccountHash

Represents an account hash in the Casper network. This class extends the Hash class, adding specific methods and properties for managing account hashes, which include special prefixes.

Hierarchy

Constructors

  • Initializes a new AccountHash instance.

    Parameters

    • hash: Hash

      The underlying Hash object containing the raw bytes of the account hash.

    • originPrefix: string = ''

      Optional. The prefix of the original hash string (default is an empty string).

    Returns AccountHash

Properties

originPrefix: string

Stores the prefix of the original hash string if it had one. Possible prefixes are "00" or "account-hash-".

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 AccountHash to its JSON representation. The JSON representation includes the original prefix if present.

    Returns

    A string representation of the AccountHash for JSON serialization.

    Returns string

  • Returns the account hash as a string, prefixed with "account-hash-". This is useful for displaying the hash in a format recognized by the Casper network.

    Returns

    The account hash as a prefixed string.

    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>

  • Creates a Hash instance from a hexadecimal string.

    Returns

    A new Hash instance.

    Throws

    Error if the string length does not match the expected hash length.

    Parameters

    • source: string

      The hexadecimal string representation of the hash.

    Returns Hash

  • Deserializes an AccountHash instance from a JSON string representation.

    Returns

    A new AccountHash instance created from the JSON string.

    Throws

    Throws an error if the input is not a valid JSON string.

    Parameters

    • data: string

      The JSON string representation of the AccountHash.

    Returns AccountHash

  • Parses a string representation of an account hash and creates an AccountHash instance. Recognizes and preserves any prefix, either "00" or "account-hash-".

    Returns

    A new AccountHash instance containing the parsed hash and prefix.

    Parameters

    • source: string

      The string representation of the account hash.

    Returns AccountHash

Generated using TypeDoc