CKB Pulse
经验

CKB 学到了什么

从这里开始 · 术语表 · 自测 · 订阅

经验用英文撰写,请用英文搜索。

来自一次修复

找到 155 条经验。 全部经验

第 2 页,共 13 页

JoyID sub-key signing needs the COTA aggregator and CSP allowances实践来自一次修复

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 · 来源(1) · 2026-11-16

Exact CKB-to-shannon conversion with BigInt实践来自一次修复

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

Lock-based fallback when a stored out point goes stale实践来自一次修复

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

Use findCellsOnChain for shared live state实践来自一次修复

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

Advancing devnet median time for time-lock tests实践来自一次修复

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

Occupied capacity minimum for every output基础来自一次修复

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 · 来源(2) · 2026-11-15

Molecule hash_type byte values实践来自一次修复

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

Devnet commits need the proposal window实践来自一次修复

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

Reset devnets instead of skewing the chain clock实践来自一次修复

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

Witness data in input_type and folding sub-minimum change实践来自一次修复

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

Hand-encoding WitnessArgs in molecule实践来自一次修复

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

ckb-debugger verifies one script group per run实践来自一次修复

`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 · 来源(1) · 2026-11-14

第 2 页,共 13 页

文本采用 CC BY 4.0:请署名 LusoCryptoLabs, CKB lessons,并附上经验的链接。 JSON · 想修改或撤下某条经验?请提交 issue。