All lessons · Developer tooling · Start here · Glossary
Script hash_type selects the VM version: data2 (4) or type (1) for a VM2 targetWorkingFrom one fix
From one fix · Check: right · Checked 2026-11-19
CKB picks the VM version from the Script hash_type: data (0) runs VM0, data1 (2) runs VM1, data2 (4) runs VM2, and type (1) runs the latest activated VM. Code deployed for VM2 and pinned by data hash must be referenced with hash_type data2. The same code hash with data or data1 still resolves to the same cell but runs under an older VM, so tooling should reject those hash types for a VM2 target rather than only checking that the code hash matches.
Why it matters: A script whose code hash matches but whose hash_type is data or data1 still resolves to the code cell, yet it silently runs under an older VM than the code was built for.
Pattern
"ckb" => Some("data2"), "ckb-type-hash" => Some("type"),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/frozen_interface.rs,tests/policy_artifact_checker.rs
- Concepts
- Cell deps and script lookup, Type ID and upgrades
- Evidence
- From one fix: from one project, checked against its commit
- 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 (1)
- 2026-10-09 · CellScript-Labs/CellScript · more from this project
More about Developer tooling
- Absence of on-chain references does not mean a code cell is safe to consume
- Derive devnet Spore and system script cell deps from a fresh OffCKB export
- Matching a Script code_hash to its code Cell by hash_type
Do you maintain a project this lesson came from? Confirm or correct it
Cite this lesson
LusoCryptoLabs, "Script hash_type selects the VM version: data2 (4) or type (1) for a VM2 target", CKB lessons, https://pulse.lusocryptolabs.com/learned/tooling/script-hash-type-selects-the-vm-version-data2-4-or-type-1-fo, CC BY 4.0, last changed 2026-10-09.