All lessons · CCC (TypeScript SDK) · Start here · Glossary
Hand-rolled Script hash: hash_type byte mapping and molecule offsets, checked against CCCWorkingReproduced
Reproduced · Check: right · Checked 2026-11-19
If you serialise a CKB Script molecule yourself to compute its blake2b hash, use a 16 byte header (total size plus three u32 offsets 16, 48, 49) and map hash_type as data=0, type=1, data1=2, data2=4 (not 3). This commit cross checks the result against ccc.Script.from(...).hash() for all four hash types, and a single wrong offset or data2 mapped to 3 makes that test fail.
Why it matters: A wrong molecule offset or data2 mapped to 3 yields a plausible script hash that matches nothing, so a lock hash comparison such as entry-lock's committed participant check refuses the spend.
Pattern
const hashType = { data: 0, type: 1, data1: 2, data2: 4 }[script.hashType];Taken from the commit, shortened.
A test changed in the same commit
It sits next to the fix. We did not run it.
- toastmanAu/daowow:
apps/web/test/refund-tx.test.js
Reproduced by a test
A public test runs what this lesson says on @ckb-ccc/core 1.23.1, with no node. Anyone can run it.
tests/ccc/script-hash.test.mjs
- Concepts
- Data encoding (molecule, hex, bigints), Testing and devnet
- Evidence
- Reproduced: reproduced by a public test
- First seen
- 2026-09-23
- Last changed
- 2026-09-23
- 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-09-23 · toastmanAu/daowow · more from this project
More about CCC (TypeScript SDK)
- CCC custom client scripts must include AnyoneCanPay for SignerCkbPrivateKey
- Convert Fiber RPC snake_case scripts to CCC camelCase ScriptLike
- Parsing snake_case JSON-RPC transactions in CCC
Do you maintain a project this lesson came from? Confirm or correct it
Cite this lesson
LusoCryptoLabs, "Hand-rolled Script hash: hash_type byte mapping and molecule offsets, checked against CCC", CKB lessons, https://pulse.lusocryptolabs.com/learned/ccc/hand-rolled-script-hash-hash-type-byte-mapping-and-molecule, CC BY 4.0, last changed 2026-09-23.