All lessons · Developer tooling · Start here · Glossary
Matching a Script code_hash to its code Cell by hash_typeWorkingSeen again
Seen again · Check: right · Checked 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.
Why it matters: 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.
Pattern
0 | 2 | 4 => artifact, 1 => type_hash.ok_or_else(|| invalid("Type-hash selection has no actual code Cell Type Script"))?,Taken from the commit, shortened.
A test changed in the same commit
It sits next to the fix. We did not run it.
- CellScript-Labs/CellScript:
tests/policy_artifact_checker.rs
- Concepts
- Cell deps and script lookup, Data encoding (molecule, hex, bigints)
- Evidence
- Seen again: seen in two or more projects
- First seen
- 2026-10-09
- Last changed
- 2026-10-09
- Last checked
- 2026-11-19
- Check against the commit
- right: the lesson follows from its commit and still holds in the code today
Sources (2)
- 2026-10-09 · CellScript-Labs/CellScript · more from this project
- 2026-10-06 · salmansarwarr/Kirea-finance · more from this project
More about Developer tooling
- Decoding InvalidDepGroup OutPoints
- Mock transactions must expand dep_group members
- ckb-vm-js 0.2.0 (npm) checks header hash instead of rejecting the field
Do you maintain a project this lesson came from? Confirm or correct it
Cite this lesson
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.