Skip to main content

Function Signature

Future<List<PortalNftAsset>> getNftAssets(String chainId)

Description

Retrieves all NFTs owned by the wallet on the specified chain.

Parameters

ParameterTypeRequiredDescription
chainIdStringYesThe chain ID in CAIP-2 format

Returns

List<PortalNftAsset> - A list of NFT assets.

PortalNftAsset

PropertyTypeDescription
tokenIdString?The NFT token ID
contractAddressString?The NFT contract address
nameString?NFT name
descriptionString?NFT description
imageUrlString?NFT image URL
tokenTypeString?Token type (e.g., “ERC721”, “ERC1155”)
metadataPortalNftMetadata?Additional NFT metadata

PortalNftMetadata

PropertyTypeDescription
nameString?NFT name from metadata
descriptionString?NFT description from metadata
imageString?NFT image URL from metadata

Example

import 'package:portal_flutter/portal_flutter.dart';

final portal = Portal();

final nfts = await portal.getNftAssets('eip155:1');

for (final nft in nfts) {
  print('NFT: ${nft.name ?? nft.metadata?.name}');
  print('Token ID: ${nft.tokenId}');
  print('Contract: ${nft.contractAddress}');
  print('Image: ${nft.imageUrl ?? nft.metadata?.image}');
  print('Type: ${nft.tokenType}');
}

Errors

CodeDescription
NOT_INITIALIZEDPortal was not initialized
FETCH_FAILEDFailed to fetch NFT assets