본문으로 건너뛰기

자산 토큰화 reference

tokenized_asset module은 coin library와 유사한 방식으로 동작한다.

새 One-Time Witness type을 받으면 fractional asset의 unique representation을 만든다. 이 module은 Coin module의 일부 method와 유사한 implementation을 사용한다. 새 asset 생성, minting, splitting, joining, burning 등 asset tokenization에 관련된 functionality를 포함한다. 자세한 내용은 The Move Book의 One-Time Witness를 참조한다.

struct

  • AssetCap

    fractional NFT로 표현되는 각 새 asset마다 AssetCap을 생성한다. 대부분의 scenario에서는 owned object로 만들고, access-restricted method invocation을 위해 platform administrator에게 transfer할 수 있다.

    struct AssetCap<phantom T> {
    id: UID,
    // the current supply in circulation
    supply: Supply<T>,
    // the total max supply allowed to exist at any time
    total_supply: u64,
    // Determines if the asset can be burned or not
    burnable: bool
    }
  • AssetMetadata

    AssetMetadata struct는 fractionalize할 전체 asset을 나타내는 metadata를 정의한다. 이는 shared object여야 한다.

    struct AssetMetadata<phantom T> has key, store {
    id: UID,
    /// Name of the asset
    name: String,
    // the total max supply allowed to exist at any time
    total_supply: u64,
    /// Symbol for the asset
    symbol: ascii::String,
    /// Description of the asset
    description: String,
    /// URL for the asset logo
    icon_url: Option<Url>
    }
  • TokenizedAsset

    TokenizedAsset은 remaining supply 이하의 지정된 balance로 mint된다. asset의 VecMap이 value로 채워져 있으면(multiple unique entry를 의미) NFT로 간주된다. asset의 VecMap이 채워져 있지 않으면(individual entry가 없음을 의미) FT로 간주된다.

    struct TokenizedAsset<phantom T> has key, store {
    id: UID,
    /// The balance of the tokenized asset
    balance: Balance<T>,
    /// If the VecMap is populated, it is considered an NFT, else the asset is considered an FT.
    metadata: VecMap<String, String>,
    /// URL for the asset image (optional)
    image_url: Option<Url>,
    }
  • PlatformCap

    PlatformCap은 contract를 deploy한 address에 발급되는 capability이다. 이 capability는 platform functionality와 관련된 specific permission을 부여하여 deployer가 deployed contract 안에서 특정 controlled action 또는 access right를 갖도록 한다.

    /// Capability that is issued to the one deploying the contract
    struct PlatformCap has key, store { id: UID }

함수

  • init

    PlatformCap을 만들고 transaction sender에게 transfer한다.

    fun init(ctx: &mut TxContext) {}
  • new_asset

    중요한 attribute를 포함하는 새 asset representation을 만든다. AssetCapAssetMetadata라는 2개의 distinct object를 반환한다. 이 object들은 system 안에서 asset을 정의하는 데 필요한 정보와 characteristic을 encapsulate한다.

    public fun new_asset<T: drop>(
    witness: T,
    total_supply: u64,
    symbol: ascii::String,
    name: String,
    description: String,
    icon_url: Option<Url>,
    burnable: bool,
    ctx: &mut TxContext
    ): (AssetCap<T>, AssetMetadata<T>) {}
  • mint

    tokenized asset을 mint한다. 이 process 중 새 metadata가 도입되면 tokenized asset은 unique해지고 balance가 1로 설정된 NFT가 생성된다. 새 metadata가 추가되지 않으면 system은 tokenized asset을 FT로 classify하여 제공된 argument에 지정된 대로 balance가 1을 초과할 수 있게 한다. tokenized asset object를 반환한다.

    public fun mint<T>(
    cap: &mut AssetCap<T>,
    keys: vector<String>,
    values: vector<String>,
    value: u64,
    ctx: &mut TxContext
    ): TokenizedAsset<T> {}
  • split

    balance가 1보다 큰 FT type의 tokenized asset과 object balance보다 작은 value를 받아 split operation을 수행한다. 이 operation은 existing tokenized asset을 2개의 separate tokenized asset으로 나눈다. 새로 생성된 tokenized asset은 지정된 value와 같은 balance를 가지며, 제공된 object의 balance는 지정된 value만큼 감소한다. 새로 생성된 tokenized asset을 반환한다. 이 function은 NFT type의 tokenized asset을 받지 않는다.

    public fun split<T>(
    self: &mut TokenizedAsset<T>,
    split_amount: u64,
    ctx: &mut TxContext
    ): TokenizedAsset<T> {}
  • join

    FT type의 tokenized asset 2개를 받아 merge한다. 이 operation은 첫 번째 tokenized asset의 balance를 두 번째 tokenized asset의 balance만큼 늘린다. 그런 다음 system은 두 번째 tokenized asset을 burn한다. burned tokenized asset의 ID를 반환한다. 이 function은 NFT type의 tokenized asset을 받지 않는다.

    public fun join<T>(
    self: &mut TokenizedAsset<T>,
    other: TokenizedAsset<T>
    ): ID {}
  • burn

    AssetCap을 parameter로 요구하여 invocation을 platform admin으로 제한한다. tokenized asset을 받아 burn한다. circulating supply는 burned item의 balance만큼 감소한다. burnable tokenized asset이 필요하다.

    public fun burn<T>(
    cap: &mut AssetCap<T>,
    tokenized_asset: TokenizedAsset<T>
    )
  • total_supply

    asset의 maximum supply를 반환한다.

    public fun total_supply<T>(cap: &AssetCap<T>): u64 {}
  • supply

    asset의 current circulating supply를 반환한다.

    public fun supply<T>(cap: &AssetCap<T>): u64 {}
  • value

    tokenized asset의 balance를 반환한다.

    public fun value<T>(tokenized_asset: &TokenizedAsset<T>): u64 {}
  • create_vec_map_from_arrays

    VecMap<String, String>을 채우는 internal helper function이다. VecMap data structure 안에 key-value pair를 채우는 process를 지원한다.

    fun create_vec_map_from_arrays(
    keys: vector<String>,
    values: vector<String>
    ): VecMap<String, String> {}

template 패키지

browser에서 seamless asset creation을 지원하도록 Rust WASM functionality를 활성화하는 example use case package이다.

이는 launchpad approach와 유사하며, 새 asset이 tokenized asset으로 표현되어야 할 때마다 template package 역할을 한다. 이 package는 template contract의 field를 즉석에서 edit하고 edit이 포함된 상태로 publish할 수 있게 한다. 이 package는 asset tokenization에 필요한 distinct functionality를 담당하는 두 essential module을 구현한다. Rust WASM이 구현된 방식에 대한 자세한 내용은 WebAssembly 및 template package section에서 확인할 수 있다.

package는 다음 module을 포함한다:

  • template: 이 module은 새 asset 정의를 지원한다. 새 asset을 fractional asset으로 표현해야 하는 경우 이 module을 <template>::<TEMPLATE>로 수정한다. 여기서 대문자 <template>은 이 새 asset의 One-Time Witness이다. 이 module은 asset_tokenization::tokenized_asset::new_asset(...) method를 호출하며, 이 method는 asset에 대한 새 field declaration을 지원한다:

    • witness: One-Time Witness NEW_ASSET
    • total_supply: 언제든 존재할 수 있는 total supply
    • symbol: asset의 symbol
    • name: asset의 name
    • description: asset의 description
    • icon_url: asset logo의 URL(optional)
    • burnable: admin이 asset을 burn할 수 있는지 정의하는 boolean
  • genesis: sender가 publisher를 claim할 수 있도록 One-Time Witness를 포함하는 genesis type module이다.