Start here · Glossary · Test yourself · Feed
#Indexer queries and cell collection ✕
43 lessons found. All lessons
Page 1 of 4Next
After a data/data1 type script is redeployed with a new code hash, old cells still run against the old code. Keep a list of retired deployments and query the indexer for every one. Pick each cell's cell dep by matching the codeHash and hashType of that cell's own type script, not a single 'current' manifest entry.
#Cell deps and script lookup #Type ID and upgrades #Indexer queries and cell collection · Sources (1) · 2026-11-17
A saved out point stops being valid once the cell is consumed and recreated. Use the recorded out point if it is still live; otherwise find the unique live cell matching the exact lock (code_hash, hash_type, args). In both cases, still check the cell's contents against the recorded values.
#Indexer queries and cell collection · Sources (1) · 2026-11-15
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 · Sources (1) · 2026-11-15
In the molecule Script encoding, hash_type is data=0, type=1, data1=2, data2=4; 3 is not a valid value. Using 2 where you meant data2 builds a valid data1 script with a different hash, so indexer queries on it return nothing. Assert the raw byte inside the encoded Script, or run against a real devnet, because mocks that reuse the same constant on both sides cannot catch it.
#Data encoding (molecule, hex, bigints) #Indexer queries and cell collection #Testing and devnet · Sources (1) · 2026-11-15
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 · Sources (1) · 2026-11-10
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 · Sources (1) · 2026-11-10
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 · Sources (2) · 2026-11-10
Cells returned by a prefix search on type script args (as findRounds does here) come back in indexer key order, sorted by type args, not by creation time, so taking the first result does not give the newest cell. To get the latest, sort by a field stored in the cell (here the round config's entryStart).
#Indexer queries and cell collection · Sources (1) · 2026-11-09
A frozen-tip check ("the indexer tip must not change during the scan") fails often on a live chain, so do not demand it. Select a single funding cell from get_cells, verify it directly against the node (get_live_cell, get_transaction, get_header, output and data equal to the indexed ones), then re-check at the end that get_block_hash at the starting indexer tip still equals the anchor hash, that the cell's block is canonical, and that the cell is still live. New blocks arriving in between are fine, but still fail closed if the indexer lags the node at the start or the anchor hash changed. This gives one verified input, not a snapshot of the whole wallet.
#Indexer queries and cell collection #Network and RPC reliability · Sources (1) · 2026-11-09
After get_transaction reports tx_status committed, poll get_indexer_tip until its block_number is at least the transaction's block number before calling get_cells. If you query first, the indexer silently returns the pre-transaction cell set with no error.
#Indexer queries and cell collection #Network and RPC reliability · Sources (4) · 2026-11-09
A CCC signer for MetaMask can control more than one CKB lock (Omnilock addresses and the legacy PW-lock address used by Portal Wallet), and getRecommendedAddressObj returns only one of them. When assets such as Nervos DAO deposits may sit under any of them, call signer.getAddressObjs(), dedupe by script hash and check each, rather than assuming the recommended address holds the funds.
#Indexer queries and cell collection #Login and authorization · Sources (1) · 2026-11-06
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) · Sources (2) · 2026-11-06
Page 1 of 4Next
Text under CC BY 4.0: credit LusoCryptoLabs, CKB lessons, with a link to the lesson. JSON · Want a lesson changed or removed? Open an issue.