RFC: Modified Extensible UDT for better script-driven UDT

In the existing CKB UDT design, the issuer of the UDT must be an Owner. Specifically, the mint transaction of the UDT must ensure that a cell with specific owner_lock in the input_cell is destroyed. Logically this is not a problem, any operation on mint can be written to owner’s Lockscript, but in practice, this can cause problems for script-driven UDTs.

For example: Wrapped CKB: When we want to design a simple script to convert CKB to wCKB, originally this only requires simple logic, and there is no state contention, but due to the design of the existing UDT standard, if there is not enough owner_cells is for use, and when there are too many mint txs at the same time, there will be serious state contention, which will affect the user experience. Of course, the user can construct an owner_cell at his own expense, but this is an inexplicable expense for the user and cannot be returned, which will also affect the user experience.

The same problem exists for the scheme of releasing the liquidity of NervosDAO pledged CKB, such as dCKB. All in all, for all UDTs is not issued by a specific owner but are based on a certain logic, the existing owner-centric UDT standards have affected the user experience.

Therefore, the reverse design is a better choice. Instead of converting the logic into owner_cell, the owner unlocking is regarded as a special logic.

The following logical decision has made a small modification to xUDT ( RFC: Extensible UDT - English / CKB Development & Technical Discussion - Nervos Talk), so it is still called xUDT.

I think the modification described below is a minor change to xUDT and can bring many benefits.

Data Structure

xUDT Cell

An xUDT cell is backwards 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 following:

    <amount: uint128> <audt data>
    code_hash: modified extensible_udt type script
    args: <owner lock script hash> 
    	or <xudt args>   //this is the only change, and -> or

The rules are as follows:

  • If the length of args is 32 Bytes and a cell’s lock_hash in input_cells matches it, the logic of simple UDT is followed.
  • Otherwise, go through the verification process of xUDT.
    • For UDTs that need extended functions and are issued by private keys, such as UDTs issued by centralized institutions and require compliance verification, the owner logic can be used as a Script in ScriptVec.
    • Of course, we can also use the unused xudt_flags to propose a new xUDT args type. if xudt_flags is 0x3, the extension data is owner_lock_script_hash | scriptVec; if xudt_flags is 0x4, the extension data is owner_lock_script_hash | scriptVecHash.

Under this design, script-driven UDTs such as ckb->wCKB can be written as logic, and only one cell needs to be the dependency of all mint transactions without destroying it.

We can do more design on xUDT, here are some ideas:

  • The face value of UDT can only be fixed, such as 0.1, 0.5, 1, 5, 10.
  • The face value of UDT can only be 1, at this time we can use it as a simple NFT.

If you have an idea, please give a suggestion.

1 Like