LiçõesO que a CKB aprendeu
Começa aqui · Glossário · Testa-te · Feed
As lições estão escritas em inglês, por isso pesquise em inglês.
#Indexer queries and cell collection ✕
43 lições encontradas. Todas as lições
AnteriorPágina 2 de 4Seguinte
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 · Fontes (2) · 2026-11-05
Without an indexer on a small local chain, cells for a lock can be found by walking get_block_by_number from 0 to the tip, matching output locks, and confirming each hit with get_live_cell (with_data true). The commit also checks get_block_hash per height and at the end, then rechecks each match, so the result is treated as a snapshot that a reorg or spend can invalidate.
#Indexer queries and cell collection #Testing and devnet · Fontes (2) · 2026-11-05
When a send_transaction response is lost (the node may already have accepted the transaction), this commit pins the signed transaction hash and its input outpoints, and recovers by querying get_transaction for that exact hash and get_live_cell for each input instead of building a new payment. Only a 'committed' status ends the intent; rejected, unknown or spent inputs stay 'uncertain' for operator review, because a fresh rebuild from refreshed cells was shown to let a second payment to the same recipient commit.
#Network and RPC reliability #Transaction building and fees #Indexer queries and cell collection · Fontes (1) · 2026-11-02
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 · Fontes (1) · 2026-10-31
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 · Fontes (3) · 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 · Fontes (1) · 2026-10-30
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 · Fontes (1) · 2026-10-30
A CCC client caches the outputs of every transaction it sent, so when that transaction loses a race for the same input and never commits, its change cells still look usable to later builds. This campaign calls client.cache.clear() on every client before rebuilding and confirms candidate cells with getCellLiveNoCache rather than trusting cached state.
#Indexer queries and cell collection #Transaction building and fees · Fontes (1) · 2026-10-29
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 · Fontes (1) · 2026-10-29
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) · Fontes (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 · Fontes (1) · 2026-10-24
A signed CKB transaction that is not committed (not pending, proposed or sent) is still valid and can be broadcast by anyone while all its inputs are live, so do not release its input reservations yet. Release them only after a committed-state live-cell check shows at least one input spent (a spend still in the tx pool does not count), and a second status check confirms the transaction still has not committed. A conflicting spend can still be reorganized away, so require the operator to acknowledge that risk.
#Transaction building and fees #Indexer queries and cell collection #Network and RPC reliability · Fontes (2) · 2026-10-22
AnteriorPágina 2 de 4Seguinte
Texto sob CC BY 4.0: dá crédito à LusoCryptoLabs, CKB lessons, com uma ligação para a lição. JSON · Queres que uma lição seja mudada ou retirada? Abre um issue.