I’m working on creating my own NFT contract using AssemblyScript, following the NEP-171 guidelines. I minted an NFT token through my nft_mint method, and the transaction is confirmed on the testnet. Yet, I can’t see the NFT in my wallet’s collectibles section.
Here’s my contract code:
import { PersistentMap } from 'near-sdk-as';
import { Token, TokenMetadata } from './reit-token';
@nearBindgen
class NFTContractMetadata {
spec: string; // version like "nft-1.0.0"
name: string; // e.g., "Reit Token"
symbol: string; // e.g., "REIT"
icon: string | null;
base_uri: string | null;
reference: string | null;
reference_hash: string | null;
}
@nearBindgen
export class Contract {
metadata: NFTContractMetadata = {
spec: 'reit-token-0.0.0',
name: 'Reit Token',
symbol: 'REIT',
icon: null,
base_uri: null,
reference: null,
reference_hash: null,
};
owner_id: string;
tokens_per_owner: PersistentMap<string, Array<string>> = new PersistentMap('tokens_per_owner');
tokens_by_id: PersistentMap<string, Token> = new PersistentMap('tokens_by_id');
token_metadata_by_id: PersistentMap<string, TokenMetadata> = new PersistentMap('token_metadata_by_id');
nft_tokens_for_owner(account_id: string): Array<Token> {
const tokenIds: string[] = this.tokens_per_owner.getSome(account_id);
const tokens: Array<Token> = new Array<Token>();
for (let i = 0; i < tokenIds.length; ++i) {
const token: Token = this.tokens_by_id.getSome(tokenIds[i]);
tokens.push(token);
}
return tokens;
}
nft_mint(token_id: string, metadata: TokenMetadata, receiver_id: string): void {
const token = new Token(token_id, metadata, receiver_id);
const tokens: Array<string> = new Array<string>();
tokens.push(token_id);
this.tokens_per_owner.set(receiver_id, tokens);
this.tokens_by_id.set(token_id, token);
this.token_metadata_by_id.set(token_id, token.metadata);
}
}
I have integrated the necessary method nft_tokens_for_owner, but it seems the wallet isn’t recognizing my NFTs. Is there something missing in the functions or metadata that the wallet needs to display NFTs correctly?