从这里开始 · 术语表 · 自测 · 订阅
经验用英文撰写,请用英文搜索。
“Data encoding (molecule, hex, bigints)” ✕
找到 44 条经验。 全部经验
上一页第 2 页,共 4 页下一页
A get_cells query with script_search_mode "prefix" and args "0x" returns every live cell whose script has that code hash and hash_type, whatever its args, so it can include cells of the same script with a different data layout (for example a script that owns both a state cell and a ledger cell). Check output_data length, or catch the decode error, and skip the cell before calling a strict decoder. Otherwise one unexpected cell throws and the whole result list is lost.
#Indexer queries and cell collection #Data encoding (molecule, hex, bigints) · 来源(1) · 2026-09-18
CKB hash_type encodes as data=0, type=1, data1=2, data2=4 (no value 3), so a config loader should reject any hashType string outside data/type/data1/data2 rather than map it loosely. A wrong code hash or hash type makes cell discovery watch the wrong cells and silently return empty results.
hash_type validation, not covered
#Cell deps and script lookup #Data encoding (molecule, hex, bigints) · 来源(1) · 2026-09-18
With ckb-vm-js 0.2.0 from npm, verifyScriptGroup accepts an RPC header in context.tip_header that carries its own hash only when that hash matches the recomputed one, and fails with "header hash does not match" otherwise (the earlier vendored build rejected any `hash` field as unknown). Dropping `hash` before passing RPC headers or transactions remains safe because the verifier recomputes it.
No existing lesson covers how ckb-vm-js treats a hash field on RPC headers.
#Testing and devnet #Data encoding (molecule, hex, bigints) · 来源(1) · 2026-11-17
A script group is identified by BLAKE2b-256 with the 'ckb-default-hash' personalization over the Molecule-encoded Script (code_hash, hash_type byte data=0/type=1/data1=2/data2=4, args). Lock groups come only from inputs. Type groups come from inputs and outputs, and lock and type groups with the same hash stay distinct. Passing the code_hash as the group hash yields ScriptNotFound.
#Data encoding (molecule, hex, bigints) #Witnesses and signatures · 来源(1) · 2026-11-16
InvalidDepGroup prints the OutPoint in molecule encoding: a 32-byte tx_hash followed by a 4-byte little-endian index. Reverse the index bytes, then match only dep_group cell_deps on both tx_hash and index.
#Cell deps and script lookup #Data encoding (molecule, hex, bigints) · 来源(1) · 2026-11-16
In a ckb-debugger mock_info, list the dep_group cell with dep_type "dep_group" (data included) and also list each member out point as a separate cell dep with dep_type "code", with its data. Get the members by decoding the group cell's data as a molecule OutPoint vector: a u32 LE count, then per entry a 32-byte tx hash and a u32 LE index (36 bytes each), and check that the length is 4 + 36*count bytes.
#Testing and devnet #Cell deps and script lookup #Data encoding (molecule, hex, bigints) · 来源(1) · 2026-11-14
nervosnetwork/sparse-merkle-tree folds runs of empty siblings into MergeWithZero nodes (merge byte 2; a normal merge uses byte 1 plus height and parent path), and bit 0 of a key is the low bit of byte 0. Compiled proofs use the opcodes 0x4c, 0x50, 0x51, 0x4f n (n=0 means 256) and 0x48. Test any off-chain port against vectors generated by the Rust code.
#Data encoding (molecule, hex, bigints) #Testing and devnet · 来源(1) · 2026-11-14
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 · 来源(2) · 2026-11-13
A CKB script that refuses a transaction returns only an error code that names no rule, so port the contract's witness decoders to JS with the same refusals (bad version, truncation, trailing bytes, count or size limits). Check that they round-trip bytes produced by the Rust code. Before signing, run a checker that re-derives the contract's rules from the finished transaction, and pin each rule with a mutation test that breaks one field of a valid transaction and expects that rule's named reason.
#Testing and devnet #Data encoding (molecule, hex, bigints) #Since and time locks · 来源(1) · 2026-11-13
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
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
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
上一页第 2 页,共 4 页下一页
文本采用 CC BY 4.0:请署名 LusoCryptoLabs, CKB lessons,并附上经验的链接。 JSON · 想修改或撤下某条经验?请提交 issue。