从这里开始 · 术语表 · 自测 · 订阅
经验用英文撰写,请用英文搜索。
#Indexer queries and cell collection ✕
找到 43 条经验。 全部经验
上一页第 3 页,共 4 页下一页
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
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
To show a CKB address balance, convert the address to a lock script (ckb-sdk-utils addressToScript returns camelCase codeHash/hashType) and pass it to the indexer RPC get_cells_capacity with snake_case fields (code_hash, hash_type, args) and script_type "lock". The returned capacity is a hex shannon string, so parse it with BigInt and divide by 10^8 for CKB.
#Indexer queries and cell collection #Data encoding (molecule, hex, bigints) · 来源(1) · 2026-10-15
The CKB light client keeps reporting a script, with its block number, from get_scripts until you register a new script set that leaves it out. A sync poll that runs between your local delete and that set_scripts call will still see the removed script. Do not let that poll recreate local per script progress for an owner that no longer exists, and clear that progress again once the new set is registered while polling is excluded.
#Indexer queries and cell collection #Network and RPC reliability · 来源(1) · 2026-10-11
Before consuming a deployed code cell, call indexer get_cells across the whole chain with script_search_mode "prefix" and args "0x", once as lock and once as type. Query the cell's data hash with hash_type data, data1 and data2, and for a Type ID cell also its type script hash with hash_type type. Zero results only means no live cell uses the binary right now. Consuming the cell is irreversible, and a Type ID identity cannot be recreated, so treat unused Type ID cells with extra caution.
#Cell deps and script lookup #Indexer queries and cell collection #Type ID and upgrades · 来源(2) · 2026-10-10
In a CKB devnet reorg test, transactions from detached blocks can return to the txpool and be committed again on the winning branch, which hides the rollback you want to observe. Have the winning branch spend one input of the orphaned transaction, such as its fee input, before the branches reconnect. Resubmitting the old transaction is then rejected with TransactionFailedToResolve (-301), and you must rebuild it with fresh funding.
#Testing and devnet #Indexer queries and cell collection · 来源(1) · 2026-10-10
With the CKB light client, a DAO withdrawing cell older than the script's sync start is never returned by the scan, and the phase-2 unlock output is a plain cell that does not point back at it. So absence from the scan cannot mark the position spent: retire it only when the unlock transaction is confirmed (a verified local inclusion, or getTransactionStatus reporting committed on the node), keep it shown as confirming while the unlock is in flight, and never treat an unreachable node or an unknown transaction as a spend.
#Indexer queries and cell collection #Other · 来源(2) · 2026-10-09
The indexer's get_cells lists only cells live at its current tip. To get Nervos DAO deposits live at height H, read the indexer tip, list get_cells and keep those with block_number <= H, then read the indexer tip again as T. Then query get_transactions on the DAO type script with filter block_range [H+1, T+1) (the end is exclusive), keep io_type input, follow each input's previous_output to the creating tx and its header, and add back cells created at or below H. In both passes keep only real deposits (DAO type and 8 zero bytes of data), since withdrawing cells share the type script, and retry if either tip hash is no longer canonical per get_block_hash.
#Indexer queries and cell collection #Network and RPC reliability · 来源(1) · 2026-10-08
A locally maintained index of CKB blocks can lag the node or still hold an orphaned block after a reorg, so before serving its tip as an anchor, fetch the node's tip number, wait briefly for the index to reach it, then ask the node for the canonical block hash at the indexed height and refuse (503 with NOT_SYNCED or REORGANIZING) unless it equals the indexed hash. The check narrows the window but is not atomic, so a client that signs over the anchor should also compare it with an independent source.
#Network and RPC reliability #Indexer queries and cell collection · 来源(1) · 2026-10-08
In a devnet reorg test, the inclusion status a client reads from the node does not mean your own indexing service has processed that block. Before truncating the chain below block n, poll that service's indexed block number until it reaches n. Otherwise it never sees the block, never records a rollback, and the test times out on slow CI runners.
#Testing and devnet #Indexer queries and cell collection · 来源(1) · 2026-10-08
If an app saves per-script sync progress from the light client's get_scripts while another path calls set_scripts to reset or re-register scripts, a get_scripts result read before the set landed can overwrite the reset progress. Do the get_scripts read and the progress write under the same lock that guards set_scripts, and have the poll use tryLock and skip that tick while a registration is in flight, so it never queues behind it. Pocket Node does this in SyncCoordinator.tryWithRegistrationLock.
#Indexer queries and cell collection #Network and RPC reliability · 来源(1) · 2026-10-06
The CKB light client's set_scripts with the all command replaces every registered script, so a call carrying only one wallet's lock script unregisters all other wallets. When several scripts must stay tracked, either pass the full set with each script's own start block, or use the partial command to update only the changed script. If registrations can race, serialise them so a stale full set cannot overwrite a newer one.
#Indexer queries and cell collection #Network and RPC reliability · 来源(1) · 2026-09-30
上一页第 3 页,共 4 页下一页
文本采用 CC BY 4.0:请署名 LusoCryptoLabs, CKB lessons,并附上经验的链接。 JSON · 想修改或撤下某条经验?请提交 issue。