Documentation Index
Fetch the complete documentation index at: https://docs.portalhq.io/llms.txt
Use this file to discover all available pages before exploring further.
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
| Parameter | Type | Required | Description |
|---|
chainId | String | Yes | The chain ID in CAIP-2 format |
Returns
PortalAssetsResponse - An object containing:
| Property | Type | Description |
|---|
nativeBalance | List<PortalAsset?> | List of native token balances |
tokenBalances | List<PortalAsset?> | List of token balances |
PortalAsset
| 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 |
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
| Code | Description |
|---|
NOT_INITIALIZED | Portal was not initialized |
FETCH_FAILED | Failed to fetch assets |