All lessons · xUDT and tokens · Start here · Glossary
Carry type script and data into the output when spending a lock-only custody cellWorkingFrom one fix
From one fix · Check: partly right · Checked 2026-11-19
When a custom lock's spend rebuilds an output from an input cell that may carry a type script (a UDT held in custody, say), copy cell.cellOutput.type and cell.outputData into the output and change only the lock; writing outputsData "0x" with no type burns or strands the token. Add the type script's cell deps to the transaction before signing, because the signature covers the cell deps and callers cannot append them afterwards, and refuse to build the spend if a typed cell comes without them. If the lock also constrains who gets the capacity (as Tranfr's recipient claim does today), follow that rule instead of a plain copy.
Why it matters: Without it, the spend rebuilds the custody cell as plain capacity with empty data, so a UDT held in it is dropped. A typed cell's script would also lack its cell deps, which cannot be added once the transaction is signed.
Pattern
outputs: [{ lock: toLock, type: cell.cellOutput.type, capacity: cell.cellOutput.capacity }], outputsData: [cell.outputData],Taken from the commit, shortened.
A test changed in the same commit
It sits next to the fix. We did not run it.
- salmansarwarr/Tranfr:
sdk/tests/client.test.ts
- Concepts
- Transaction building and fees, Cell deps and script lookup, Witnesses and signatures
- Evidence
- From one fix: from one project, checked against its commit
- First seen
- 2026-10-21
- Last changed
- 2026-10-21
- Last checked
- 2026-11-19
- Check against the commit
- partly right: a true core, with a part that is loose or too wide
Sources (1)
- 2026-10-21 · salmansarwarr/Tranfr · more from this project
More about xUDT and tokens
Do you maintain a project this lesson came from? Confirm or correct it
Cite this lesson
LusoCryptoLabs, "Carry type script and data into the output when spending a lock-only custody cell", CKB lessons, https://pulse.lusocryptolabs.com/learned/xudt/carry-type-script-and-data-into-the-output-when-spending-a-l, CC BY 4.0, last changed 2026-10-21.