Hierarchy

Constructors

  • Creates an instance of Script.

    Parameters

    • codeHash: `0x${string}`

      The code hash of the script.

    • hashType: HashType

      The hash type of the script.

    • args: `0x${string}`

      The arguments for the script.

    Returns Script

Properties

codeHash: `0x${string}`

The code hash of the script.

hashType: HashType

The hash type of the script.

args: `0x${string}`

The arguments for the script.

byteLength?: number

The bytes length of the entity, if it is fixed, otherwise undefined

Accessors

Methods

  • Clone a script.

    Returns Script

    A cloned Script instance.

    const script1 = script0.clone();
    
  • Creates a Script instance from a ScriptLike object.

    Parameters

    • script: ScriptLike

      A ScriptLike object or an instance of Script.

    Returns Script

    A Script instance.

    const script = Script.from({
    codeHash: "0x1234...",
    hashType: "type",
    args: "0xabcd..."
    });
  • Creates a Script instance from client and known script.

    Parameters

    • client: Client

      A ScriptLike object or an instance of Script.

    • knownScript: KnownScript

      A KnownScript enum.

    • args: BytesLike

      Args for the script.

    Returns Promise<Script>

    A promise that resolves to the script instance.

    const script = await Script.fromKnownScript(
    client,
    KnownScript.XUdt,
    args: "0xabcd..."
    );
  • Encode the entity into bytes

    Parameters

    Returns Uint8Array

    The encoded bytes

    Will throw an error if the entity is not serializable

  • Decode the entity from bytes

    Parameters

    Returns Script

    The decoded entity

    Will throw an error if the entity is not serializable

  • Create an entity from bytes

    Parameters

    Returns Script

    The created entity

    Will throw an error if the entity is not serializable

  • Convert the entity to bytes

    Returns Uint8Array

    The bytes representation of the entity

  • Check if the entity is equal to another entity

    Parameters

    • other: ScriptLike

      The other entity to compare with

    Returns boolean

    True if the entities are equal, false otherwise

  • Calculate the hash of the entity

    Returns `0x${string}`

    The hash of the entity