Start here · Glossary · Test yourself · Feed
CKB node, RPC and indexer ✕
45 lessons found. All lessons
PreviousPage 3 of 4Next
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 · Sources (3) · 2026-10-30
The CKB node's get_transaction RPC does not return a null result for rejected or unknown hashes: it returns an object whose transaction field is null and whose tx_status.status is "rejected" (with tx_status.reason holding the rejection reason) or "unknown". Check res.transaction, not just res, before reading outputs, surface tx_status.reason to users, and make test mocks return this shape rather than result null.
Joined with toastmanAu/openswap@4dbe3232c3.
#Network and RPC reliability #Testing and devnet · Sources (2) · 2026-10-30
The built-in indexer RPCs get_cells and get_transactions return at most the requested limit (here 0x3e8) plus a last_cursor. To read all results for a search key, pass last_cursor as the fourth param on the next call and stop once a page returns fewer objects than the limit; a single call with a small limit (the old 0xc8 or 0x19) undercounts cells and transactions.
#Indexer queries and cell collection #Network and RPC reliability · Sources (1) · 2026-10-30
The block header `dao` field packs four little endian u64 values (C, AR, S, U), and U at byte offset 24 is the total occupied capacity of all live cells in shannons. This commit reads it from `get_tip_header` to show chain state size, and for a genesis that holds the 8.4 billion CKB cell (mainnet and offckb devnet) it subtracts 5.04 billion CKB counted as occupied because it is due to be burnt, as the CKB Explorer does.
#Capacity and cell size #Data encoding (molecule, hex, bigints) · Sources (1) · 2026-10-30
When one account sends several transfers in a row (here via `offckb transfer`), a new transfer started before the previous one is committed can pick the same input cell, and the node rejects it with PoolRejectedRBF. This faucet queues claims and polls get_transaction until tx_status is committed, rejected or unknown before building the next transfer.
#Transaction building and fees #Network and RPC reliability · Sources (1) · 2026-10-30
With CCC client.findTransactionsPaged (scriptSearchMode 'prefix', groupByTransaction: true), each returned transaction has a cells list of {isInput, cellIndex} entries for the cells that matched the searched script. If your logic only needs the matched inputs, fetch parent transactions with getTransaction only for those indexes (plus siblings from a parent you already hold) and skip unrelated inputs such as wallet funding. OpenSwap's market scanner did this together with raising read concurrency to 16, and its first scan went from about 8 to 10 s to about 5.3 s; the gain from this change alone was not measured.
#Indexer queries and cell collection #Network and RPC reliability · Sources (1) · 2026-10-29
A node reporting a transaction you sent as rejected or unknown does not prove it is dead: one node's answer is not proof, and while all its inputs are live the signed bytes could still be rebroadcast by someone and commit. Only release its reserved inputs if a later transaction is guaranteed to conflict with it (here a shared pool cell every later action must spend, so at most one can commit), and also require that every input is still live, that the status is still rejected or unknown when rechecked after the input reads, and that the submission is old enough (2 minutes here), behind an explicit confirmation.
#Transaction building and fees #Network and RPC reliability · Sources (1) · 2026-10-26
A cell that runs a JS contract carries the ckb_js_vm script as its lock or type. Its args are 2 flag bytes, then the contract's 32 byte code hash, then its hash type byte (data 0, type 1, data1 2, data2 4). A get_cells prefix search on the contract's own code_hash finds none of these cells, so also run a prefix search on the ckb_js_vm script with args set to flags plus code hash plus hash type byte, and merge the results. With 0x0000 as the flags, that search only matches cells whose flags are zero.
#Indexer queries and cell collection #Data encoding (molecule, hex, bigints) · Sources (1) · 2026-10-25
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 · Sources (1) · 2026-10-24
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 · Sources (2) · 2026-10-10
A CKB Transaction's packed size (the length of get_transaction with verbosity 0) can be computed from its RPC JSON without serializing it. It is 12 (table header) + RawTransaction + witnesses. RawTransaction is 28 (table header) + 4 (version) + cell_deps (4 + 37 each) + header_deps (4 + 32 each) + inputs (4 + 44 each) + outputs + outputs_data. Each CellOutput is 16 + 8 + lock size, plus the type script size only when a type is present. Each Script is 53 + len(args). A dynvec costs 4 + 4 * count + the sum of its item sizes, and every Bytes item in outputs_data and witnesses costs 4 + len.
#Data encoding (molecule, hex, bigints) #Transaction building and fees · Sources (1) · 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 · Sources (1) · 2026-10-10
PreviousPage 3 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.