



`@ckb-ccc/core` is the base layer of CCC. It contains all CKB data types, encoders, hashers, and the abstract `Signer` / `Client` interfaces used by every higher-level package.

<Callout type="info">
  Most projects do not need to install `@ckb-ccc/core` directly. Use
  `@ckb-ccc/shell` for Node.js or `@ckb-ccc/connector-react` for React — both
  re-export everything from core.
</Callout>

## Installation [#installation]

<PackageBadges pkg="@ckb-ccc/core" />

<Tabs items="['npm', 'yarn', 'pnpm']">
  <Tab value="npm">
    ```bash
    npm install @ckb-ccc/core
    ```
  </Tab>

  <Tab value="yarn">
    ```bash
    yarn add @ckb-ccc/core
    ```
  </Tab>

  <Tab value="pnpm">
    ```bash
    pnpm add @ckb-ccc/core
    ```
  </Tab>
</Tabs>

## Imports [#imports]

```typescript
import { ccc } from "@ckb-ccc/core";
```

## Exported modules [#exported-modules]

`@ckb-ccc/core` re-exports the following sub-modules under the `ccc` namespace:

| Module       | Contents                                                                              |
| ------------ | ------------------------------------------------------------------------------------- |
| `address`    | `Address`, `AddressLike`, address parsing and formatting                              |
| `bytes`      | `bytesFrom`, `bytesTo`, byte array utilities                                          |
| `ckb`        | `Transaction`, `Script`, `Cell`, `CellInput`, `CellOutput`, `OutPoint`, `WitnessArgs` |
| `client`     | `Client` (abstract), `ClientPublicMainnet`, `ClientPublicTestnet`                     |
| `fixedPoint` | `fixedPointFrom`, `fixedPointToString` — CKB capacity in shannons                     |
| `hasher`     | `hashCkb`, `Hasher` — CKB Blake2b hashing                                             |
| `hex`        | `hexFrom`, `HexLike`, hex encoding helpers                                            |
| `jsonRpc`    | `RequestorJsonRpc` — low-level JSON-RPC client                                        |
| `keystore`   | `KeyStore` — encrypted key storage                                                    |
| `molecule`   | Molecule codec primitives                                                             |
| `num`        | `numFrom`, `numFromBytes`, `numToBytes`, `numLeToBytes` — numeric conversions         |
| `signer`     | `Signer` (abstract), `SignerInfo`, `SignerType`, `SignerSignType`                     |
| `utils`      | Miscellaneous helpers                                                                 |

## Key classes [#key-classes]

### Transaction [#transaction]

The primary type for building CKB transactions:

```typescript
// Build a CKB transfer transaction
const tx = ccc.Transaction.from({
  outputs: [{ lock: toLock, capacity: ccc.fixedPointFrom(amount) }],
});

await tx.completeInputsByCapacity(signer);
await tx.completeFeeBy(signer);
const txHash = await signer.sendTransaction(tx);
```

Important methods:

| Method                                | Description                          |
| ------------------------------------- | ------------------------------------ |
| `Transaction.from(like)`              | Create from a plain object           |
| `tx.addInput(cell)`                   | Add a cell input                     |
| `tx.addOutput(output, data?)`         | Add a cell output                    |
| `tx.completeInputsByCapacity(signer)` | Auto-select inputs to cover capacity |
| `tx.completeFeeBy(signer, feeRate?)`  | Add a change output and compute fee  |
| `tx.addCellDepInfos(client, deps)`    | Resolve and add cell dependencies    |
| `signer.sendTransaction(tx)`          | Sign and broadcast                   |

### Script [#script]

```typescript
const script = ccc.Script.from({
  codeHash: "0x...",
  hashType: "type",
  args: "0x...",
});

script.eq(otherScript); // structural equality
```

### Address [#address]

```typescript
const addr = await ccc.Address.fromString(
  "ckb1qzda0cr08m85hc8jlnfp3gog...",
  client,
);
const { script, prefix } = addr;
```

### Signer (abstract) [#signer-abstract]

The `Signer` abstract class is implemented by every wallet integration. Key members:

```typescript
abstract class Signer {
  readonly client: Client;

  abstract getInternalAddress(): Promise<string>;
  abstract getRecommendedAddressObj(preference?: unknown): Promise<Address>;
  abstract signTransaction(tx: Transaction): Promise<Transaction>;

  async sendTransaction(tx: Transaction): Promise<Hex>;
  async findCells(filter, withData?, order?, limit?): AsyncGenerator<Cell>;
}
```

### Client (abstract) [#client-abstract]

```typescript
// Connect to public testnet
const client = new ccc.ClientPublicTestnet();

// Connect to public mainnet
const client = new ccc.ClientPublicMainnet();

// Connect to a custom node
const client = new ccc.ClientPublicTestnet("https://my-node.example.com/rpc");
```

## Key functions [#key-functions]

```typescript
// Convert any value to a fixed-point CKB capacity (shannons)
const capacity = ccc.fixedPointFrom("100"); // 100 CKB = 10_000_000_000n shannons

// Hash data with CKB's Blake2b
const hash = ccc.hashCkb(data);

// Encode to hex
const hex = ccc.hexFrom(bytes);

// Numeric conversion
const n = ccc.numFrom("0xff"); // BigInt
const bytes = ccc.numToBytes(n, 8); // little-endian Uint8Array

// Byte conversions
const arr = ccc.bytesFrom("0xdeadbeef");
const str = ccc.bytesTo(arr, "utf8");
```


---

> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ckbccc.com/llms.txt
> Use this file to discover all available pages before exploring further.
