All lessons · Rust scripts and ckb-std · Start here · Glossary
Molecule hash_type byte valuesWorkingFrom one fix
From one fix · Check: right · Checked 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.
Why it matters: 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.
Pattern
const HASH_TYPE_DATA2: u8 = 2; // wrong, 2 is data1; correct value is 4- Concepts
- Data encoding (molecule, hex, bigints), Indexer queries and cell collection, Testing and devnet
- Evidence
- From one fix: from one project, checked against its commit
- First seen
- 2026-11-15
- Last changed
- 2026-11-15
- Last checked
- 2026-11-19
- Check against the commit
- right: the lesson follows from its commit and still holds in the code today
Sources (1)
- 2026-11-15 · psawyerberlin/ckb-revocable-timelock · more from this project
More about Rust scripts and ckb-std
- ckb-std C shim needs a RISC-V C toolchain (clang) in CI
- Median time vs tip timestamp for deadlines
- Use raw_data(), not as_slice(), when parsing a packed::Bytes witness
Do you maintain a project this lesson came from? Confirm or correct it
Cite this lesson
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.