CKB Pulse
经验

CKB 学到了什么

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

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

实践

找到 174 条经验。 全部经验

第 6 页,共 15 页

Parsing snake_case JSON-RPC transactions in CCC实践已复现

ccc.Transaction.from reads only camelCase keys, so a snake_case JSON-RPC transaction (such as the ones ckb-cli writes, with cell_deps, outputs_data and similar) has to be converted with cccA.JsonRpcTransformers.transactionTo from @ckb-ccc/core/advanced. Passing that JSON directly to Transaction.from does not read those fields.

#Data encoding (molecule, hex, bigints) #Transaction building and fees · 来源(1) · 2026-11-08

Iterating group inputs and outputs with ckb-std until IndexOutOfBound实践来自一次修复

In a ckb-std script, walk the cells of a source with the high-level loaders, for example load_cell_type_hash(i, Source::GroupInput) or load_cell_lock_hash(j, Source::Output), in an index loop. Break on Err(SysError::IndexOutOfBound), and return a script error code for any other SysError. Accumulate the u64 capacities you load in a u128 so that a sum over many cells cannot overflow.

#Capacity and cell size #Cell deps and script lookup · 来源(1) · 2026-11-08

ckb-cli deploy info file layout for offline multisig signing实践来自一次修复

A `ckb-cli deploy` info file is JSON with snake_case JSON-RPC transactions `cell_tx` and `dep_group_tx` (either may be null), `used_input_txs` (previous transactions by hash, so inputs resolve offline), signature maps `cell_tx_signatures` and `dep_group_tx_signatures` (lock args to a list of 65-byte signatures), and `deployment.multisig_config` with `sighash_addresses`, `require_first_n`, `threshold` and `lock_code_hash`. Each member address is a full-format sighash address whose args are the member's key hash; the list can be empty when the default config is used, so check for that before building the multisig script.

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

Shape of ckb-cli deploy sign-txs output实践来自一次修复

`ckb-cli deploy sign-txs` prints two maps, `cell_tx_signatures` and `dep_group_tx_signatures`, for the deploy info file's `cell_tx` and `dep_group_tx`. Each map goes from lock args (20 bytes, or 28 for multisig args with a since) to one 65 byte signature. It prints YAML-style text by default and a JSON object with `--output-format json`, and the YAML writer prints an empty map inline as `cell_tx_signatures: {}`, so a parser collecting multisig signatures must accept both shapes and the inline empty header.

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

Lock code hashes differ between testnet and mainnet for Omnilock, JoyID, ACP and PW lock实践由所有者核对

When identifying a wallet's lock by its code hash, Omnilock, JoyID, anyone-can-pay and PW lock have different code hashes on testnet and mainnet (per CCC's known scripts), while secp256k1 and multisig share one across networks. Code that compares against a single testnet hash will misclassify or fail to filter mainnet locks, so keep a hash per network (or look it up from the client's known scripts).

#Cell deps and script lookup · 来源(1) · 2026-11-08

Multisig sighash placeholder lock: script plus M zeroed signatures实践来自一次修复

When computing the signing message for a secp256k1_blake160_multisig_all input, set the first witness's WitnessArgs.lock to the multisig script bytes followed by threshold × 65 zero bytes (a single key sighash lock uses just 65 zero bytes), and keep the inputType and outputType fields, before calling CCC's tx.getSignHashInfo(script, client). The same placeholder length must be used here as in the signed witness, otherwise the message differs from what the lock script hashes on chain.

#Witnesses and signatures #Transaction building and fees · 来源(2) · 2026-11-08

secp256k1_blake160_multisig_all signature matching rules实践来自一次修复

The system multisig lock (secp256k1_blake160_multisig_all) expects the witness to carry exactly M signatures (threshold), uses each member key at most once, and requires all of the first R keys (require_first_n) to be among them. A tool collecting partial signatures should dedupe per member key and check the first R are present before finalizing, since any M valid distinct signers that include the first R form a complete set.

#Witnesses and signatures · 来源(1) · 2026-11-08

CCC EVM and Bitcoin signers pass the exact signed text through signMessageRaw实践由所有者核对

In CCC, the EVM and Bitcoin signers' signTransaction builds the text to sign and passes it to this.signMessageRaw. A dApp can temporarily replace signMessageRaw on the signer instance, record the argument, call the original, and restore it afterwards, to show users the text the wallet will sign. Omnilock in Ethereum display mode (auth flag 0x12) passes "CKB transaction: 0x…" and Bitcoin signers pass "CKB (Bitcoin Layer) transaction: 0x…". PW-lock and Omnilock with flag 0x01 pass a bare 32 byte hash. This relies on CCC internals, so recheck it when upgrading.

#Witnesses and signatures · 来源(1) · 2026-11-07

Adding a wallet missing from CCC's connector via a SignersController subclass实践由所有者核对

To list a wallet that CCC's connector does not include yet, subclass ccc.SignersController (from @ckb-ccc/connector-react) and override addRealSigners: call this.addSigners(name, icon, [{ name: "CKB", signer }], context) with a ccc.Signer for that wallet, then await super.addRealSigners(context). Pass an instance to ccc.Provider as signersController. Wallets are shown in the order they are added, so adding yours before the super call puts it ahead of CCC's own. The Khie entry is drawn by the connector above that list and is not part of it; the hide-khie attribute removes it.

Order and the Khie entry checked against the CCC source at e10b99d (@ckb-ccc/ccc 1.3.7, connector 2.4.0): packages/ccc/src/signersController.ts (addSigner appends) and packages/connector/src/scenes/selecting/wallets.ts.

#Witnesses and signatures · 来源(1) · 2026-11-06

CCC EVM signer exposes several lock addresses via getAddressObjs实践由所有者核对

A CCC signer for MetaMask can control more than one CKB lock (Omnilock addresses and the legacy PW-lock address used by Portal Wallet), and getRecommendedAddressObj returns only one of them. When assets such as Nervos DAO deposits may sit under any of them, call signer.getAddressObjs(), dedupe by script hash and check each, rather than assuming the recommended address holds the funds.

#Indexer queries and cell collection #Login and authorization · 来源(1) · 2026-11-06

Nervos DAO phase 1 withdrawing cells keep the DAO type; count deposits by 8 zero bytes of data实践由所有者核对

A Nervos DAO cell in phase 1 of withdrawal still has the DAO type script (code hash 0x82d76d...3f2e, hash_type type, args 0x), so filtering by type alone counts it as a deposit. Only cells whose output data is exactly 0x0000000000000000 are deposits; a withdrawing cell's data holds its deposit block number. The commit's testnet test shows a type-only count giving 500 CKB where the true deposit total is 300 CKB.

#Indexer queries and cell collection #Data encoding (molecule, hex, bigints) · 来源(2) · 2026-11-06

Locate the signing witness slot instead of hardcoding its index实践来自一次修复

The signing witness of a lock group sits at the index of the first input that uses that lock, so it differs between transaction shapes (in QuotaCell, 1 for payments and most owner actions, 0 for a deposit). In CCC, take the position from tx.getSignHashInfo(lock, client).position and assert it matches the position you set, instead of hardcoding 1. A wallet or test mock that has no lock available can look for the placeholder witness, but a bare "first non-empty witness" search is only safe when no other input carries a witness.

#Witnesses and signatures · 来源(1) · 2026-11-05

第 6 页,共 15 页

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