CCC Docs
    Preparing search index...

    Represents a CKB cell that can be either on-chain (with an outPoint) or off-chain (without an outPoint). This class provides a unified interface for handling cells before they are included in a transaction, or for cells that are already part of the blockchain state.

    Hierarchy (View Summary)

    Index

    Constructors

    • Creates an instance of CellAny.

      Parameters

      • cellOutput: CellOutput

        The cell output of the cell.

      • outputData: `0x${string}`

        The output data of the cell.

      • OptionaloutPoint: OutPoint

        The optional output point of the cell. If provided, the cell is considered on-chain.

      Returns CellAny

    Properties

    cellOutput: CellOutput

    The cell output of the cell.

    outputData: `0x${string}`

    The output data of the cell.

    outPoint?: OutPoint

    The optional output point of the cell. If provided, the cell is considered on-chain.

    Accessors

    • get occupiedSize(): number

      Calculates the total occupied size of the cell in bytes. This includes the size of the CellOutput structure plus the size of the outputData.

      Returns number

      The total occupied size in bytes.

    • get capacityFree(): bigint

      Calculates the free capacity of the cell. Free capacity is the total capacity minus the capacity occupied by the cell's structure and data.

      Returns bigint

      The free capacity in shannons as a Num.

    Methods

    • Creates a CellAny instance from a CellAnyLike object. This factory method provides a convenient way to create CellAny instances from plain objects, automatically handling the optional outPoint or previousOutput.

      Parameters

      Returns CellAny

      A new CellAny instance.

      // Create an off-chain cell (e.g., a new output)
      const offChainCell = CellAny.from({
      cellOutput: { capacity: 1000n, lock: lockScript },
      outputData: "0x"
      });

      // Create an on-chain cell from an input
      const onChainCell = CellAny.from({
      outPoint: { txHash: "0x...", index: 0 },
      cellOutput: { capacity: 2000n, lock: lockScript },
      outputData: "0x1234"
      });
    • Checks if the cell is a Nervos DAO cell and optionally checks its phase.

      Parameters

      • client: Client

        A CKB client instance to fetch known script information.

      • Optionalphase: "deposited" | "withdrew"

        Optional phase to check: "deposited" or "withdrew". If omitted, it checks if the cell is a DAO cell regardless of phase.

      Returns Promise<boolean>

      A promise that resolves to true if the cell is a matching Nervos DAO cell, false otherwise.

    • Clones the CellAny instance.

      Returns CellAny

      A new CellAny instance that is a deep copy of the current one.

      const clonedCell = cellAny.clone();