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
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.
- LusoCryptoLabs/cells-resolver:
test/livenames.test.ts
- 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)
- 2026-09-25 · LusoCryptoLabs/cells-resolver · more from this project
More about CCC (TypeScript SDK)
- CCC EVM signer exposes several lock addresses via getAddressObjs
- Clear the CCC client cache after a sent transaction loses a double spend race
- Use findCellsOnChain for shared live state
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.