Class URef

Represents an Unforgeable Reference (URef) in the system, identified by a unique hash and associated with specific access permissions. A URef is used to control permissions and securely reference data in smart contracts.

Hierarchy

  • URef

Constructors

  • Creates an instance of URef.

    Throws

    Error if the data length is not equal to ByteHashLen or if the access rights are unsupported.

    Parameters

    • data: Uint8Array

      The data (hash) of the URef, expected to be exactly 32 bytes.

    • access: UrefAccess

      The access permissions for the URef, specified by the UrefAccess enum.

    Returns URef

Properties

access: UrefAccess

The access permissions assigned to this URef, defined by the UrefAccess enum.

data: Uint8Array

The unique data (hash) associated with the URef, represented as a 32-byte array.

Methods

  • Converts the URef to a byte array representation. This format is useful for serialization or data transfer.

    Returns

    A Uint8Array representing the URef, combining its data and access bytes.

    Returns Uint8Array

  • Sets or updates the access permissions for the URef.

    Parameters

    • access: UrefAccess

      The new access permission to set, defined by the UrefAccess enum.

    Returns void

  • Returns the byte array representation of the URef, often used for driving values in other contexts.

    Returns

    A Uint8Array representing the URef.

    Returns Uint8Array

  • Serializes the URef to a JSON-compatible string format.

    Returns

    A JSON string representation of the URef.

    Returns string

  • Converts the URef to a prefixed string representation, following the standard format for URef strings.

    Returns

    A string with the URef prefix, data in hex format, and access permissions in hex format.

    Returns string

  • Converts the URef to a string, displaying its data as a hexadecimal string along with the access permissions.

    Returns

    A string representation of the URef.

    Returns string

  • Creates a URef instance from an ArrayBuffer, extracting the hash data and access byte.

    Returns

    A new URef instance.

    Throws

    Error if the ArrayBuffer size is smaller than expected.

    Parameters

    • arrayBuffer: ArrayBuffer

      The ArrayBuffer containing the URef data.

    Returns URef

  • Creates a URef from a byte array representation, expecting the hash data and access byte.

    Returns

    A new URef instance wrapped in an IResultWithBytes object.

    Throws

    Error if the byte array length does not match the expected URef structure.

    Parameters

    • bytes: Uint8Array

      The byte array containing the URef data and access byte.

    Returns IResultWithBytes<URef>

  • Creates a URef from a JSON-compatible string representation.

    Returns

    A new URef instance.

    Parameters

    • data: string

      The JSON string representing the URef.

    Returns URef

  • Parses a URef from a prefixed string format, which includes its data and access permissions.

    Returns

    A new URef instance.

    Throws

    ErrIncorrectUrefFormat if the string format does not match the expected URef format.

    Parameters

    • source: string

      The string containing the URef data, starting with the URef prefix.

    Returns URef

Generated using TypeDoc