Why doesn't my NFT show up in NEAR wallet collectibles using AssemblyScript?

I’m building my own NFT smart contract using AssemblyScript and following the NEP-171 standard. I created an NFT using my custom mint function, but it doesn’t appear in the collectibles section of my NEAR testnet wallet.

My implementation:

import { PersistentMap, context } from 'near-sdk-as';

@nearBindgen
class ContractMetadata {
  version: string;
  title: string;
  symbol: string;
  icon: string | null;
  base_url: string | null;
  ref: string | null;
  ref_hash: string | null;
}

@nearBindgen
export class AssetMetadata {
  name: string;
  desc: string;
  image: string;
  image_hash: string;
  quantity: number;
  created_at: number;
  expires_at: number;
  valid_from: number;
  modified_at: number;
  additional: string;
  external_ref: string;
  external_hash: string;
}

@nearBindgen
export class Asset {
  token_id: string;
  holder_id: string;
  meta: AssetMetadata;
  
  constructor(id: string, metadata: AssetMetadata, holder: string) {
    this.token_id = id;
    this.meta = metadata;
    this.holder_id = holder;
  }
}

@nearBindgen
export class NFTContract {
  contract_meta: ContractMetadata = {
    version: 'asset-v1.0.0',
    title: 'Digital Assets',
    symbol: 'DIGI',
    icon: null,
    base_url: null,
    ref: null,
    ref_hash: null,
  };

  owner: string;
  
  user_assets: PersistentMap<string, Array<string>> = new PersistentMap<string, Array<string>>('user_tokens');
  asset_registry: PersistentMap<string, Asset> = new PersistentMap<string, Asset>('asset_data');
  metadata_registry: PersistentMap<string, AssetMetadata> = new PersistentMap<string, AssetMetadata>('meta_data');

  nft_tokens_for_owner(user_id: string): Array<Asset> {
    const assetIds: string[] = this.user_assets.getSome(user_id);
    const userAssets: Array<Asset> = new Array<Asset>();
    
    for (let j = 0; j < assetIds.length; ++j) {
      const asset: Asset = this.asset_registry.getSome(assetIds[j]);
      userAssets.push(asset);
    }
    return userAssets;
  }

  create_nft(asset_id: string, meta: AssetMetadata, recipient: string): void {
    const newAsset = new Asset(asset_id, meta, recipient);
    const userTokens: Array<string> = new Array<string>();
    userTokens.push(asset_id);
    
    this.user_assets.set(recipient, userTokens);
    this.asset_registry.set(asset_id, newAsset);
    this.metadata_registry.set(asset_id, newAsset.meta);
  }
}

I successfully minted a token and the transaction went through, but the NFT doesn’t show up in my wallet’s collectibles tab. Am I missing some required methods or is there something wrong with my contract structure? Do I need to implement additional NEP-171 functions for wallet visibility?

you’re missing the nft_metadata and nft_token methods - wallets need these to read your NFTs. also double-check your function names. it should be nft_tokens_for_owner, not user_assets. most wallets won’t display custom implementations unless you’re fully NEP-171 compliant.

Hmm interesting issue! I’m curious about a few things here - have you called the specific view methods from NEAR CLI to test if they’re returning data? Like when you run near view your-contract.testnet nft_tokens_for_owner '{"account_id": "your-account.testnet"}' does it actually return your minted token?

Also, I noticed you’re using custom field names in your AssetMetadata class like desc instead of description - wallets might expect the exact field names from the standard. What about the nft_total_supply() method? Some wallets check this first to see if there are tokens to display.

One more thing - when you minted the token, did you emit the proper events? Wallets listen for nft mint events to know when to refresh their displays. Just wondering if you implemented the event logging part or if that’s why the wallet isn’t picking it up even though the mint transaction succeeded?

NEAR wallets need specific method signatures to detect and show NFTs properly. Your contract’s missing key NEP-171 methods that wallets look for. You need nft_token(token_id: string) to return token info for a specific ID, and nft_metadata() for contract metadata. Your nft_tokens_for_owner method signature looks right, but make sure it handles pagination with from_index and limit parameters - most wallets expect this. I ran into the same thing with my AssemblyScript NFT contract. Minting worked fine, but the wallet couldn’t list tokens without these exact view methods from the standard.