Extensible UDT(xUDT) is an extension of Simple UDT 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:

data:
    <amount: uint128> <xUDT data>
type:
    code_hash: xUDT type script
    args: <owner lock script hash> <xUDT args>
lock:
    <user_defined>

The added xUDT args and xUDT data parts provide all the new functions needed by xUDT, we will explain the detailed structure below.

xUDT Args

xUDT args has the following structure:

<4-byte xUDT flags> <Variable length bytes, extension data>

Depending on the content of flags, different extension data might be attached:

• If flags & 0x1FFFFFFF is 0, we won’t need any extension data. 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 serialized ScriptVec structure:

table Script {
    code_hash:      Byte32,
    hash_type:      byte,
    args:           Bytes,
}

vector ScriptVec <Script>

Each entry included in ScriptVec structure is interpreted as a CKB script hash for an extension script with additional behaviors. When an xUDT script is executed, it will run through each included extension script. Only when all extension scripts pass validation, will xUDT also consider the validation to be successful.