> ## 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.

# getClient

> Get client information.

## Function Signature

```dart theme={null}
Future<PortalClientInfo> getClient()
```

## Description

Retrieves client information from the Portal backend, including the client ID, list of wallets, and environment configuration.

## Parameters

This method takes no parameters.

## Returns

**`PortalClientInfo`** - An object containing:

| Property | Type | Description |
| - | - | - |
| `id` | `String` | The client ID |
| `custodian` | `PortalClientCustodian` | The custodian that manages the client |
| `createdAt` | `String` | ISO timestamp of when the client was created |
| `environment` | `PortalClientEnvironment?` | The client's environment configuration (null if unavailable) |
| `ejectedAt` | `String?` | ISO timestamp of when keys were ejected (null if not ejected) |
| `isAccountAbstracted` | `bool` | Whether the client uses account abstraction |
| `metadata` | `PortalClientMetadata` | Per-namespace address metadata |
| `wallets` | `List<PortalWallet?>` | List of wallets |

### PortalClientCustodian

| Property | Type | Description |
| - | - | - |
| `id` | `String` | Custodian ID |
| `name` | `String` | Custodian name |

### PortalClientMetadata

| Property | Type | Description |
| - | - | - |
| `namespaces` | `PortalClientMetadataNamespaces` | Address metadata grouped by namespace |

### PortalClientMetadataNamespaces

Each property is a `PortalNamespaceMetadataItem?`, and is `null` when the client has no wallet
for that namespace.

| Property | Type | Description |
| - | - | - |
| `eip155` | `PortalNamespaceMetadataItem?` | EVM namespace metadata |
| `solana` | `PortalNamespaceMetadataItem?` | Solana namespace metadata |
| `bip122` | `PortalNamespaceMetadataItem?` | Bitcoin namespace metadata |
| `stellar` | `PortalNamespaceMetadataItem?` | Stellar namespace metadata |
| `tron` | `PortalNamespaceMetadataItem?` | Tron namespace metadata |

### PortalNamespaceMetadataItem

| Property | Type | Description |
| - | - | - |
| `address` | `String` | The address for the namespace. Empty string for `bip122`; use `bitcoin.p2wpkh` instead |
| `curve` | `String` | The cryptographic curve used |
| `bitcoin` | `PortalBitcoinAddressInfo?` | Bitcoin P2WPKH addresses (only present for the `bip122` namespace) |

#### PortalBitcoinAddressInfo

| Property | Type | Description |
| - | - | - |
| `p2wpkh` | `PortalP2wpkhAddressInfo` | P2WPKH mainnet/testnet addresses |

#### PortalP2wpkhAddressInfo

| Property | Type | Description |
| - | - | - |
| `mainnet` | `String` | Mainnet P2WPKH address |
| `testnet` | `String` | Testnet P2WPKH address |

<Note>
  `getClient()` is the only way to reach a Bitcoin address from Dart. `getAddress('bip122:...')`
  returns `null`, and [`getAddresses()`](./getaddresses) carries only `ethereum` and `solana`.
</Note>

### PortalWallet

| Property | Type | Description |
| - | - | - |
| `id` | `String` | Wallet ID |
| `createdAt` | `String` | ISO timestamp of when the wallet was created |
| `curve` | `String` | The cryptographic curve used (e.g., "secp256k1", "ed25519") |
| `ejectableUntil` | `String?` | ISO timestamp until which private keys can be ejected (null if not ejectable) |
| `publicKey` | `String` | The wallet's public key |
| `backupSharePairs` | `List<PortalBackupSharePair?>` | The wallet's backup share pairs |
| `signingSharePairs` | `List<PortalSigningSharePair?>` | The wallet's signing share pairs |

#### PortalBackupSharePair

| Property | Type | Description |
| - | - | - |
| `id` | `String` | Share pair ID |
| `backupMethod` | `String` | The backup method (native enum string value). On Android, methods absent from the native `BackupMethods` enum — `ICLOUD` and `CUSTOM` — read as `UNKNOWN`; iOS reports the real method. |
| `createdAt` | `String` | ISO timestamp of when the share pair was created |
| `status` | `String` | Share status (e.g., "completed", "incomplete") |

#### PortalSigningSharePair

| Property | Type | Description |
| - | - | - |
| `id` | `String` | Share pair ID |
| `createdAt` | `String` | ISO timestamp of when the share pair was created |
| `status` | `String` | Share status (e.g., "completed", "incomplete") |

### PortalClientEnvironment

| Property | Type | Description |
| - | - | - |
| `id` | `String` | The environment ID |
| `name` | `String` | Environment name (e.g., "production", "sandbox") |
| `backupWithPortalEnabled` | `bool?` | `true` when the client is configured for Portal-Managed Backups; `false` (or `null`) for Self-Managed Backups |

## Example

```dart theme={null}
import 'package:portal_flutter/portal_flutter.dart';

final portal = Portal();

final clientInfo = await portal.getClient();

print('Client ID: ${clientInfo.id}');
print('Custodian: ${clientInfo.custodian.name}');
print('Account abstracted: ${clientInfo.isAccountAbstracted}');

final eip155 = clientInfo.metadata.namespaces.eip155;
if (eip155 != null) {
  print('EVM address: ${eip155.address}');
}

for (final wallet in clientInfo.wallets) {
  if (wallet != null) {
    print('Wallet ID: ${wallet.id}');
    print('Curve: ${wallet.curve}');
    print('Public key: ${wallet.publicKey}');
    if (wallet.ejectableUntil != null) {
      print('Ejectable until: ${wallet.ejectableUntil}');
    }
    print('Backup share pairs: ${wallet.backupSharePairs.length}');
    print('Signing share pairs: ${wallet.signingSharePairs.length}');
  }
}
```

## Use Cases

### Check Eject Availability

```dart theme={null}
final clientInfo = await portal.getClient();

for (final wallet in clientInfo.wallets) {
  if (wallet != null && wallet.ejectableUntil != null) {
    final ejectableUntil = DateTime.parse(wallet.ejectableUntil!);
    if (DateTime.now().isBefore(ejectableUntil)) {
      print('Wallet ${wallet.id} can be ejected until ${wallet.ejectableUntil}');
    }
  }
}
```

### Read the Bitcoin Address

```dart theme={null}
final clientInfo = await portal.getClient();

final bitcoin = clientInfo.metadata.namespaces.bip122?.bitcoin;
if (bitcoin != null) {
  print('Bitcoin testnet address: ${bitcoin.p2wpkh.testnet}');
  print('Bitcoin mainnet address: ${bitcoin.p2wpkh.mainnet}');
}
```

### Detect Portal-Managed vs Self-Managed Backups

```dart theme={null}
final clientInfo = await portal.getClient();
final portalManaged = clientInfo.environment?.backupWithPortalEnabled ?? false;
```

## Errors

| Code | Description |
| - | - |
| `NOT_INITIALIZED` | Portal was not initialized |
| `FETCH_FAILED` | Failed to fetch client information |

## Related

* [backupWallet](./backupwallet)
* [ejectPrivateKeys](./ejectprivatekeys)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.