Skip to main content

Function Signature

Future<PortalAssetsResponse> getAssets(String chainId)

Description

Retrieves both native token balance and ERC-20/token balances for the wallet on the specified chain.

Parameters

ParameterTypeRequiredDescription
chainIdStringYesThe chain ID in CAIP-2 format

Returns

PortalAssetsResponse - An object containing:
PropertyTypeDescription
nativeBalanceList<PortalAsset?>List of native token balances
tokenBalancesList<PortalAsset?>List of token balances

PortalAsset

PropertyTypeDescription
symbolStringToken symbol (e.g., “ETH”, “USDC”)
nameStringToken name
balanceStringThe formatted balance amount
decimalsintToken decimals
tokenAddressString?Token contract address (null for native)
rawBalanceString?Raw balance in smallest unit
metadataPortalAssetMetadata?Additional token metadata

PortalAssetMetadata

PropertyTypeDescription
logoUriString?Token logo URL
tokenTypeString?Type of token

Example

import 'package:portal_flutter/portal_flutter.dart';

final portal = Portal();

final assets = await portal.getAssets('eip155:1');

// Native balance
for (final native in assets.nativeBalance) {
  if (native != null) {
    print('${native.symbol} balance: ${native.balance}');
  }
}

// Token balances
for (final token in assets.tokenBalances) {
  if (token != null) {
    print('${token.symbol}: ${token.balance}');
  }
}

Errors

CodeDescription
NOT_INITIALIZEDPortal was not initialized
FETCH_FAILEDFailed to fetch assets