1. Overview
There is a solution to put UDT info in the cell for reading, but if we don’t change info often, we can treat UDT Info as static data and put it in witness. This solution is an additional solution to info_cell and does not conflict with info_cell.
The advantage is that it can reduce the state occupation on the chain. When UDT is useless, no state will be occupied, and there will be no situation where the state is still occupied on the chain after the EOS fundraising ends. The disadvantage is that if adding CKB will cut the block, the information may be lost.
2. Info_data format
decimals: uint8
name: Common knowledge Byte
symbol: CKB
extra: {website:"https://nervos.org"} // optional
In info_data, the most basic information that must be included is token_name, token_symbol and decimals. The current total supply and balance can be obtained by indexing the live cell.
The UDT information format in the specification is as follows:
data:
-decimals: (uint8 type) The number of decimal places used by the token. If decimals is 8, it means that the token can be divisible by at least 0.00000001.
-tokenname: Token name, UTF8 encoded character array.
-symbol: The identifier of the token, such as “HIX”, an array of characters encoded in UTF8.
-extra: anything you want to write, such as the website, the hash value of a certain picture, etc.
The first three items are parameters that must be filled in, and information can be added as required.
3. For Single Owner sUDT
The issuance of sUDT on CKB is controlled by lockscript, so the simplest sUDT is issued by an individual or organization using a lockscript controlled by a private key, such as USDC and other stable coins.
// Issue new UDT/UDT_Info
Inputs:
<... one of the input cell must have owner lock script as lock>
Outputs:
UDT_Cell:
Data:
amount: uint128
Type:
code_hash: simple_udt type script
args: owner lock script hash (...)
Lock:
<user defined>
witnesses:
...
<Corresponding to owner cell>lock:signature,input_type:...,output_type:udt_info_data
...
For a single owner controlled UDT, info_data satisfies the following rules:
- Rule 1: First check according to the rules of info_cell, if there is a corresponding info_cell, use info_cell.
- Rule 2: When there is no corresponding info_cell, scan the entire chain for the minting transaction corresponding to UDT, and look for the first transaction that has data in the format of info_data in the output_type of the witness corresponding to owner_cell, and it can be determined as the info of the UDT .
4. For Script-drive sUDT
Script-driven UDT stands for, the owner_lock of udt is not a lock controlled by a private key, but a special script.
// Issue new SUDT/SUDT_Info
Inputs:
<... one of the input cell must have owner lock script as lock>
Outputs:
UDT_Cell:
Data:
amount: uint128
Type:
code_hash: simple_udt type script
args: owner lock script hash (...)
Lock:
<user defined>
witnesses:
...
<Corresponding to owner cell>lock:signature,input_type:...,output_type:udt_info_data
...
For a script-drive UDT, info_data satisfies the following rules:
- Rule 1: First check according to the rules of info_cell, if there is a corresponding info_cell, use info_cell.
- Rule 2: When there is no corresponding info_cell, scan the entire chain for the minting transaction corresponding to UDT, and look for the first transaction that has data in the format of info_data in the output_type of the witness corresponding to owner_cell, and the hash of info_data is equal to owner The first 32 bytes of the args of lockscript.