Function Signature
Description
Retrieves both native token balance and ERC-20/token balances for the wallet on the specified chain.Parameters
Returns
PortalAssetsResponse - An object containing:
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Get asset balances for a chain.
Future<PortalAssetsResponse> getAssets(String chainId)
| Parameter | Type | Required | Description |
|---|---|---|---|
chainId | String | Yes | The chain ID in CAIP-2 format |
PortalAssetsResponse - An object containing:
| Property | Type | Description |
|---|---|---|
nativeBalance | List<PortalAsset?> | List of native token balances |
tokenBalances | List<PortalAsset?> | List of token balances |
| Property | Type | Description |
|---|---|---|
symbol | String | Token symbol (e.g., “ETH”, “USDC”) |
name | String | Token name |
balance | String | The formatted balance amount |
decimals | int | Token decimals |
tokenAddress | String? | Token contract address (null for native) |
rawBalance | String? | Raw balance in smallest unit |
metadata | PortalAssetMetadata? | Additional token metadata |
| Property | Type | Description |
|---|---|---|
logoUri | String? | Token logo URL |
tokenType | String? | Type of token |
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}');
}
}
| Code | Description |
|---|---|
NOT_INITIALIZED | Portal was not initialized |
FETCH_FAILED | Failed to fetch assets |
Was this page helpful?