@aptos-labs/ts-sdk - v3.1.1
    Preparing search index...

    Class MoveOption<T>

    Represents an argument for entry functions, providing methods to serialize the argument to BCS-serialized bytes and convert it to different formats.

    Type Parameters

    Hierarchy (View Summary)

    Implements

    Index

    Implementation - BCS

    • Converts the BCS-serialized bytes of a value into a Hex instance. This function provides a Hex representation of the BCS-serialized data for easier handling and manipulation.

      Returns Hex

      A Hex instance with the BCS-serialized bytes loaded into its underlying Uint8Array.

    • Retrieves the inner value of the MoveOption.

      This method is inspired by Rust's Option<T>.unwrap(), where attempting to unwrap a None value results in a panic. This method will throw an error if the value is not present.

      Returns T

      The contained value if present.

      const option = new MoveOption<Bool>(new Bool(true));
      const value = option.unwrap(); // Returns the Bool instance

      Throws an error if the MoveOption does not contain a value.

    • Factory method to generate a MoveOption from a boolean or undefined.

      Parameters

      • Optionalvalue: null | boolean

        the value used to fill the MoveOption. If value is undefined the resulting MoveOption's .isSome() method will return false.

      Returns MoveOption<Bool>

      a MoveOption with an inner value value

      MoveOption.Bool(true).isSome() === true;
      MoveOption.Bool().isSome() === false;
      MoveOption.Bool(undefined).isSome() === false;
    • Factory method to generate a MoveOption from a string or undefined.

      Parameters

      • Optionalvalue: null | string

        the value used to fill the MoveOption. If value is undefined the resulting MoveOption's .isSome() method will return false.

      Returns MoveOption<MoveString>

      a MoveOption with an inner value value

      MoveOption.MoveString("hello").isSome() === true;
      MoveOption.MoveString("").isSome() === true;
      MoveOption.MoveString().isSome() === false;
      MoveOption.MoveString(undefined).isSome() === false;
    • Factory method to generate a MoveOption from a number or a bigint or undefined.

      Parameters

      • Optionalvalue: null | AnyNumber

        the value used to fill the MoveOption. If value is undefined the resulting MoveOption's .isSome() method will return false.

      Returns MoveOption<U128>

      a MoveOption with an inner value value

      MoveOption.U128(1).isSome() === true;
      MoveOption.U128().isSome() === false;
      MoveOption.U128(undefined).isSome() === false;
    • Factory method to generate a MoveOption from a number or undefined.

      Parameters

      • Optionalvalue: null | number

        the value used to fill the MoveOption. If value is undefined the resulting MoveOption's .isSome() method will return false.

      Returns MoveOption<U16>

      a MoveOption with an inner value value

      MoveOption.U16(1).isSome() === true;
      MoveOption.U16().isSome() === false;
      MoveOption.U16(undefined).isSome() === false;
    • Factory method to generate a MoveOption from a number or a bigint or undefined.

      Parameters

      • Optionalvalue: null | AnyNumber

        the value used to fill the MoveOption. If value is undefined the resulting MoveOption's .isSome() method will return false.

      Returns MoveOption<U256>

      a MoveOption with an inner value value

      MoveOption.U256(1).isSome() === true;
      MoveOption.U256().isSome() === false;
      MoveOption.U256(undefined).isSome() === false;
    • Factory method to generate a MoveOption from a number or undefined.

      Parameters

      • Optionalvalue: null | number

        the value used to fill the MoveOption. If value is undefined the resulting MoveOption's .isSome() method will return false.

      Returns MoveOption<U32>

      a MoveOption with an inner value value

      MoveOption.U32(1).isSome() === true;
      MoveOption.U32().isSome() === false;
      MoveOption.U32(undefined).isSome() === false;
    • Factory method to generate a MoveOption from a number or a bigint or undefined.

      Parameters

      • Optionalvalue: null | AnyNumber

        the value used to fill the MoveOption. If value is undefined the resulting MoveOption's .isSome() method will return false.

      Returns MoveOption<U64>

      a MoveOption with an inner value value

      MoveOption.U64(1).isSome() === true;
      MoveOption.U64().isSome() === false;
      MoveOption.U64(undefined).isSome() === false;
    • Factory method to generate a MoveOption from a number or undefined.

      Parameters

      • Optionalvalue: null | number

        the value used to fill the MoveOption. If value is undefined the resulting MoveOption's .isSome() method will return false.

      Returns MoveOption<U8>

      a MoveOption with an inner value value

      MoveOption.U8(1).isSome() === true;
      MoveOption.U8().isSome() === false;
      MoveOption.U8(undefined).isSome() === false;

    Implementation - Transactions

    Constructors

    Methods

    • Returns the hex string representation of the Serializable value with the 0x prefix.

      Returns string

      the hex formatas a string prefixed by 0x.

    Properties

    value?: T