CKB Pulse

全部经验 · xUDT and tokens · 从这里开始 · 术语表

Carry type script and data into the output when spending a lock-only custody cell实践来自一次修复

来自一次修复 · 核对结果:部分正确 · 核对于 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.

为什么重要: 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.

代码模式

推荐
outputs: [{ lock: toLock, type: cell.cellOutput.type, capacity: cell.cellOutput.capacity }], outputsData: [cell.outputData],

摘自提交,已缩短。

同一提交中改动了测试

它与修复在一起,我们没有运行它。

概念
Transaction building and fees, Cell deps and script lookup, Witnesses and signatures
证据
来自一次修复: 来自一个项目,已对照其提交核对
首次出现
2026-10-21
最近改动
2026-10-21
最近核对
2026-11-19
对照提交的核对结果
部分正确:核心属实,但有一部分表述松散或范围过宽

来源(1)

更多关于xUDT and tokens

查看此主题的全部 2 条

你维护这条经验的来源项目吗?请确认或纠正

引用这条经验
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.

取自公开提交,并对照每条经验的来源提交和项目当前代码做了核对。使用前请先读来源。 文本采用 CC BY 4.0:请署名 LusoCryptoLabs, CKB lessons,并附上经验的链接。 想修改或撤下某条经验?请提交 issue。