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 ccc.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.

Accessors

Methods

  • Creates a Script instance from a ScriptLike object.

    Parameters

    • script: ScriptLike

      A ScriptLike object or an instance of Script.

    Returns ccc.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<ccc.Script>

    A promise that resolves to the script instance.

    const script = await Script.fromKnownScript(
    client,
    KnownScript.XUdt,
    args: "0xabcd..."
    );
  • Converts the Script instance to molecule data format.

    Returns {
        codeHash: Uint8Array;
        hashType: Uint8Array;
        args: Uint8Array;
    }

    An object representing the script in molecule data format.

    • codeHash: Uint8Array
    • hashType: Uint8Array
    • args: Uint8Array
  • Converts the Script instance to bytes.

    Returns Uint8Array

    A Uint8Array containing the script bytes.

    const scriptBytes = script.toBytes();
    
  • Get hash of a script

    Returns `0x${string}`

    Hash of this script

    const hash = script.hash();
    
  • Creates a Script instance from a byte-like value or molecule Script.

    Parameters

    Returns ccc.Script

    A Script instance.

    const script = Script.fromBytes(new Uint8Array([/* script bytes */]));
    
  • Compares the current Script instance with another ScriptLike object for equality.

    Parameters

    • val: ScriptLike

      The ScriptLike object to compare with.

    Returns boolean

    True if the scripts are equal, otherwise false.

    const isEqual = script.eq(anotherScript);