CKB Pulse
经验

CKB 学到了什么

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

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

实践

找到 174 条经验。 全部经验

第 4 页,共 15 页

Wallet discovery with SignersController实践来自一次修复

To support every CCC wallet without the @ckb-ccc/connector UI, call `new ccc.SignersController().refresh(client, callback, {name, icon})`. Keep the callback registered and update the picker, because it fires again as EIP-6963 wallets announce themselves. Treat signers that are `instanceof ccc.SignerDummy` as download links, not connectable wallets.

Medium confidence.

#Witnesses and signatures #Login and authorization · 来源(1) · 2026-11-12

Preview network spec removed from CKB实践来自一次修复

The preview network is retired and specs/preview.toml has been removed. `ckb init --chain preview` is rejected, and configs using { bundled = "specs/preview.toml" } fail to load after upgrading. Point tooling and tests at testnet, staging or dev instead.

#Testing and devnet · 来源(1) · 2026-11-12

Validate header and epoch lookups before using timestamps实践来自一次修复

After get_header_by_number or get_epoch_by_number, treat a null result as unavailable and check that the returned number equals the one you asked for. To get an epoch's start time, read the header at the EpochView's start_number. Then check that this header's epoch field has the epoch number in its low 24 bits and 0 in bits 24 to 39 (the block's index within the epoch), so the block really is the first block of that epoch.

#Network and RPC reliability #Since and time locks #Data encoding (molecule, hex, bigints) · 来源(2) · 2026-11-12

Pre-sign checkers must mirror every on-chain comparison实践来自一次修复

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

Check indexer lag with get_indexer_tip before signing实践来自一次修复

The built-in CKB indexer can trail the chain tip, so cells it returns may be stale. Before signing, compare the block_number from get_indexer_tip with the height from get_tip_header, show a notice when the gap is large, and refuse to sign while it is. daowow flags the indexer as lagging when it is more than 8 blocks behind, and its entry, refund and claim guards refuse to proceed in that state.

#Indexer queries and cell collection #Network and RPC reliability #Transaction building and fees · 来源(1) · 2026-11-10

Decoding the packed epoch field (number, index, length)实践再次出现

A CKB header epoch field packs the epoch number in the low 24 bits, the index in the next 16 bits (shift 24) and the epoch length in the next 16 bits (shift 40). When estimating time to a target epoch from the tip, subtract the fraction already spent (index * epoch duration / length) and guard against length 0 to avoid division by zero.

#Since and time locks #Data encoding (molecule, hex, bigints) · 来源(3) · 2026-11-10

get_consensus dao_type_hash is the DAO code hash, not the DAO type script hash实践来自一次修复

The dao_type_hash field returned by the get_consensus RPC is the native Nervos DAO code hash (used with hash_type type, args 0x). A contract that checks deposits with load_cell_type_hash needs the hash of the whole script, ccc Script{codeHash: dao_type_hash, hashType: "type", args: "0x"}.hash() (0xcc77c4de... on testnet); committing the raw dao_type_hash makes every deposit fail the check.

#Cell deps and script lookup #Data encoding (molecule, hex, bigints) · 来源(2) · 2026-11-10

Nervos DAO compensation from the header's accumulated rate (AR)实践再次出现

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

One prefix get_cells scan per type code hash instead of one scan per round实践来自一次修复

When many logical groups (here rounds) share one type script code hash, query the indexer's get_cells once with script_type "type", args "0x" and script_search_mode "prefix" to get every cell under that code hash, then bucket the cells client side by data length and args. Querying per group repeats the same scan and grows with the group count against a public node. The indexer returns cells in type args order, not age order, so sort the results yourself.

#Indexer queries and cell collection #Network and RPC reliability · 来源(1) · 2026-11-10

Do not detect DER signatures by a leading 0x30 byte实践来自一次修复

When converting secp256k1 signatures to DER for a CKB contract (here the Perun channel script, which uses k256 and expects low-S), a 64 or 65 byte compact R||S(||V) signature can begin with 0x30 because R is arbitrary. Dispatch on the fixed lengths first, and parse anything else with a full asn1.Unmarshal that has no trailing bytes, followed by a check that R and S lie in [1, n).

#Witnesses and signatures #Data encoding (molecule, hex, bigints) · 来源(1) · 2026-11-10

Placeholder JoyID lock args are 22 bytes when quoting capacity实践来自一次修复

When quoting capacity before a wallet is connected, use a placeholder lock shaped like the wallet you expect. A JoyID lock has 22 byte args, 2 bytes more than a secp256k1 lock's 20, so every cell carrying the user's lock needs 2 CKB more occupied capacity. Pass the placeholder (for example args of 22 zero bytes) to the same quote function used after connecting, so the pre-connect total is not lower than what a JoyID user will actually commit.

#Capacity and cell size #Transaction building and fees · 来源(1) · 2026-11-10

Sign a prepared transaction without broadcasting via CCC signOnlyTransaction实践来自一次修复

signer.signOnlyTransaction(tx) asks the CCC signer to sign a transaction you already completed (inputs, fee, cell deps, zero placeholder witness) without preparing or sending it. Treat the wallet as untrusted: pass it a copy, recheck the connected account after it returns, and verify the signed result against the sign hash you got from tx.getSignHashInfo(lock, client) on the prepared transaction (same tx hash, other witnesses untouched, signature recovers to the expected public key).

#Witnesses and signatures #Transaction building and fees · 来源(1) · 2026-11-09

第 4 页,共 15 页

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