CKB Pulse

全部经验 · Developer tooling · 从这里开始 · 术语表

Matching a Script code_hash to its code Cell by hash_type实践再次出现

再次出现 · 核对结果:正确 · 核对于 2026-11-19

To check that a Script points at a given deployed code Cell, compare its code_hash with ckb blake2b256 of the Cell's output data when hash_type is data, data1 or data2 (0, 2, 4), and with the hash of that Cell's Type Script when hash_type is type (1). A type selection needs the code Cell to actually carry a Type Script, and other hash_type values are rejected.

为什么重要: Comparing a code_hash against the wrong preimage, such as the ELF hash for a type-mode Script or a type hash for a data-mode Script, wrongly rejects a correct binding or accepts the wrong code Cell. A type selection also fails when the Cell has no Type Script.

代码模式

推荐
0 | 2 | 4 => artifact, 1 => type_hash.ok_or_else(|| invalid("Type-hash selection has no actual code Cell Type Script"))?,

摘自提交,已缩短。

同一提交中改动了测试

它与修复在一起,我们没有运行它。

概念
Cell deps and script lookup, Data encoding (molecule, hex, bigints)
证据
再次出现: 在两个或以上项目中出现
首次出现
2026-10-09
最近改动
2026-10-09
最近核对
2026-11-19
对照提交的核对结果
正确:这条经验出自该提交,并且在今天的代码中仍然成立

来源(2)

更多关于Developer tooling

查看此主题的全部 35 条

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

引用这条经验
LusoCryptoLabs, "Matching a Script code_hash to its code Cell by hash_type", CKB lessons, https://pulse.lusocryptolabs.com/learned/tooling/matching-a-script-code-hash-to-its-code-cell-by-hash-type, CC BY 4.0, last changed 2026-10-09.

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