pub fn _decimals(
decimals_key: StorageKey<StorageMap<AssetId, u8>>,
asset: AssetId,
) -> Option<u8>
Expand description
Returns the number of decimals the asset uses.
Additional Information
e.g. 8, means to divide the coins amount by 100000000 to get its user representation.
Arguments
decimals_key
: [StorageKey<StorageMap<AssetId, u8>>] - The location in storage which theStorageMap
that stores the decimals of assets is stored.asset
: [AssetId] - The asset of which to query the decimals.
Returns
- [Option] - The decimal precision used by
asset
.
Number of Storage Accesses
- Reads:
1
Examples
use sway_libs::asset::base::_decimals;
storage {
decimals: StorageMap<AssetId, u8> = StorageMap {},
}
fn foo(asset: AssedId) {
let decimals = _decimals(storage.decimals, asset);
assert(decimals.unwrap_or(0u8) == 8);
}