CKB Pulse

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

Prefer
"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.

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)

More about Developer tooling

All 35 in this topic

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.

Drawn from public commits and checked against the commit each one came from and the project's code today. Read the source before you rely on one. Text under CC BY 4.0: credit LusoCryptoLabs, CKB lessons, with a link to the lesson. Want a lesson changed or removed? Open an issue.