Skip to main content

getAddresses

Function Signature

Future<PortalGetAddressesResult> getAddresses()

Description

Get wallet addresses if a wallet exists on device. This method is useful for checking if a wallet exists and retrieving addresses without creating or recovering a wallet.

Parameters

This method takes no parameters.

Returns

PortalGetAddressesResult - An object containing:
PropertyTypeDescription
hasWalletboolWhether a wallet exists
addressesPortalAddressesThe wallet addresses

PortalAddresses

PropertyTypeDescription
ethereumString?The EVM wallet address
solanaString?The Solana wallet address

Example

import 'package:portal_flutter/portal_flutter.dart';

final portal = Portal();

final result = await portal.getAddresses();

if (result.hasWallet) {
  print('EVM address: ${result.addresses.ethereum}');
  print('Solana address: ${result.addresses.solana}');
} else {
  print('No wallet found');
}

getAddress

Function Signature

Future<String?> getAddress(String chainId)

Description

Get the wallet address for a specific chain.

Parameters

ParameterTypeRequiredDescription
chainIdStringYesThe chain ID in CAIP-2 format

Returns

String? - The wallet address for the specified chain, or null if no wallet exists.

Example

import 'package:portal_flutter/portal_flutter.dart';

final portal = Portal();

// Get Ethereum mainnet address
final ethAddress = await portal.getAddress('eip155:1');

// Get Solana mainnet address
final solAddress = await portal.getAddress('solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp');

print('ETH address: $ethAddress');
print('SOL address: $solAddress');

Errors

CodeDescription
NOT_INITIALIZEDPortal was not initialized