CCC Docs
    Preparing search index...

    Represents an on-chain CKB cell, which is a CellAny that is guaranteed to have an outPoint. This class is typically used for cells that are already part of the blockchain state, such as transaction inputs.

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    cellOutput: CellOutput

    The cell output of the cell.

    outputData: `0x${string}`

    The output data of the cell.

    outPoint: OutPoint

    The output point of the cell.

    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

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

    • Creates a Cell instance from a CellLike object. This method accepts either outPoint or previousOutput to specify the cell's location, and supports automatic capacity calculation for the cell output.

      Parameters

      • cell: CellLike

        A CellLike object or an instance of Cell. The object can use either: - outPoint: For referencing a cell output - previousOutput: For referencing a cell input (alternative name for outPoint) The cellOutput can omit capacity for automatic calculation.

      Returns Cell

      A Cell instance.

      // Using outPoint with explicit capacity
      const cell1 = Cell.from({
      outPoint: { txHash: "0x...", index: 0 },
      cellOutput: {
      capacity: 1000n,
      lock: { codeHash: "0x...", hashType: "type", args: "0x..." }
      },
      outputData: "0x"
      });

      // Using previousOutput with automatic capacity calculation
      const cell2 = Cell.from({
      previousOutput: { txHash: "0x...", index: 0 },
      cellOutput: {
      lock: { codeHash: "0x...", hashType: "type", args: "0x..." }
      // capacity will be calculated automatically
      },
      outputData: "0x1234"
      });
    • Retrieves detailed information about a Nervos DAO cell, including its deposit and withdrawal headers.

      Parameters

      • client: Client

        A CKB client instance to fetch cell and header data.

      Returns Promise<
          | { depositHeader?: undefined; withdrawHeader?: undefined }
          | { depositHeader: ClientBlockHeader; withdrawHeader?: undefined }
          | { depositHeader: ClientBlockHeader; withdrawHeader: ClientBlockHeader },
      >

      A promise that resolves to an object containing header information. - If not a DAO cell, returns {}. - If a deposited DAO cell, returns { depositHeader }. - If a withdrawn DAO cell, returns { depositHeader, withdrawHeader }.

      If the cell is a DAO cell but its corresponding headers cannot be fetched.

      const daoInfo = await cell.getNervosDaoInfo(client);