How can I make my NFT visible in the NEAR wallet (AssemblyScript)?

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?

Your contract’s missing key NEP-171 methods that wallets need. You don’t have nft_metadata - wallets call this to verify your contract follows the standard. You’re also missing nft_token to fetch tokens by ID, which most wallets use before showing NFTs. Found another problem in your nft_mint function - you’re creating a new array each time instead of adding to existing tokens. This overwrites previous tokens for that owner. Also, make sure your Token class has the approved_account_ids field (even if empty) since some wallets expect it per NEP-171 specs.

u might wanna add the nft_token method for wallets to fetch indiv tokens. also, try changing your spec to “nft-1.0.0” instead of “reit-token-0.0.0” – otherwise, wallets might not pick it up.