Client is your connection to the CKB network. It wraps the CKB JSON-RPC, handles request caching, and exposes higher-level helpers for finding cells and transactions. Every other CCC abstraction — signers, transactions, addresses — depends on a client to talk to the chain.
Instantiate a client
CCC ships two ready-to-use implementations that connect to the public RPC endpoints:url option to point at your own node:
ClientPublicMainnet uses the address prefix ckb; ClientPublicTestnet uses ckt.
Query chain state
Tip block
Blocks and headers
undefined when the block does not exist, and cache confirmed results automatically.
Fee rate
Find cells
UsefindCells to iterate over live cells that match a search key. It merges cached cells with on-chain results so you never miss a freshly sent cell:
Find transactions
findTransactions returns an async generator of transaction records for any lock or type script:
groupByTransaction: true to receive one record per transaction instead of one record per input/output:
Send a transaction
After you build and sign a transaction, submit it withsendTransaction:
sendTransaction validates the fee rate against a configurable maximum before broadcasting.
Wait for confirmation
KnownScript
TheKnownScript enum lets you reference well-known on-chain scripts by name instead of hard-coding code hashes. Call client.getKnownScript() to retrieve the deployment info (code hash, hash type, and cell deps) for any entry:
| Enum value | Description |
|---|---|
NervosDao | Nervos DAO deposit/withdraw script |
Secp256k1Blake160 | Standard single-sig lock |
Secp256k1Multisig | Standard multisig lock |
AnyoneCanPay | Anyone-can-pay lock |
TypeId | Type ID script |
XUdt | xUDT fungible token type |
JoyId | JoyID passkey lock |
OmniLock | OmniLock (EVM / BTC compatible) |
NostrLock | Nostr event lock |
COTA | CoTA NFT type |
UniqueType | Unique cell type |
TimeLock | Time-locked cells |
Script availability varies by network. Calling
getKnownScript for a script that is not deployed on the current network throws an error.