abi SetAssetAttributes {
    /// Stores the name for a specific asset.
    ///
    /// # Arguments
    ///
    /// * `asset`: [AssetId] - The asset for the name to be stored.
    /// * `name`: [String] - The name which to be stored.
    ///
    /// # Example
    ///
    /// ```sway
    /// use standards::src20::SRC20;
    /// use sway_libs::asset::base::*;
    /// use std::string::String;
    ///
    /// fn foo(contract_id: ContractId, asset: AssetId, name: String) {
    ///     let contract_abi = abi(SetAssetAttributes, contract_id.bits());
    ///     contract_abi.set_name(asset, name);
    ///     assert(contract_abi.name(asset) == name);
    /// }
    /// ```
    #[storage(write)]
    fn set_name(asset: AssetId, name: String);
    /// Stores the symbol for a specific asset.
    ///
    /// # Arguments
    ///
    /// * `asset`: [AssetId] - The asset for the symbol to be stored.
    /// * `symbol`: [String] - The symbol which to be stored.
    ///
    /// # Example
    ///
    /// ```sway
    /// use standards::src20::SRC20;
    /// use sway_libs::asset::base::*;
    /// use std::string::String;
    ///
    /// fn foo(contract_id: ContractId, asset: AssetId, symbol: String) {
    ///     let contract_abi = abi(SetAssetAttributes, contract_id.bits());
    ///     contract_abi.set_symbol(asset, symbol);
    ///     assert(contract_abi.symbol(asset) == symbol);
    /// }
    /// ```
    #[storage(write)]
    fn set_symbol(asset: AssetId, symbol: String);
    /// Stores the decimals for a specific asset.
    ///
    /// # Arguments
    ///
    /// * `asset`: [AssetId] - The asset for the symbol to be stored.
    /// * `decimals`: [u8] - The decimals which to be stored.
    ///
    /// # Example
    ///
    /// ```sway
    /// use standards::src20::SRC20;
    /// use sway_libs::asset::base::*;
    ///
    /// fn foo(contract_id: ContractId, asset: AssetId, decimals: u8) {
    ///     let contract_abi = abi(SetAssetAttributes, contract_id.bits());
    ///     contract_abi.set_decimals(asset, decimals);
    ///     assert(contract_abi.decimals(asset).unwrap() == decimals);
    /// }
    /// ```
    #[storage(write)]
    fn set_decimals(asset: AssetId, decimals: u8);
}

Required Methods

Stores the name for a specific asset.

Arguments

  • asset: [AssetId] - The asset for the name to be stored.
  • name: [String] - The name which to be stored.

Example

use standards::src20::SRC20;
use sway_libs::asset::base::*;
use std::string::String;

fn foo(contract_id: ContractId, asset: AssetId, name: String) {
    let contract_abi = abi(SetAssetAttributes, contract_id.bits());
    contract_abi.set_name(asset, name);
    assert(contract_abi.name(asset) == name);
}

Stores the symbol for a specific asset.

Arguments

  • asset: [AssetId] - The asset for the symbol to be stored.
  • symbol: [String] - The symbol which to be stored.

Example

use standards::src20::SRC20;
use sway_libs::asset::base::*;
use std::string::String;

fn foo(contract_id: ContractId, asset: AssetId, symbol: String) {
    let contract_abi = abi(SetAssetAttributes, contract_id.bits());
    contract_abi.set_symbol(asset, symbol);
    assert(contract_abi.symbol(asset) == symbol);
}

Stores the decimals for a specific asset.

Arguments

  • asset: [AssetId] - The asset for the symbol to be stored.
  • decimals: [u8] - The decimals which to be stored.

Example

use standards::src20::SRC20;
use sway_libs::asset::base::*;

fn foo(contract_id: ContractId, asset: AssetId, decimals: u8) {
    let contract_abi = abi(SetAssetAttributes, contract_id.bits());
    contract_abi.set_decimals(asset, decimals);
    assert(contract_abi.decimals(asset).unwrap() == decimals);
}