asset type
Sui에는 대체 가능, 대체 불가능, 기타 여러 asset standard가 있으며 각각 정의된 usage pattern과 capability가 있다. use case에 맞는 standard를 선택하는 것은 application에서 필요한 feature set을 활성화하는 데 중요하다.
Fungible token: Coin standard
Coin standard는 key와 store ability가 있는 fungible token을 정의한다. Coin은 wrapping과 public transfer를 지원한다. sui::coin module을 사용한다. Coin은 fungible asset을 위한 single object wrapper를 의미한다.
Coin<T> type은 open-loop fungible token을 나타낸다. Coin은 type parameter T로 denomination되며, T는 모든 Coin<T> instance에 적용되는 metadata(name, symbol, decimal precision 등)와도 연관된다.
Coin standard로 생성된 fungible token은 coin이라고 부른다.
coin::create_currency function으로 coin을 만들면 coin을 생성하는 smart contract의 publisher가 TreasuryCap object를 받는다. Coin standard는 CoinMetadata를 사용해 coin metadata를 정의한다.
Coin을 사용할 때
다음에 해당하면 Coin standard를 사용한다.
-
legacy code로 작업하거나
sui::coinmodule로 만든 existing coin을 유지한다. -
advanced supply tracking 또는 regulatory feature가 필요 없는 coin을 만든다.
-
metadata storage를 위해
CoinMetadata<T>object에 익숙하다.
주소 잔액
주소 잔액은 fungible asset을 Sui address에 직접 연결한다. 이는 address가 소유한 모든 Coin<T> object를 합산해 balance를 계산하던 UTXO-style Coin<T> model을 대체한다. 주소 잔액 기능을 사용하면 각 Sui address는 자신이 보유한 currency마다 하나의 address-owned balance를 가질 수 있으며, total balance는 모든 Coin<T> object와 주소 잔액의 합계이다. Coin<T>와 주소 잔액은 함께 존재할 수 있지만, 주소 잔액은 Coin<T>만 사용할 때보다 여러 이점을 제공한다.
전체 specification은 SIP-58: Sui Address Balances를 참조한다.
Fungible token: Currency standard
Currency standard는 open-loop system의 예시이다. 이는 어느 application에나 저장할 수 있는 free-flowing, wrappable, freely transferable fungible asset을 지원한다. sui::coin_registry module과 metadata용 Currency object를 사용한다. Currency는 Coin Registry에서 생성되는 object를 의미하며, currency property와 setup을 설명한다.
Currency<T> type은 open-loop fungible token을 나타낸다. Currency는 type parameter T로 denomination되며, T는 모든 Currency<T> instance에 적용되는 name, symbol, decimal precision 같은 metadata와도 연관된다.
Currency standard로 생성된 fungible token은 coin이라고 부른다.
coin_registry::new_currency와 coin_registry::new_currency_with_otw를 사용해 Currency standard로 coin을 만들 수 있다.
-
Standard creation(
coin_registry::new_currency): 대부분의 경우 권장된다. coin type이 publish된 뒤 언제든 이 method를 호출할 수 있다. -
One-Time Witness creation(
coin_registry::new_currency_with_otw): uniqueness proof에 One-Time Witness를 사용한다. two-step publish 및 finalize process가 필요하다.
Coin과 Currency standard는 모두 fungible token을 만드는 데 사용된다. 하지만 creation method와 metadata를 저장하는 object type이 다르다.
Coin은 coin::create_currency로 token을 만들고 Currency는 sui::coin_registry를 사용한다.
Coin은 CoinMetadata를 사용하고 Currency는 Currency를 사용한다.
Sui에서 Coin 또는 Currency standard로 생성된 fungible token은 coin이라고 부른다.
Closed-Loop Token standard로 생성된 fungible token에 대해 documentation은 token이라는 용어를 사용한다. 실제로 두 object에 대한 용어는 자주 서로 바꿔 쓰인다.
Coin Registry
Coin Registry system은 sui::coin_registry module을 통해 currency management에 대한 centralized approach를 제공한다. registry는 address 0xc에 위치한 shared object이며, 등록된 모든 coin type의 metadata, supply information, regulatory status를 저장한다.
Currency를 사용할 때
asset은 Currency Standard를 따르면서 specialized ability를 제공할 수 있다. 예를 들어 creator가 특정 address를 deny list에 추가하여 해당 address가 coin을 transaction input으로 사용하지 못하게 하는 regulated coin을 만들 수 있다.
다음에 해당하면 Currency standard를 사용한다.
- 새 coin을 만들고 Coin Registry를 사용하려 한다.
- fixed supply, burn-only supply, uncontrolled supply 같은 advanced supply chain management가 필요하다.
- deny list 같은 regulatory tracking이 필요하다.
- wallet, exchange, app과의 enhanced integration option이 필요하다.
- future-proofing option과 ongoing registry improvement에 접근해야 한다.
Permissioned asset
Permissioned Asset Standard는 현재 Testnet에서 사용할 수 있다. 아직 Mainnet에는 live 상태가 아니다.
Permissioned Asset Standard (PAS)는 Account object를 통한 asset ownership을 가능하게 한다. Account object는 asset을 보유하고 transfer control과 compliance check를 enforce할 수 있다. Account는 type과 독립적으로 하나의 asset만 보유할 수 있으며, asset은 동일한 programmable transaction block (PTB) 안에서 approve되고 resolve되어야 하는 hot potato request를 통해서만 Account 사이를 이동할 수 있다.
PAS는 Sui 주소 잔액을 사용한다. PAS balance는 wallet address를 대신해 PAS가 관리한다. 이는 derived Account object에 보관되지만 transfer는 항상 Account address가 아니라 wallet address를 대상으로 한다.
PAS asset은 Sui object에 저장되며 다른 address-owned data와 동일한 data access method로 query할 수 있다.
Permissioned Asset Standard 자세히 알아보기.
Fungible token: Closed-Loop Token standard
Permissioned Asset Standard (PAS)는 Closed-Loop Token (CLT) standard를 대체하는 새롭고 개선된 alternative를 제공한다. CLT 대신 PAS를 사용한다.
Closed-Loop Token standard는 key ability만 가진 fungible token을 만든다. Closed-loop token은 custom policy가 허용하지 않는 한 wrap, dynamic field 저장 또는 자유 transfer가 불가능하다. 이 restriction 때문에 이 standard로 생성된 token은 account만 소유할 수 있으며 application에 저장할 수 없다. 하지만 spend할 수는 있다. 이 standard는 sui::token module을 사용한다.
Closed-Loop Token standard로 생성된 fungible token은 token이라고 부른다.
Closed-Loop Token standard를 사용하면 token을 사용하는 application을 제한하고 transfer, spend, conversion에 대한 custom policy를 설정할 수 있다. 일부 application은 특정 service에만 사용할 수 있거나 authorized account만 사용할 수 있거나 특정 account의 사용을 차단할 수 있는 token이 필요할 수 있다. 현실 세계의 analog로는 regulated, bank-controlled, compliant한 bank account를 들 수 있다.
자세한 내용은 Closed-Loop Token을 참조한다.
Non-fungible token: Sui object
Sui는 object model을 사용하므로 Sui의 모든 entity는 unique ID를 가진다. application이 fungible token pool과 상호작용하든 non-fungible token collection과 상호작용하든, application의 smart contract는 individual object와 상호작용한다. 따라서 Sui는 ERC-721 standard가 작동하는 방식처럼 unique token instance를 만들기 위해 globally unique ID와 관련 smart contract address를 pair하는 NFT standard를 필요로 하지 않는다.
다음 예시 Move smart contract를 고려한다. NFT의 name attribute는 NFT 자체를 정의하는 object의 field이다. TestnetNFT struct는 id, name, description, url field로 NFT를 정의한다.
public struct TestnetNFT has key, store {
id: UID,
name: string::String,
description: string::String,
url: Url,
}