Skip to main content

CoTA NFT Protocol Extension

There are four predefined smt_type enum for NFT operations.

type name1st byte2nd bytedescription
cota-NFT-define0x81 (NFT)0x00NFT issuance definition
cota-NFT-hold0x81 (NFT)0x01current hold NFT
cota-NFT-withdrawal0x81 (NFT)0x02NFT withdrawal record
cota-NFT-claim0x81 (NFT)0x03NFT claim record

Here are the detailed k-v definitions.

# cota-NFT-define data structure
key:
smt_type: uint16 # type bytes for cota-NFT-define big endian
token_id: Byte[20] # hash(inputs[0].out_point + first_cota_index)[0..20]
reserved: Byte[10]
value:
total: uint32 # 0 for unlimited
issued: uint32
configure: Byte[1]
reserved: Byte[22]
ending: 0xFF # in case all-zero value

# cota-NFT-hold data structure
key:
smt_type: uint16 # type byte for cota-NFT-hold
token_id: Byte[20]
index_id: uint32
reserved: Byte[6]
value:
configure: Byte[1]
state: Byte[1]
characteristic: Byte[20] # user-defined data
reserved: Byte[9]
ending: 0xFF # in case all-zero value

# cota-NFT-withdraw data structure
key:
smt_type: uint16 # type byte for cota-NFT-withdraw
token_id: Byte[20]
index_id: uint32
reserved: Byte[6]
value:
blake2b_hash of {
configure: Byte[1]
state: Byte[1]
characteristic: Byte[20] # user-defined data
to_lock: lock_script
out_point: OutPoint[12..36] # Outpoint of previous input cell with SMT
}

# cota-NFT-claim data structure
key:
blake2b_hash of {
smt_type: uint16 # type byte for cota-NFT-claim
token_id: Byte[20]
index_id: uint32
out_point: OutPoint[12..36] # Outpoint field recorded in the proof
|
value:
0x00...00 for nonclaimed
0xFF...FF for claimed

Where token_id (also written as cota_id in the early designs) is an UUID for all fungible and non-fungible tokens. Its value is set according to the token definition transaction data.

token_id = hash(tx.inputs[0].out_point | tx.outputs.get_first(cota_type).index)[0..20]