diff --git a/rfcs/0052-extensible-udt/0052-extensible-udt.md b/rfcs/0052-extensible-udt/0052-extensible-udt.md new file mode 100644 index 00000000..daaa2ca7 --- /dev/null +++ b/rfcs/0052-extensible-udt/0052-extensible-udt.md @@ -0,0 +1,383 @@ +--- +Number: "0052" +Category: Standards Track +Status: Proposal +Author: Xuejie Xiao , Xu Jiandong +Created: 2024-01-09 +--- + + +# Extensible UDT + +Extensible UDT(xUDT) is an extension of [Simple +UDT](https://github.com/nervosnetwork/rfcs/blob/master/rfcs/0025-simple-udt/0025-simple-udt.md) for +defining more behaviors a UDT might need. While simple UDT provides a minimal +core for issuing UDTs on Nervos CKB, extensible UDT builds on top of simple UDT +for more potential needs, such as regulations. + +## **Data Structure** + +**xUDT Cell** + +An xUDT cell is backward compatible with Simple UDT, all the existing rules +defined in the Simple UDT spec must still hold true for xUDT cells. On top of +sUDT, xUDT extends a cell like the following: + +```yaml +data: + +type: + code_hash: xUDT type script + args: +lock: + +``` +The `amount` is a 128-bit unsigned integer in little endian format. The added `xUDT +args` and `xUDT data` parts provide all the new functions needed by xUDT, the +detailed structure is explained below. + +### **xUDT Args** + +xUDT args has the following structure: + +``` +<4-byte xUDT flags> +``` + +Depending on the content of `flags`, which is represented as a 32-bit unsigned +integer in little-endian format, different extension data might be attached: + +• If `flags & 0x1FFFFFFF` is 0, no extension data is required. Note a +backward-compatible way of viewing things, which is that a plain sUDT cell also +has a hidden `flags` field with all zeros. + +• If `flags & 0x1FFFFFFF` is 0x1, extension data will contain a +[molecule](https://github.com/nervosnetwork/molecule) serialized `ScriptVec` +structure: + +``` +table Script { + code_hash: Byte32, + hash_type: byte, + args: Bytes, +} + +vector ScriptVec