All lessons · CKB node, RPC and indexer · Start here · Glossary
Filter prefix get_cells results by data length before decodingWorkingFrom one fix
From one fix · Check: right · Checked 2026-11-19
A get_cells query with script_search_mode "prefix" and args "0x" returns every live cell whose script has that code hash and hash_type, whatever its args, so it can include cells of the same script with a different data layout (for example a script that owns both a state cell and a ledger cell). Check output_data length, or catch the decode error, and skip the cell before calling a strict decoder. Otherwise one unexpected cell throws and the whole result list is lost.
Why it matters: Without the length check one cell with a different data length makes the strict decoder throw, and the page shows no rounds at all instead of the rounds that exist.
Pattern
if (data.length !== ROUND_CONFIG_SIZE) continue; // not a round config cellTaken from the commit, shortened.
A test changed in the same commit
It sits next to the fix. We did not run it.
- toastmanAu/daowow:
apps/web/test/discovery.test.js
- Concepts
- Indexer queries and cell collection, Data encoding (molecule, hex, bigints)
- Evidence
- From one fix: from one project, checked against its commit
- First seen
- 2026-09-18
- Last changed
- 2026-09-18
- 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-18 · toastmanAu/daowow · more from this project
More about CKB node, RPC and indexer
- Nervos DAO phase 1 withdrawing cells keep the DAO type; count deposits by 8 zero bytes of data
- Finding cells of a ckb_js_vm JS contract needs a second indexer prefix search
- Check chain-wide script users before consuming a deployed code cell
Do you maintain a project this lesson came from? Confirm or correct it
Cite this lesson
LusoCryptoLabs, "Filter prefix get_cells results by data length before decoding", CKB lessons, https://pulse.lusocryptolabs.com/learned/node/filter-prefix-get-cells-results-by-data-length-before-decodi, CC BY 4.0, last changed 2026-09-18.