Skip to main content

Asset Tokenization Reference

The tokenized_asset module operates in a manner similar to the coin library.

When it receives a new One-Time Witness type, it creates a unique representation of a fractional asset. This module uses implementations similar to some methods found in the Coin module. It encompasses functionalities pertinent to asset tokenization, including new asset creation, minting, splitting, joining, and burning. See One-Time Witness in The Move Book for more information.

Structs

  • AssetCap

    Generates an AssetCap for each new asset represented as a fractional NFT. In most scenarios, create it as an owned object, which you can then transfer to the platform administrator for access-restricted method invocation.

    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

    The AssetMetadata struct defines the metadata representing the entire asset to fractionalize. This should be a 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

    The TokenizedAsset is minted with a specified balance that is less than or equal to the remaining supply. If the VecMap of an asset is populated with values (indicating multiple unique entries), it is considered an NFT. If the VecMap of an asset is not populated (indicating an absence of individual entries), it is considered an 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

    The PlatformCap is the capability issued to the address that deploys the contract. This capability grants specific permissions related to the platform functionalities, allowing the deployer certain controlled actions or access rights within the deployed contract.

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

Functions

  • init

    Creates a PlatformCap and transfers it to the transaction sender.

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

    Creates a fresh representation of an asset with its crucial attributes. Returns 2 distinct objects: the AssetCap and AssetMetadata. These objects encapsulate the necessary information and characteristics that define the asset within the system.

    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

    Mints a tokenized asset. If new metadata is introduced during this process, the tokenized asset becomes unique, resulting in the creation of an NFT with a balance set to 1. If no new metadata is added, the system classifies the tokenized asset as an FT, permitting its balance to exceed 1 as specified by a provided argument. Returns the 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

    Receives a tokenized asset of the FT type with a balance greater than 1 and a value less than the object balance, then performs a split operation. The operation divides the existing tokenized asset into 2 separate tokenized assets. The newly created tokenized asset has a balance equal to the given value, while the balance of the provided object decreases by the specified value. Returns the newly created tokenized asset. This function does not accept tokenized assets of the NFT type.

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

    Receives 2 tokenized assets of the FT type and merges them. The operation increases the balance of the first tokenized asset by the balance of the second one. The system then burns the second tokenized asset. Returns the ID of the burned tokenized asset. This function does not accept tokenized assets of the NFT type.

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

    Requires the AssetCap as a parameter, restricting invocation to the platform admin. Accepts a tokenized asset and burns it. The circulating supply decreases by the balance of the burned item. Requires a tokenized asset that is burnable.

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

    Returns the maximum supply of the asset.

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

    Returns the current circulating supply of the asset.

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

    Returns the balance of a tokenized asset.

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

    An internal helper function that populates a VecMap<String, String>. It assists in the process of filling key-value pairs within the VecMap data structure.

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

template package

An example use case package that enables Rust WASM functionality to support seamless asset creation in the browser.

This is similar to the launchpad approach and serves as the template package whenever a new asset requires representation as a tokenized asset. It effectively allows you to edit fields of this template contract on the fly and publish it with the edits included. This package implements two essential modules, each catering to distinct functionalities required for asset tokenization. More details on how Rust WASM was implemented can be found in the WebAssembly and template package section.

The package contains the following modules:

  • template: This module supports defining a new asset. When you need to represent a new asset as a fractional asset, modify this module to <template>::<TEMPLATE>, with the <template> (in capitals) being the One-Time Witness of this new asset. This module calls the asset_tokenization::tokenized_asset::new_asset(...) method, which facilitates the declaration of new fields for the asset:

    • witness: The One-Time Witness NEW_ASSET
    • total_supply: The total supply allowed to exist at any time
    • symbol: The symbol for the asset
    • name: The name of the asset
    • description: The description of the asset
    • icon_url: The URL for the asset logo (optional)
    • burnable: Boolean that defines if the asset can be burned by an admin
  • genesis: A genesis type of module that includes a One-Time Witness so that the sender can claim the publisher.