CKB Pulse
经验

CKB 学到了什么

从这里开始 · 术语表 · 自测 · 订阅

经验用英文撰写,请用英文搜索。

“Indexer queries and cell collection”

找到 43 条经验。 全部经验

第 2 页,共 4 页

Use findCellsOnChain for shared live state实践来自一次修复

client.findCells merges results from the client's local cache, which can still hold outputs of your own earlier transactions after other parties spent them on chain. When you need the true live cell set, such as state shared with other actors or runners, use client.findCellsOnChain.

Medium confidence.

#Indexer queries and cell collection · 来源(1) · 2026-11-15

Check indexer lag with get_indexer_tip before signing实践来自一次修复

The built-in CKB indexer can trail the chain tip, so cells it returns may be stale. Before signing, compare the block_number from get_indexer_tip with the height from get_tip_header, show a notice when the gap is large, and refuse to sign while it is. daowow flags the indexer as lagging when it is more than 8 blocks behind, and its entry, refund and claim guards refuse to proceed in that state.

#Indexer queries and cell collection #Network and RPC reliability #Transaction building and fees · 来源(1) · 2026-11-10

One prefix get_cells scan per type code hash instead of one scan per round实践来自一次修复

When many logical groups (here rounds) share one type script code hash, query the indexer's get_cells once with script_type "type", args "0x" and script_search_mode "prefix" to get every cell under that code hash, then bucket the cells client side by data length and args. Querying per group repeats the same scan and grows with the group count against a public node. The indexer returns cells in type args order, not age order, so sort the results yourself.

#Indexer queries and cell collection #Network and RPC reliability · 来源(1) · 2026-11-10

Rebuild an append-only on-chain accumulator from transaction history, not from live cells进阶来自一次修复

When a cell stores only the root of an append-only accumulator (an MMR) that commits to every entry ever added, spending an entry cell removes it from the indexer's live set while the root still counts it. Replaying live cells builds a different tree and membership proofs fail (the first refund works, the second fails). If each append transaction carries its entries in a witness and spends the previous head at input 0, recover the full set by walking get_transaction backwards through input 0 and parsing each witness with a strict exact-length check, so unrelated WitnessArgs or empty witnesses are not read as entries. Refuse to act unless the recovered count equals the frozen entry count, and fail if the node no longer serves an old transaction.

Joined with daowow@765895a407.

#Indexer queries and cell collection #Witnesses and signatures · 来源(2) · 2026-11-10

Nervos DAO phase 1 withdrawing cells keep the DAO type; count deposits by 8 zero bytes of data实践由所有者核对

A Nervos DAO cell in phase 1 of withdrawal still has the DAO type script (code hash 0x82d76d...3f2e, hash_type type, args 0x), so filtering by type alone counts it as a deposit. Only cells whose output data is exactly 0x0000000000000000 are deposits; a withdrawing cell's data holds its deposit block number. The commit's testnet test shows a type-only count giving 500 CKB where the true deposit total is 300 CKB.

#Indexer queries and cell collection #Data encoding (molecule, hex, bigints) · 来源(2) · 2026-11-06

Filtering get_cells for plain, typeless, empty funding cells实践再次出现

To collect plain funding cells of a lock with the indexer get_cells (or get_cells_capacity) RPC, search with script_type "lock" and add filter output_data_len_range ["0x0","0x1"] and script_len_range ["0x0","0x1"]. Ranges are half-open [start, end), so this keeps only cells with empty data, and since the search is by lock, script_len_range applies to the type script, so only cells with no type script come back. Sorting by capacity on the client only sees the page returned (limit), so page through the results if the lock may own more cells than the limit.

#Indexer queries and cell collection · 来源(2) · 2026-11-05

Count only empty, typeless lock cells as spendable balance实践来自一次修复

When computing a wallet's spendable balance from indexer cells under a lock, count only cells with empty output data and no type script as available. A cell with data or any type script (UDT, DOB, profile or attachment cells, not just your own type) holds state, so its capacity stays in the total but is reported as reserved, because spending it would destroy that state. In cemp-mobile this is `const hasData = cell.data !== "0x" && cell.data !== ""; const isProtocol = hasData || type !== null;`.

#Indexer queries and cell collection #Capacity and cell size · 来源(1) · 2026-10-31

get_live_cell may return "unknown" rather than "dead" for a spent output实践再次出现

On CKB node 0.210.0 devnet, get_live_cell for an output already consumed by a committed transaction returned status "unknown" instead of "dead", so a check requiring "dead" fails. Accept "dead" or "unknown" and prove consumption by calling get_transaction on the creating and consuming transactions, confirming both are committed and that the consumer's inputs reference the out point exactly once.

#Indexer queries and cell collection #Network and RPC reliability · 来源(3) · 2026-10-30

Finding a spore or cluster by id through the indexer's get_transactions实践来自一次修复

A spore id or cluster id is the args of the spore (or spore_cluster) type script, so you can look one up by calling get_transactions with that type script, args set to the id, script_search_mode "exact" and a limit of 0x1. Because get_transactions returns history and not just live cells, this also finds spores that have since been melted.

Lookup by id via get_transactions, includes melted spores.

#Indexer queries and cell collection · 来源(1) · 2026-10-30

Search for a script's cells under both its data hash and its type id code hash实践由所有者核对

A script deployed with a type id can be referenced by cells either as hashType data1 with the code's data hash or as hashType type with the deployment's type id hash (per network). An exact indexer search via client.findCells over only one form misses the other; here @ckbfs/api's useTypeID cells read as missing until the reader queried both forms and treated a combined count above one as an error.

#Indexer queries and cell collection #Type ID and upgrades · 来源(1) · 2026-10-24

Use getCellLive, not getCell, when a cell's current state matters in CCC实践来自一次修复

In CCC, client.getCell(outPoint) can also return a cell that has already been spent, so status checks built on it report claimed or reclaimed cells as still active. Use client.getCellLive(outPoint, true) and treat an undefined result as "not found or already spent".

#Indexer queries and cell collection · 来源(1) · 2026-10-20

Recognizing a Nervos DAO deposit cell (not a withdrawing one)实践再次出现

Treat a cell as a Nervos DAO deposit only if its type script exactly matches the DAO type script and its data is exactly 8 zero bytes. The DAO type script has code hash 0x82d76d1b75fe2fd9a27dfbaa65a039221a380d76c926f378d3f81cf3e7e13f2e, hash_type type and empty args. A phase one withdrawing cell has the same type script but a nonzero block number in its 8 data bytes, so it fails this check, as do data of any other length and look alike type scripts.

joined with the ckb-service-runner card teaching the same check

#Indexer queries and cell collection #Data encoding (molecule, hex, bigints) · 来源(2) · 2026-10-20

第 2 页,共 4 页

文本采用 CC BY 4.0:请署名 LusoCryptoLabs, CKB lessons,并附上经验的链接。 JSON · 想修改或撤下某条经验?请提交 issue。