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.

toastmanAu/daowow

Lições de toastmanAu/daowow

github.com/toastmanAu/daowow

Manténs este projeto? Confirma as lições 1 a 30 · Confirma as lições 31 a 51

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

Página 4 de 5

Use the secp256k1 sighash dep group, not the bare code cell, as the lock depPráticoDe uma correção

When a hand-built transaction spends a secp256k1_blake160_sighash_all cell, it needs a cell dep for that lock. That dep should be the genesis dep group (dep_type dep_group), not the bare code cell in genesis tx0, because the lock also loads the secp256k1_data table from a second cell. With only the code cell, ScriptNotFound goes away but the lock then fails inside execution.

#Cell deps and script lookup #Transaction building and fees · Fontes (2) · 2026-09-25

Occupied capacity depends on the actual lock's args lengthPráticoDe uma correção

When quoting the capacity for cells locked to a user's wallet, compute the occupied size from the connected lock script (8 capacity bytes + 32 code_hash + 1 hash_type + args length + type + data), not a hardcoded value. In this commit a JoyID lock with 22 byte args gives a 222 CKB claim cell and a secp256k1 lock with 20 byte args gives 220 CKB. The script's molecule serialization header does not count toward occupied capacity.

Distinct from the pre-sign checker lesson: this is about sizing by the connected lock's real args length.

#Capacity and cell size · Fontes (1) · 2026-09-23

Hand-rolled Script hash: hash_type byte mapping and molecule offsets, checked against CCCPráticoReproduzida

If you serialise a CKB Script molecule yourself to compute its blake2b hash, use a 16 byte header (total size plus three u32 offsets 16, 48, 49) and map hash_type as data=0, type=1, data1=2, data2=4 (not 3). This commit cross checks the result against ccc.Script.from(...).hash() for all four hash types, and a single wrong offset or data2 mapped to 3 makes that test fail.

#Data encoding (molecule, hex, bigints) #Testing and devnet · Fontes (1) · 2026-09-23

Split CCC signTransaction from sendTransaction to retry on consumed inputsPráticoDe uma correção

When several clients race to spend the same shared cell, sign with signer.signTransaction and send with signer.client.sendTransaction as two steps instead of signer.sendTransaction. The dead-input rejection only appears at broadcast, so wrapping just the send in the retry catch lets you tell contention (re-read the live cell, rebuild, sign again) from a wallet refusal or a script verification failure, which must not be retried. Cap the attempts, because each retry costs another signature.

#Transaction building and fees #Network and RPC reliability · Fontes (1) · 2026-09-23

Check that a derived successor type args match the spent cell's type argsPráticoDe uma correção

When a successor cell's type args are derived from other data (such as a config commitment) instead of copied from the spent input, compare them with the input cell's own type args before building. A mismatch (for example a config cell paired with a shard from another round) puts the input's type script group in the transaction with no output, so the type script runs as a burn and typically fails with an opaque error code. Read output.type.args during cell discovery and throw a clear client error on mismatch.

#Transaction building and fees #Cell deps and script lookup · Fontes (1) · 2026-09-23

ckb-cli tx init overwrites an existing tx file with an empty skeletonPráticoDe uma correção

`ckb-cli tx init --tx-file` creates a new empty transaction file and exits 0, so running it on a prepared transaction silently destroys that transaction. For a prebuilt transaction, write ckb-cli's tx-file wrapper ({transaction, multisig_configs, signatures}) yourself and go straight to `tx info` and `tx sign-inputs`.

#Transaction building and fees #Witnesses and signatures · Fontes (1) · 2026-09-23

ckb-cli tx sign-inputs stores signatures in the file's signatures map, not witness 0PráticoDe uma correção

ckb-cli `tx sign-inputs --add-signatures` leaves witness 0's lock zero-filled and records the signature in the tx file's `signatures` map keyed by lock arg; `tx send` assembles the final witnesses from that map. A checker that inspects witness 0 for a signature before `tx send` will wrongly report the transaction as unsigned, so read `doc.signatures[lockArg]` instead.

#Witnesses and signatures #Transaction building and fees · Fontes (1) · 2026-09-23

Pin JS cell data encoders and decoders to Rust generated vectorsPráticoDe uma correção

When JS code encodes or decodes CKB cell data or script args that an on chain Rust script parses, test it against vectors exported from the Rust crate's own encoder, not against the JS code's own expectations. Assert every decoded field and every encoded byte, because a length check cannot catch a shifted offset. Give each field a distinct non zero value so a one byte shift gives a visibly wrong result. Read u64 shannon fields as BigInt (DataView.getBigUint64) and reject data of the wrong length.

Joined with toastmanAu/daowow@e08898943c.

#Data encoding (molecule, hex, bigints) #Testing and devnet · Fontes (2) · 2026-09-22

Absence of on-chain references does not mean a code cell is safe to consumePráticoDe uma correção

Before consuming a deployed code cell, search live cells for its data hash as lock and type script code hash (prefix mode, hash types data, data1 and data2), and compare its data hash (blake2b with personalization ckb-default-hash) against the binaries you currently build. Zero references does not mean superseded: a contract unchanged by a rebuild has no users yet and is still the live deployment. This search does not see type ID references or cell dep use, so treat a cell that anything may resolve by type ID or as a dep as still needed.

#Type ID and upgrades #Indexer queries and cell collection #Cell deps and script lookup · Fontes (1) · 2026-09-20

Filter prefix get_cells results by data length before decodingPráticoDe uma correção

A get_cells query with script_search_mode "prefix" and args "0x" returns every live cell whose script has that code hash and hash_type, whatever its args, so it can include cells of the same script with a different data layout (for example a script that owns both a state cell and a ledger cell). Check output_data length, or catch the decode error, and skip the cell before calling a strict decoder. Otherwise one unexpected cell throws and the whole result list is lost.

#Indexer queries and cell collection #Data encoding (molecule, hex, bigints) · Fontes (1) · 2026-09-18

Indexer RPC module must be listed in ckb.toml rpc modules for get_cells on devnetPráticoDe uma correção

CKB serves get_cells, get_indexer_tip and the other indexer RPC methods only when "Indexer" is listed in the [rpc] modules array of ckb.toml. The ckb.toml generated in the nervos/ckb 0.209.0 devnet image used here leaves Indexer out, so add it before relying on cell collection against a devnet node. Then confirm with a real indexer call such as get_cells after the node starts.

#Indexer queries and cell collection #Testing and devnet · Fontes (1) · 2026-09-18

Never pass the terminal "0x" cursor back to indexer get_cellsPráticoDe uma correção

An exhausted indexer get_cells scan returns {objects: [], last_cursor: "0x"} (captured from a real node). The authors report that calling get_cells again with after = "0x" then returns nothing, even once matching cells exist, and a hand-written mock that never returned the real "0x" hid this for days. When paging, stop on an empty page before reading last_cursor, and never send or persist a "0x" cursor. Build paging tests from captured node responses, not hand-written mocks.

#Indexer queries and cell collection #Testing and devnet · Fontes (1) · 2026-09-18

Página 4 de 5

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.