CKB Pulse
Lições

O 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.

Prático

174 lições encontradas. Todas as lições

Página 8 de 15

get_live_cell may return "unknown" rather than "dead" for a spent outputPráticoVista outra vez

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

get_transaction returns an object with a null transaction for rejected and unknown txsPráticoVista outra vez

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 · Fontes (2) · 2026-10-30

Paging indexer get_cells and get_transactions with last_cursorPráticoDe uma correção

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

Reading total occupied capacity (U) from the header DAO fieldPráticoDe uma correção

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) · Fontes (1) · 2026-10-30

Serialize transfers from one account until the previous tx is committedPráticoDe uma correção

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 · Fontes (1) · 2026-10-30

Minimum capacity of a cell depends on its lock args lengthPráticoVerificada pelo dono

A cell with no type and no data needs at least 8 (capacity) + 32 (code hash) + 1 (hash type) + args length in CKB: 61 CKB for a secp256k1_blake160 lock (20-byte args), 63 CKB for a JoyID lock with 22-byte args. A contract that knows a recipient lock only by hash cannot measure it, so a hardcoded floor for the fee output must be at least the largest lock it may face on each network, and a test should measure the real lock against it. Otherwise the fee output cannot be built.

#Capacity and cell size · Fontes (2) · 2026-10-30

Finding a spore or cluster by id through the indexer's get_transactionsPráticoDe uma correção

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

JoyID signer prices fees with a 1,000 byte signature placeholderPráticoDe uma correção

With CCC and @ckb-ccc/joy-id, prepareTransaction fills the JoyID witness lock with a 1,000 byte placeholder before the fee is computed as ceil((serialized size + 4) x rate / 1000). The real signature is usually shorter (347 bytes in one testnet order), so the committed transaction is smaller and its measured rate is higher than the rate it was built at (7,278 against 5,000 shannons/KB). To recover the build rate, clone the transaction, set the JoyID witness lock back to 1,000 zero bytes, and compute the rate on that size, confirming with tx.estimateFee(rate) equal to the paid fee.

#Transaction building and fees #Witnesses and signatures · Fontes (1) · 2026-10-30

Clamp the node's get_fee_rate_statistics median before using it as a fee ratePráticoDe uma correção

Do not pass the node's get_fee_rate_statistics median straight to a transaction builder: a high or untrusted endpoint can set the fee rate for every transaction you build. Clamp it between the minimum relay rate (1,000 shannons/KB) and an app-chosen ceiling, and fall back to the minimum if the call fails, accepting that a ceiling below the real market rate can make confirmation slow. openswap used 1,000 to 5,000 shannons/KB (testnet nodes suggested 33,000 to 47,000) plus a 0.01 CKB per-transaction cap.

#Transaction building and fees #Network and RPC reliability · Fontes (1) · 2026-10-29

Clear the CCC client cache after a sent transaction loses a double spend racePráticoDe uma correção

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

Verifying an immutable data1 script code cell after deploymentPráticoDe uma correção

For a script referenced by hashType 'data1', put the binary in a cell whose lock is the always fail lock (codeHash 32 zero bytes, hashType data1, args 0x, which no code cell can match) and with no type, so the cell can never be spent and the cell dep stays live; the capacity is locked forever. After sending, read the cell with client.getCellLive(outPoint, true) and assert that ccc.hashCkb(outputData) equals the pinned code hash, that the lock equals the always fail lock and that there is no type, ideally on more than one endpoint. The data1 code hash is already pinned by the binary's content; the immutable lock is what keeps the cell available.

#Cell deps and script lookup #Type ID and upgrades · Fontes (1) · 2026-10-29

Use indexer matched cell indexes to limit input parent fetchesPráticoDe uma correção

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

Página 8 de 15

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.