Class CLValue

Represents a CLValue in the Casper type system. CLValue is a container for various types of values used in smart contracts.

Hierarchy

  • CLValue

Constructors

Properties

byteArray?: CLValueByteArray
key?: Key
option?: CLValueOption
publicKey?: PublicKey
result?: CLValueResult
stringVal?: CLValueString
tuple1?: CLValueTuple1
tuple2?: CLValueTuple2
tuple3?: CLValueTuple3
type: CLType
uref?: URef

Methods

  • Converts the CLValue to its byte representation.

    Returns

    A Uint8Array representing the bytes of the value.

    Returns Uint8Array

  • Retrieves the Key value from the CLValue.

    Returns

    The Key stored in the CLValue.

    Throws

    Error if the Key property is empty.

    Returns Key

  • Retrieves the value associated with the CLValue's type.

    Returns

    An IValue representing the actual value stored in the CLValue.

    Throws

    Error if the type is not implemented.

    Returns IValue

  • Returns a string representation of the CLValue.

    Returns

    A string representation of the value.

    Returns string

  • Creates a new CLValue instance containing an 'Any' value.

    Returns

    A new CLValue instance encapsulating the 'Any' value.

    Parameters

    • data: Uint8Array

      The Uint8Array to be stored within the CLValue.

    Returns CLValue

  • Creates a new CLValue instance containing a ByteArray value.

    Returns

    A new CLValue instance encapsulating the ByteArray.

    Parameters

    • val: Uint8Array

      The Uint8Array to be stored within the CLValue.

    Returns CLValue

  • Creates a new CLValue instance with an Int32 value.

    Returns

    A new CLValue instance containing CLTypeInt32 and a CLValueInt32.

    Parameters

    • val: BigNumberish

      The 32-bit integer to be encapsulated in a CLValue.

    Returns CLValue

  • Creates a new CLValue instance with an Int64 value.

    Returns

    A new CLValue instance containing CLTypeInt64 and a CLValueInt64.

    Parameters

    • val: BigNumberish

      The value to be stored in the Int64. Accepts any BigNumberish type.

    Returns CLValue

  • Creates a new CLValue instance with a List value.

    Returns

    A new CLValue instance containing CLTypeList and a CLValueList.

    Parameters

    • elementType: CLType

      The CLType for the elements of the list.

    • elements: CLValue[] = []

      Optional array of CLValues to initialize the list with.

    Returns CLValue

  • Creates a new CLValue instance that represents an optional value.

    This method allows you to wrap a given CLValue as an optional type (Option), which can either contain a value or be null. This is useful for scenarios where a value may or may not be present.

    If inner is null, the method will use the provided clType as the type of the option. If clType is not provided, it defaults to CLTypeAny. If inner is not null, its type is used instead of clType.

    Returns

    A new CLValue instance containing:

    • A CLTypeOption representing the type of the optional value.
    • A CLValueOption that holds the inner value or null.

    Example

    // Example of an option containing a value
    const innerValue = CLValue.fromU32(42);
    const optionValue = CLValue.newCLOption(innerValue);

    // Example of an empty option with an explicitly defined type
    const emptyOptionValue = CLValue.newCLOption(null, CLType.U32);

    // Example of an empty option with no type provided (defaults to CLTypeAny)
    const emptyOptionValueDefault = CLValue.newCLOption(null);

    Parameters

    • inner: null | CLValue

      The CLValue to be wrapped in the option. Pass null if no value is present.

    • Optional clType: CLType

      (Optional) The CLType representing the type of the value contained in the option. This is required if inner is null to properly define the option type.

    Returns CLValue

  • Creates a new CLValue instance with a Result value.

    Returns

    A new CLValue instance containing CLTypeResult and a CLValueResult.

    Parameters

    • innerOk: CLType

      The CLType for the success case.

    • innerErr: CLType

      The CLType for the error case.

    • value: CLValue

      The CLValue to be contained in the Result.

    • isSuccess: boolean

      A boolean indicating whether the Result is a success (true) or an error (false).

    Returns CLValue

  • Creates a new CLValue instance with a string value.

    Returns

    A new CLValue instance containing CLTypeString and a CLValueString.

    Parameters

    • val: string

      The string value to be represented.

    Returns CLValue

  • Creates a new CLValue instance with a UInt128 value.

    Returns

    A new CLValue instance containing CLTypeUInt128 and a CLValueUInt128.

    Parameters

    • value: BigNumberish

      The value to initialize the UInt128 with.

    Returns CLValue

  • Creates a new CLValue instance with a UInt256 value.

    Returns

    A new CLValue instance containing CLTypeUInt256 and a CLValueUInt256.

    Parameters

    • value: BigNumberish

      The value to initialize the UInt256 with.

    Returns CLValue

  • Creates a new CLValue instance with a UInt32 value.

    Returns

    A new CLValue instance containing CLTypeUInt32 and a CLValueUInt32.

    Parameters

    • value: BigNumberish

      The value to initialize the UInt32 with.

    Returns CLValue

  • Creates a new CLValue instance with a UInt512 value.

    Returns

    A new CLValue instance containing CLTypeUInt512 and a CLValueUInt512.

    Parameters

    • value: BigNumberish

      The value to initialize the UInt512 with.

    Returns CLValue

  • Creates a new CLValue instance with a UInt64 value.

    Returns

    A new CLValue instance containing CLTypeUInt64 and a CLValueUInt64.

    Parameters

    • val: BigNumberish

      The value to initialize the UInt64 with. Can be any BigNumberish type.

    Returns CLValue

  • Creates a new CLValue instance with a UInt8 value.

    Returns

    A new CLValue instance containing CLTypeUInt8 and a CLValueUInt8.

    Parameters

    • value: BigNumberish

      The value to initialize the UInt8 with. Must be an integer between 0 and 255.

    Returns CLValue

  • Creates a new CLValue instance containing a boolean value.

    Returns

    A new CLValue instance encapsulating the boolean value.

    Parameters

    • val: boolean

      The boolean value to be stored in the CLValue.

    Returns CLValue

Generated using TypeDoc