CKB Pulse

全部经验 · Rust scripts and ckb-std · 从这里开始 · 术语表

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

来自一次修复 · 核对结果:正确 · 核对于 2026-11-19

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.

为什么重要: With data2 encoded as 2, the service built a data1 script that matched no cell, so its Node Cell query found nothing and every run reported dropped; the mock chain used the same constant on both sides and never caught it.

代码模式

const HASH_TYPE_DATA2: u8 = 2; // wrong, 2 is data1; correct value is 4
概念
Data encoding (molecule, hex, bigints), Indexer queries and cell collection, Testing and devnet
证据
来自一次修复: 来自一个项目,已对照其提交核对
首次出现
2026-11-15
最近改动
2026-11-15
最近核对
2026-11-19
对照提交的核对结果
正确:这条经验出自该提交,并且在今天的代码中仍然成立

来源(1)

更多关于Rust scripts and ckb-std

查看此主题的全部 35 条

你维护这条经验的来源项目吗?请确认或纠正

引用这条经验
LusoCryptoLabs, "Molecule hash_type byte values", CKB lessons, https://pulse.lusocryptolabs.com/learned/scripts/molecule-hash-type-byte-values, CC BY 4.0, last changed 2026-11-15.

取自公开提交,并对照每条经验的来源提交和项目当前代码做了核对。使用前请先读来源。 文本采用 CC BY 4.0:请署名 LusoCryptoLabs, CKB lessons,并附上经验的链接。 想修改或撤下某条经验?请提交 issue。