CKB Pulse
Lessons

What CKB learned

Start here · Glossary · Test yourself · Feed

From one fix

155 lessons found. All lessons

Page 2 of 13

JoyID sub-key signing needs the COTA aggregator and CSP allowancesWorkingFrom one fix

If you strip external hosts from a CCC bundle or restrict CSP connect-src, keep CCC's COTA aggregator host (cota.nervina.dev) and allow it, because the JoyID signer calls it before signing for sub-key wallets. Also allow the RPC websocket hosts your CCC client uses, such as wss://testnet.ckb.dev.

Low confidence: inferred from the commit message only. The diff showed just a rebuilt bundle.

#Witnesses and signatures #Network and RPC reliability · Sources (1) · 2026-11-16

Exact CKB-to-shannon conversion with BigIntWorkingFrom one fix

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 · Sources (1) · 2026-11-15

Lock-based fallback when a stored out point goes staleWorkingFrom one fix

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 · Sources (1) · 2026-11-15

Use findCellsOnChain for shared live stateWorkingFrom one fix

client.findCells merges results from the client's local cache, which can still hold outputs of your own earlier transactions after other parties spent them on chain. When you need the true live cell set, such as state shared with other actors or runners, use client.findCellsOnChain.

Medium confidence.

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

Advancing devnet median time for time-lock testsWorkingFrom one fix

With the IntegrationTest RPC module enabled, call get_block_template, set current_time (hex ms) to a future value, and submit it with generate_block_with_template, block by block. Since/timestamp checks use the median time, which only moves after many future-dated blocks. Poll get_blockchain_info.median_time until it reaches the target rather than mining one far-future block.

#Testing and devnet #Since and time locks · Sources (1) · 2026-11-15

Occupied capacity minimum for every outputBasicFrom one fix

Every output must hold at least its occupied capacity: (8 for the capacity field + 33 + lock args length, plus 33 + type args length if a type script is present, plus data length) × 10^8 shannons. That is 61 CKB for a plain secp256k1 lock with 20 byte args and 63 CKB for a JoyID lock. A fixed payout or fee output set below the recipient lock's minimum is rejected, so choose a constant at or above the largest minimum among the locks you accept.

#Capacity and cell size #Transaction building and fees · Sources (2) · 2026-11-15

Molecule hash_type byte valuesWorkingFrom one fix

In the molecule Script encoding, hash_type is data=0, type=1, data1=2, data2=4; 3 is not a valid value. Using 2 where you meant data2 builds a valid data1 script with a different hash, so indexer queries on it return nothing. Assert the raw byte inside the encoded Script, or run against a real devnet, because mocks that reuse the same constant on both sides cannot catch it.

#Data encoding (molecule, hex, bigints) #Indexer queries and cell collection #Testing and devnet · Sources (1) · 2026-11-15

Devnet commits need the proposal windowWorkingFrom one fix

On a devnet a transaction is not committed as soon as you send it: it must be proposed in one block and committed in a later one inside the proposal window, so a fixed small number of mined blocks can still leave the old cell state. Before asserting, mine a couple of blocks at a time in a bounded loop and re-read the cell state until it equals the expected value or the retry limit is reached.

#Testing and devnet · Sources (1) · 2026-11-15

Reset devnets instead of skewing the chain clockWorkingFrom one fix

Pushing devnet timestamps ahead leaves the chain clock skewed for every later run, which stalls services that compare the tip with wall time. Reset the devnet for each scenario. At the start, assert that |tip timestamp − now| is small, for example under 600 s.

#Testing and devnet #Since and time locks · Sources (1) · 2026-11-15

Witness data in input_type and folding sub-minimum changeWorkingFrom one fix

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 · Sources (1) · 2026-11-14

Hand-encoding WitnessArgs in moleculeWorkingFrom one fix

WitnessArgs is a molecule table of three BytesOpt fields (lock, input_type, output_type). An absent field takes zero bytes, but a present empty field still takes a 4-byte length header, so the two encode differently. The table starts with a u32le total size, then three u32le offsets, the first being 16 (4 + 4*3), each counted from the start of the table. Check any hand-written encoder byte for byte against ccc.WitnessArgs.from(...).toBytes(), including the cases lock only, all absent, and a present empty field.

#Data encoding (molecule, hex, bigints) #Witnesses and signatures · Sources (1) · 2026-11-14

ckb-debugger verifies one script group per runWorkingFrom one fix

`full` is a VM mode, and by default ckb-debugger runs only input 0's lock, which may be an always-success lock. To check a whole transaction, enumerate every input lock, input type and output type group, run each with --script-group-type/--cell-type/--cell-index, and sum the cycles. Pair each accepted case with a control that must fail with an exact error code.

#Testing and devnet #Transaction building and fees · Sources (1) · 2026-11-14

Page 2 of 13

Text under CC BY 4.0: credit LusoCryptoLabs, CKB lessons, with a link to the lesson. JSON · Want a lesson changed or removed? Open an issue.