CKB Pulse

All lessons · Rust scripts and ckb-std · Start here · Glossary

Type ID code cell upgrade keeps code_hash but spends the old cell depWorkingFrom one fix

From one fix · Check: right · Checked 2026-11-23

To upgrade a contract deployed under a Type ID type script, spend the old code cell and create exactly one output carrying the identical Type ID type script (same args) with the new binary as data. The type hash that cells reference with hash_type type stays the same. The old out point is spent, though, so any client that pins the code cell dep by tx hash and index must switch to the new out point, or its transactions are rejected.

Why it matters: After the upgrade, every SDK or demo transaction that still lists the old, now spent, code cell out point as a cell dep is rejected until the config points at the new out point.

Pattern

Prefer
outputs: [{ lock: deployerLock, type: typeScript, capacity: requiredCapacity }],

Taken from the commit, shortened.

Concepts
Type ID and upgrades, Cell deps and script lookup
Evidence
From one fix: from one project, checked against its commit
First seen
2026-11-21
Last changed
2026-11-21
Last checked
2026-11-23
Check against the commit
right: the lesson follows from its commit and still holds in the code today

Sources (1)

More about Rust scripts and ckb-std

All 36 in this topic

Do you maintain a project this lesson came from? Confirm or correct it

Cite this lesson
LusoCryptoLabs, "Type ID code cell upgrade keeps code_hash but spends the old cell dep", CKB lessons, https://pulse.lusocryptolabs.com/learned/scripts/type-id-code-cell-upgrade-keeps-code-hash-but-spends-the-old, CC BY 4.0, last changed 2026-11-21.

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.