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
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)
- 2026-11-21 · salmansarwarr/Tranfr · more from this project
More about Rust scripts and ckb-std
- Delegating script validation via exec to a hash bound cell dep
- Separate builds for test-only contract constants
- Check that a derived successor type args match the spent cell's type args
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.