자산 토큰화 reference
- tokenized_asset
- proxy
- unlock
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
-
AssetCapfractional 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
} -
AssetMetadataAssetMetadatastruct는 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>
} -
TokenizedAssetTokenizedAsset은 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>,
} -
PlatformCapPlatformCap은 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 }
함수
-
initPlatformCap을 만들고 transaction sender에게 transfer한다.fun init(ctx: &mut TxContext) {} -
new_asset중요한 attribute를 포함하는 새 asset representation을 만든다.
AssetCap과AssetMetadata라는 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>) {} -
minttokenized 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> {} -
splitbalance가 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> {} -
joinFT 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 {} -
burnAssetCap을 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_supplyasset의 maximum supply를 반환한다.
public fun total_supply<T>(cap: &AssetCap<T>): u64 {} -
supplyasset의 current circulating supply를 반환한다.
public fun supply<T>(cap: &AssetCap<T>): u64 {} -
valuetokenized asset의 balance를 반환한다.
public fun value<T>(tokenized_asset: &TokenizedAsset<T>): u64 {} -
create_vec_map_from_arraysVecMap<String, String>을 채우는 internal helper function이다.VecMapdata structure 안에 key-value pair를 채우는 process를 지원한다.fun create_vec_map_from_arrays(
keys: vector<String>,
values: vector<String>
): VecMap<String, String> {}
proxy module은 type owner가 publisher-related operation을 실행하는 데 사용하는 method를 포함한다.
struct
-
ProxyPROXYstruct는 publisher를 claim하기 위한 One-Time Witness를 나타낸다.struct PROXY has drop {} -
RegistryPublisherobject의 repository 역할을 하는 shared object이다. 특히 tokenized asset의 transfer policy 생성 및 관리를 위한 access를 control하고 restrict하기 위한 것이다. 이 object에 대한 mutable access는 actual publisher에게만 부여된다.struct Registry has key {
id: UID,
publisher: Publisher
} -
ProtectedTP빈 transfer policy를 저장하는 shared object이다. 사용자가 생성한 type
<T>마다 하나씩 만들어야 한다. unlock module은 이 object를 사용한다.struct ProtectedTP<phantom T> has key, store {
id: UID,
policy_cap: TransferPolicyCap<T>,
transfer_policy: TransferPolicy<T>
}
함수
-
initPublisherobject를 만들고 registry 안에 encapsulate한 뒤Registryobject를 share한다.fun init(otw: PROXY, ctx: &mut TxContext) {} -
setup_tpregistry 안에 nested된 publisher와 sender publisher를 사용한다.
TokenizedAsset<T>에 특정된 transfer policy와 관련 transfer policy cap을 생성해 반환한다. typeT는Publisherobject에서 derive된다.또한
ProtectedTP<T>object로 감싼 빈 transfer policy를 생성하며, 이는 shared된다. 특정 condition에서 이 functionality를 사용해 Kiosk lock rule을 override할 수 있다.public fun setup_tp<T: drop>(
registry: &Registry,
publisher: &Publisher,
ctx: &mut TxContext
): (TransferPolicy<TokenizedAsset<T>>,
TransferPolicyCap<TokenizedAsset<T>>) {} -
new_displayregistry 안에 nested된 publisher와 sender publisher를 사용해
TokenizedAsset<T>type에 대한 빈Display를 생성하고 반환한다. 여기서T는Publisherobject 안에 encapsulate되어 있다.public fun new_display<T: drop>(
registry: &Registry,
publisher: &Publisher,
ctx: &mut TxContext
): Display<TokenizedAsset<T>> {} -
transfer_policy
ProtectedTP가 주어지면 TokenizedAsset<T> type에 대한 transfer policy를 반환한다.
public(friend) fun transfer_policy<T>(
protected_tp: &ProtectedTP<T>
): &TransferPolicy<T> {}
publisher_mut
platform cap의 owner만 접근할 수 있다. publisher에 대한 mutable reference를 얻기 위해 registry를 argument로 요구한다.
public fun publisher_mut(
_: &PlatformCap,
registry: &mut Registry
): &mut Publisher {}
unlock module은 authorized burning 및 joining을 위해 tokenized asset을 unlock하는 과정을 지원한다.
tokenized asset type creator가 rule 또는 policy 같은 default requirement set을 따르지 않고도 kiosk asset에 대해 이러한 operation을 활성화할 수 있게 한다.
struct
-
JoinPromisejoining의 intended scope를 넘어 object를 permanent unlock하려는 시도를 방지하기 위해 설정되는 promise object이다.
struct JoinPromise {
/// the item where the balance of the burnt tokenized asset will be added.
item: ID,
/// burned is the id of the tokenized asset that will be burned
burned: ID,
/// the expected final balance of the item after merging
expected_balance: u64
} -
BurnPromise지정된 object의 permanent burning을 보장하기 위해 생성되는 promise object이다.
struct BurnPromise {
expected_supply: u64
}
함수
-
asset_from_kiosk_to_joinkiosk에 locked된 tokenized asset의 joining을 지원하는 helper function이다. burning을 위해 tokenized asset set을 unlock하고,
JoinPromise를 반환하여 같은 type의 다른 tokenized asset이 결국 해당 balance를 포함하도록 보장한다.public fun asset_from_kiosk_to_join<T>(
self: &TokenizedAsset<T>, // A
to_burn: &TokenizedAsset<T>, // B
protected_tp: &ProtectedTP<TokenizedAsset<T>>, // unlocker
transfer_request: TransferRequest<TokenizedAsset<T>> // transfer request for b
): JoinPromise {} -
prove_joinunlocked tokenized asset이 성공적으로 burn되고 해당 balance가 existing tokenized asset에 포함되었음을 증명한다.
public fun prove_join<T>(
self: &TokenizedAsset<T>,
promise: JoinPromise,
proof: ID) {
} -
asset_from_kiosk_to_burnkiosk에 locked된 tokenized asset의 burning을 지원하는 helper function이다.
BurnPromise를 반환하여 circulating supply가 감소한다는 promise를 보장하면서 unlock을 지원한다.public fun asset_from_kiosk_to_burn<T>(
to_burn: &TokenizedAsset<T>,
asset_cap: &AssetCap<T>,
protected_tp: &ProtectedTP<TokenizedAsset<T>>,
transfer_request: TransferRequest<TokenizedAsset<T>>,
): BurnPromise {
} -
prove_burnasset cap의 circulating supply가 burned tokenized asset의 balance만큼 감소했음을 보장한다.
public fun prove_burn<T>(
asset_cap: &AssetCap<T>,
promise: BurnPromise) {
}
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 WitnessNEW_ASSETtotal_supply: 언제든 존재할 수 있는 total supplysymbol: asset의 symbolname: asset의 namedescription: asset의 descriptionicon_url: asset logo의 URL(optional)burnable: admin이 asset을 burn할 수 있는지 정의하는 boolean
-
genesis: sender가 publisher를 claim할 수 있도록 One-Time Witness를 포함하는 genesis type module이다.