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.

Apps and UI

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

Resolving cell deps per cell after redeploying a data-hashed scriptPráticoDe uma correção

After a data/data1 type script is redeployed with a new code hash, old cells still run against the old code. Keep a list of retired deployments and query the indexer for every one. Pick each cell's cell dep by matching the codeHash and hashType of that cell's own type script, not a single 'current' manifest entry.

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

Saving local state after the first step of a multi-step flowPráticoDe uma correção

In flows like Create followed by Arm, save local state right after the first transaction is sent. If you wait until the whole flow finishes, a failure in a later step leaves an on-chain object the user cannot find or cancel. Add the extra fields, such as the descriptor, once the later steps succeed.

#Transaction building and fees #Other · Fontes (1) · 2026-11-16

Exact CKB-to-shannon conversion with BigIntPráticoDe uma correção

Convert user-entered CKB amounts to shannons with BigInt string arithmetic: BigInt(whole) * 100000000n + BigInt(fraction.padEnd(8, '0')). Never use parseFloat(amount) * 1e8. First validate the input with /^\d+(\.\d{1,8})?$/, which rejects exponents, hex and commas, and reject any result above u64::MAX (0xffffffffffffffffn).

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

Lock-based fallback when a stored out point goes stalePráticoDe uma correção

A saved out point stops being valid once the cell is consumed and recreated. Use the recorded out point if it is still live; otherwise find the unique live cell matching the exact lock (code_hash, hash_type, args). In both cases, still check the cell's contents against the recorded values.

#Indexer queries and cell collection · Fontes (1) · 2026-11-15

Witness data in input_type and folding sub-minimum changePráticoDe uma correção

Put the type script's witness data in WitnessArgs.input_type of each input it guards (the type script reads the first witness of its own input group), so the lock field stays free for the wallet's signature and one signature can cover several such inputs. If the change left after a fixed fee is below a plain cell's minimum occupied capacity, add it to an existing output whose scripts accept extra capacity; if there is no such output, refuse the build instead of creating a cell that cannot exist.

#Witnesses and signatures #Transaction building and fees #Capacity and cell size · Fontes (1) · 2026-11-14

Nervos DAO hold time with term-locked withdrawalsPráticoDe uma correção

The Nervos DAO pays out phase 2 only at a whole number of 180-epoch cycles counted from the deposit epoch D, so a withdrawal started after D + 180×n matures at D + 180×(n+1). If a lock refuses phase 1 until a term of n cycles has passed, then in practice the funds are held (n + 1) × 180 epochs, not n × 180, and interest stops at the phase 1 block. Only a phase 1 that lands exactly in the boundary epoch fraction avoids the extra cycle.

#Since and time locks #Other · Fontes (1) · 2026-11-13

Pinning JS codecs and derivations to Rust test vectorsPráticoDe uma correção

When off-chain JS encodes or derives cell data that a Rust type script decodes or re-derives byte for byte, test the JS against JSON vectors generated by the Rust code, using a distinct value in every field so a wrong offset fails. Mirror the contract's validation refusals and its exact ordering and rounding: BTreeMap ascending key order, BigInt floor division with the dust going to fixed indices, and merging duplicates before dividing. The chain only returns a bare error code, so only this off-chain check can tell you which rule failed.

#Data encoding (molecule, hex, bigints) #Testing and devnet #Transaction building and fees · Fontes (2) · 2026-11-13

Pre-sign checkers must mirror every on-chain comparisonPráticoDe uma correção

A pre-sign checker that reuses the builder's assumptions will miss the builder's bugs, so make it compare every field the script compares, outputs_data included. When you add data to an output, count those bytes in its occupied capacity (8 + data + lock + type). Replay refused transactions in ckb-debugger against the deployed binaries to confirm the fix.

#Capacity and cell size #Transaction building and fees #Testing and devnet · Fontes (1) · 2026-11-11

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

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.