I am just starting out with Rust and NEAR and trying to create a simple function that counts how many NFTs have been minted with a particular substring.
My NFTs have a token_id which contains a randomstring-tier1
or randomstring-tier2
and rather than returning the total amount minted. i want o know for each tier.
I have this very basic function that returns the total count.
pub fn nft_total_supply(&self) -> U128 {
//return the length of the token metadata by ID
U128(self.token_metadata_by_id.len() as u128)
}
But not got a good enough understanding of how I check the token_id for a particular sub-string.
Was trying
pub fn check_nft_minted_by_tier1(
&self,
token_id
) -> u128 {
if token_id.contains("tier1").count() {
U128(tier1.len() as u128)
}
}
But this doesn't work.