Abi sway_libs::asset::metadata::SetAssetMetadata
abi SetAssetMetadata {
/// Stores metadata for a specific asset and key pair.
///
/// # Arguments
///
/// * `asset`: [AssetId] - The asset for the metadata to be stored.
/// * `metadata`: [Metadata] - The metadata which to be stored.
/// * `key`: [String] - The key for the metadata to be stored.
///
/// # Example
///
/// ```sway
/// use standards::src7::{SRC7, Metadata};
/// use sway_libs::asset::metadata::*;
/// use std::string::String;
///
/// fn foo(contract_id: ContractId, asset: AssetId, key: String, metadata: Metadata) {
/// let contract_abi = abi(SetAssetMetadata, contract_id.bits());
/// contract_abi.set_metadata(asset, metadata, key);
/// assert(contract_abi.metadata(asset, key).unwrap() == Metadata);
/// }
/// ```
#[storage(read, write)]
fn set_metadata(asset: AssetId, key: String, metadata: Metadata);
}
Required Methods
fn set_metadata(
asset: AssetId,
key: String,
metadata: Metadata,
)
fn set_metadata(
asset: AssetId,
key: String,
metadata: Metadata,
)
Stores metadata for a specific asset and key pair.
Arguments
asset
: [AssetId] - The asset for the metadata to be stored.metadata
: [Metadata] - The metadata which to be stored.key
: [String] - The key for the metadata to be stored.
Example
use standards::src7::{SRC7, Metadata};
use sway_libs::asset::metadata::*;
use std::string::String;
fn foo(contract_id: ContractId, asset: AssetId, key: String, metadata: Metadata) {
let contract_abi = abi(SetAssetMetadata, contract_id.bits());
contract_abi.set_metadata(asset, metadata, key);
assert(contract_abi.metadata(asset, key).unwrap() == Metadata);
}