Asset Module
Overview
The satay::asset
module manages the creation and handling of fungible assets. It provides functions for creating assets, minting and burning tokens, and managing asset stores.
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.
AssetStoreController
The AssetStoreController
struct holds the ExtendRef
, which is used to extend the fungible asset store for an owner. It provides the capability to manage the asset store.
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 acquires AssetController
: 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 acquires AssetController
: Internally mints new tokens for the given asset metadata. Requires anAssetController
reference.safe_burn(signer: &signer, asset: FungibleAsset): u64 acquires AssetController
: Burns the given fungible asset if the signer is the owner of the asset. Calls the internalburn
function.burn(asset: FungibleAsset): u64 acquires AssetController
: Internally burns the specified fungible asset. Requires anAssetController
reference.
Asset Store Management
get_or_create_asset_store(owner: &signer, metadata: Object<Metadata>, seed: vector<u8>): Object<FungibleStore>
: Retrieves or creates an asset store for the specified owner and asset metadata. Uses the seed to generate the store address.asset_store(owner: address, seed: vector<u8>): Object<FungibleStore>
: Retrieves the asset store for the specified owner and seed.create_store(owner: &signer, metadata: Object<Metadata>, seed: vector<u8>): Object<FungibleStore>
: Creates a new asset store for the given metadata and seed.
Helper Functions
controller(metadata: &Object<Metadata>): Object<AssetController>
: Retrieves theAssetController
for the given asset metadata.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.
Last updated