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.

wildanrhmn/ckb-devnet-explorer

Lições de wildanrhmn/ckb-devnet-explorer

github.com/wildanrhmn/ckb-devnet-explorer

Manténs este projeto? Confirma as lições dele num só issue

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

Nervos DAO compensation from the header's accumulated rate (AR)PráticoVista outra vez

The DAO accumulated rate AR is the second little-endian u64 (bytes 8..16) of a header's `dao` field, for example from `get_header_by_number`. Interest accrues only on free = capacity minus occupied capacity, so compensation = free * AR_end / AR_deposit minus free, and the maximum withdraw is occupied + free * AR_end / AR_deposit. AR_deposit is the AR of the deposit block; AR_end is the AR of the block holding the withdrawing cell (phase 1) once withdrawal was requested, and only for a not yet withdrawn deposit is the tip AR used, as an estimate that is still growing.

#Capacity and cell size #Data encoding (molecule, hex, bigints) · Fontes (2) · 2026-11-10

Dry run a transaction with test_tx_pool_accept before send_transactionPráticoDe uma correção

The CKB node RPC test_tx_pool_accept takes the same params as send_transaction (the snake_case tx JSON without its hash, plus an outputs validator such as "passthrough"). It returns the cycles and fee the pool would accept without broadcasting, so a tool can check a pasted transaction before sending it for real.

#Transaction building and fees #Network and RPC reliability · Fontes (1) · 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

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

Finding cells of a ckb_js_vm JS contract needs a second indexer prefix searchPráticoDe uma correção

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

Transaction size for fee rate is serialized bytes plus 4PráticoDe uma correção

To get a transaction's size as the node counts it, take the molecule serialized size of the full transaction with witnesses (for example ccc.Transaction.from(...).toBytes().length) and add 4 bytes for its offset in the block. A size-based fee rate is fee * 1000 / size in shannons per 1000 bytes; the node's pool actually uses weight, the larger of size and cycles scaled, so it can be higher for cycle-heavy transactions. get_transaction returns snake_case JSON, so map the fields (code_hash to codeHash, dep_type dep_group to depGroup) before passing it to ccc.Transaction.from.

#Transaction building and fees #Data encoding (molecule, hex, bigints) · Fontes (1) · 2026-10-17

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.