A SUDT Information Storage Meta Cell Design Proposal

SUDT Info


We know that SUDT is a minimal standard,and the relevant information about issuing SUDT, such as the initial total amount of issuance, token name, token identification, decimal number, and so on, is not globally on-chain consensus in the SUDT standard. In practice, different SUDTs may have different minimum divisible decimal places when exchanging tokens on DEXs, so we need a supplementary extension of SUDT information on the chain, i.e. SUDT Info, which only serves the purpose of declaring and displaying on the chain and making the sudt-related information readable.

Data Structure

SUDT Info Cell

A SUDT Info cell in specification looks like following:

data:
    decimals: uint8
    tokenname:Laxxx
    symbol:LAX
    //totalSupply:100.00(optional)
    
type:
    code_hash: sudt_info type script
    args: sudt type script hash
lock:
    <user_defined>

Data:

  • decimals: (uint8 type)the number of decimal digits used by the token, if decimals is 8 it means that the token can be divided to 0.00000001 at least.
  • tokenname: name of token
  • symbol: identifier of the token, such as “HIX”
  • totalSupply: (Optional) the initial total amount of issuance
  • Other: Support for custom field expansion

Issue SUDT/SUDT_Info

This operation enables issuing new SUDT/SUDT_Info.

// Issue new SUDT/SUDT_Info
Inputs:
    <... one of the input cell must have owner lock script as lock>
Outputs:
    SUDT_Cell:
        Data:
            amount: uint128
        Type:
            code_hash: simple_udt type script
            args: owner lock script hash (...)
        Lock:
            <user defined>
     
    **SUDT_Info_Cell:**
        Data:
            decimals: uint8
            tokenname:
            symbol:
          //totalSupply:(可选)
        Type:
            code_hash: sudt_info type script
            args: sudt type script hash
        Lock:
            <user defined>   
            

The following rules should be met in a SUDT Info Cell(Type Script):

  • Rule 1: In constructing a transaction, the output must exist in a SUDT Cell ( SUDT ID ) that matches the type script_args parameter field.

  • Rule 2: extracts the type script_args field parameter of output this SUDT cell (i.e. owner lock script hash), at least one input cell uses the owner lock script specified by this SUDT.

  • Rule 3:

    Data storage format common standards: except (the first field) using uint8 type (1 byte), all using UTF-8 encoding, with a newline character “0x0a” to separate each field, of which the first three fields (the first three lines) are fixed default fields (in order for decimals, tokenname,symbol). The following fields (starting from the fourth line) are custom fields, using kv pair format to store “field name: value”.

    Examples of data standards are as follows.

SUDT_Info Cell Data:   //UTF-8:
  6                   //uint8
  USD Coin
  USDC
  Totalsupply:10000000.000000
  Official Site:<https://www.centre.io/> 
  Description:XXXX
------------------------------------------
//Hex:
0x060a55534420436f696e0a555344430a546f74616c737570706c793a31303030303030302e3030303030300a4f66666963616c20536974653a68747470733a2f2f7777772e63656e7472652e696f2f0a4465736372697074696f6e3a78787878

About the uniqueness of the SUDT Info Cell

By looking at the SUDT specification , the uniqueness of sudt-type script hash(SUDT) inherits from the owner lock script hash, and the current sudt issuance of the owner lock script uses the default Lock (secp256k1_blake160), i.e. Based on the issuer’s publickey (Lock_args) being unique on chain, the sudt_info_type script inheriting from the sudt-type script hash is similarly unique.

And through the rules of the sudt_info_type script it is ensured that only the corresponding SUDT issuer can generate and modify the SUDT Info Cell.

But the sudt issuer can still issue multiple SUDT_ Info Cells with different data contents:

Currently, the default ckb lock is used as the owner lock script for issuing sudt, and the issuer can issue as many sudt as they want without any rule restriction, so the prerequisite for trusting this type of sudt is to believe that the issuer is self-disciplined. Therefore, it is not necessary for the issuer to issue multiple sudt info cells with different information.

6 Likes

SUDT Info


我们知道SUDT是最简化标准,关于发行SUDT的相关信息如初始发行总量,代币名称,代币标识,小数位数这些信息在SUDT标准中并没有在链上实现全局共识。实际在DEX代币交换时不同SUDT可能有不同最小可划分小数位,因此我们需要在链上做一个关于SUDT的信息补充拓展即SUDT Info,仅起到链上声明展示且可读取sudt相关信息的目的。

Data Structure

SUDT Info Cell

一个 SUDT Info Cell 的结构如下:

data:
    decimals: uint8
    tokenname:Laxxx
    symbol:LAX
    //totalSupply:100.00(可选)
    
type:
    code_hash: sudt_info type script
    args: sudt type script hash
lock:
    <user_defined>

Data:

  • decimals: uint8 位于data区最开始占用1byte.代币使用的小数位数,如decimals为8时意味着代币最小可以划分到0.00000001
  • tokenname: 代币的名称
  • symbol: 代币的标识,如“HIX”
  • totalSupply:(可选)
  • 其他: 支持自定义字段拓展

Issue SUDT/SUDT_Info

This operation enables issuing new SUDTs.

// Issue new SUDT/SUDT_Info
Inputs:
    <... one of the input cell must have owner lock script as lock>
Outputs:
    SUDT_Cell:
        Data:
            amount: uint128
        Type:
            code_hash: simple_udt type script
            args: owner lock script hash (...)
        Lock:
            <user defined>
     
    **SUDT_Info_Cell:**
        Data:
            decimals: uint8
            tokenname:
            symbol:
          //totalSupply:(可选)
        Type:
            code_hash: sudt_info type script
            args: sudt type script hash
        Lock:
            <user defined>   
            

SUDT Info Cell (Type Script)应满足如下规则:

  • 规则1: 在构造交易中,output须存在与type script_args参数字段一致的SUDT Cell,

  • 规则2: 提取output该SUDT Cell的type script_args字段参数(即owner lock script hash),至少存在一个input cell使用了该sudt所指定的owner lock script。

  • 规则3:

    Data数据存储标准: 除(第一字段)采用uint8类型(占1byte),均采用UTF-8编码,以换行符“0x0a”隔开每个字段,其中前三个字段(前三行)为固定默认字段(依次为decimals、tokenname、symbol),因此不带字段名直接存储字段值;后续字段(第四行开始)为自定义字段,采用kv pair格式存储"字段名:值“,每行(每字段)提取第一个“:”(0x3a)为字段名与值的分隔符。

    Data标准范例如下:

SUDT_Info Cell Data:   //UTF-8:
	6
	USD Coin
	USDC
	Totalsupply:10000000.000000
	Official Site:https://www.centre.io/ 
	Description:XXXX
------------------------------------------
//Hex:
0x060a55534420436f696e0a555344430a546f74616c737570706c793a31303030303030302e3030303030300a4f66666963616c20536974653a68747470733a2f2f7777772e63656e7472652e696f2f0a4465736372697074696f6e3a78787878

关于SUDT Info Cell唯一性的问题

通过查看SUDT的规范标准,(SUDT) sudt-type script hash的唯一性继承自owner lock script hash,而当前sudt的发行owner lock script采用的默认Lock(secp256k1_blake160),即基于发行者公钥(Lock_args)具有链上唯一性,因此sudt_info_type script 继承自sudt-type script hash也同样具有唯一性。

且通过sudt_info_type script 的规则限定确保了只有对应sudt发行者可以生成并修改SUDT Info Cell.

但sudt发行者依然可印发多个data内容不同的sudt info cell:

目前采用ckb默认锁作为owner lock script印发sudt,发行者是可以随意增发sudt没有进行规则限制,因此信任此类型sudt的前提是相信发行方是自律不作恶的。所以基于此前提发行方没有必要印发多个不同信息的sudt info cell。

3 Likes

This standard will work well with SUDT, but it will also work with the upcoming NFT standards being worked on. You may want to expand the scope beyond SUDT.

There are a few areas I believe would benefit from some additional guidelines. When I say “guidelines” I specifically mean they are recommendations that a developer could choose to ignore if they need to.

  • Should key names be one word or multiple words? Spaces or underscores? Lower case, Title Case, PascalCase, or camelCase?
  • Should binary values be encoded in base64 or 0x prefixed hex strings?
  • Are multiple identical key values allowed?

We can also define more optional fields such as:

  • Description
  • Website URL
  • Icon URL
  • Alternate symbols
3 Likes

Agreed, I think the community will make consensus on the guidelines gradually, along with more and more tokens adopt this standard.

1 Like

规则3 存储的如果是结构化的数据就好了,最简单的用 json,还可以用 jsonschema 校验

If sUDT info type do not allow update and destroy, and we all admit the eldest info cell, then it’s ok to bypass the multi-info attack.

Due to marketing and other needs, it is possible to rename and split UDT.