Asset Module
Overview
The satay::asset
module manages the creation and handling of fungible assets. It provides functions for creating assets, minting tokens and burning tokens.
Structs
AssetController
The AssetController
struct contains the references required to mint, burn, and transfer fungible assets. It is associated with the asset's metadata and controls the management of assets of the associated metadata.
Error Codes
ENOT_ASSET_OWNER:
u64 = 0
– Error indicating that the signer is not the owner of the asset.EASSET_CONTROLLER_NOT_FOUND:
u64 = 1
– Error indicating that theAssetController
could not be found.EASSET_META_NOT_FOUND:
u64 = 2
– Error indicating that the metadata for the asset was not found.
Public Functions
Asset Creation
create(owner: &signer, name: String, symbol: String, decimals: u8, icon_uri: String, project_uri: String): Object<Metadata>
: Creates a new fungible asset with the given name, symbol, decimals, and URIs. The asset'sAssetController
is also created to manage minting and burning.create_with_seed(owner: &signer, seed: vector<u8>, name: String, symbol: String, decimals: u8, icon_uri: String, project_uri: String): Object<Metadata>
: Creates a fungible asset using a seed for the address generation.
Minting and Burning
safe_mint(signer: &signer, metadata: Object<Metadata>, amount: u64): FungibleAsset
: Mints new tokens for the given asset metadata if the signer is the owner of the asset. Calls the internalmint
function.mint(metadata: Object<Metadata>, amount: u64): FungibleAsset
: Internally mints new tokens for the given asset metadata. Requires anAssetController
reference.safe_burn(signer: &signer, asset: FungibleAsset): u64
: Burns the given fungible asset if the signer is the owner of the asset. Calls the internalburn
function.burn(asset: FungibleAsset): u64
: Internally burns the specified fungible asset. Requires anAssetController
reference.
Helper Functions
create_internal(constructor_ref: &ConstructorRef, name: String, symbol: String, decimals: u8, icon_uri: String, project_uri: String): Object<Metadata>
: Internal function to handle the asset creation process, including setting up minting, burning, and transferring capabilities.
Access Control
Friend Functions: The
satay::base_strategy
, andsatay::vault
modules are friends ofsatay::asset
, giving them access to certain internal protocol functions.
Last updated