CKB Pulse

All lessons · CCC (TypeScript SDK) · Start here · Glossary

Use findCellsOnChain, not findCells, for block range queries in CCCWorkingChecked by the owner

Checked by the owner · Check: right · Checked 2026-11-19

In CCC, client.findCells merges the client's local cache of cells it has sent, and its search key takes no blockRange filter. To list live cells created in a block range, call client.findCellsOnChain with filter.blockRange set to [from, to), where the end is exclusive. This queries the indexer directly.

Why it matters: With findCells, cells from the client's own sent transactions can show up in a block range query even though they were not created in that range, which corrupts an incremental view built from block ranges.

Pattern

Prefer
client.findCellsOnChain({ ...search(from, to), withData: true }, 'asc', 100)

Taken from the commit, shortened.

A test changed in the same commit

It sits next to the fix. We did not run it.

Concepts
Indexer queries and cell collection
Evidence
Checked by the owner: checked by the owner of the project it came from, who is also the publisher of these lessons
First seen
2026-09-25
Last changed
2026-09-25
Last checked
2026-11-19
Check against the commit
right: the lesson follows from its commit and still holds in the code today

Sources (1)

More about CCC (TypeScript SDK)

All 33 in this topic

Checked by @LusoCryptoLabs (owner of the project), 2026-11-19.

Do you maintain a project this lesson came from? Confirm or correct it

Cite this lesson
LusoCryptoLabs, "Use findCellsOnChain, not findCells, for block range queries in CCC", CKB lessons, https://pulse.lusocryptolabs.com/learned/ccc/use-findcellsonchain-not-findcells-for-block-range-queries-i, CC BY 4.0, last changed 2026-09-25.

Drawn from public commits and checked against the commit each one came from and the project's code today. Read the source before you rely on one. Text under CC BY 4.0: credit LusoCryptoLabs, CKB lessons, with a link to the lesson. Want a lesson changed or removed? Open an issue.