Skip to main content
A 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:
Both classes automatically prefer a WebSocket transport when the environment supports it, and fall back to HTTPS otherwise. Pass a 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

Both methods return undefined when the block does not exist, and cache confirmed results automatically.

Fee rate

Find cells

Use findCells 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:
Two convenience wrappers cover the most common cases:

Find transactions

findTransactions returns an async generator of transaction records for any lock or type script:
Pass 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 with sendTransaction:
sendTransaction validates the fee rate against a configurable maximum before broadcasting.

Wait for confirmation

KnownScript

The KnownScript 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:
Available entries:
Script availability varies by network. Calling getKnownScript for a script that is not deployed on the current network throws an error.