Skip to main content

getAddresses

Function Signature
You can also read the same dictionary through the addresses property:
Parameters This method takes no parameters. Returns
  • [PortalNamespace: String?]: The client’s addresses, keyed by namespace:
    • .eip155: The EVM address
    • .solana: The Solana address
    • .stellar: The Stellar address
    • .tron: The Tron address
    • .xrpl: The XRP Ledger classic address
Which entries are present depends on the client’s wallets:
  • .eip155, .tron, and .xrpl are present when the client has a SECP256K1 wallet.
  • .solana and .stellar are present when the client has an ED25519 wallet.
  • A namespace the client has no address for is left out of the dictionary, so it is not in keys and reads as nil by subscript.
  • .bip122 is never present. Read Bitcoin addresses with getAddress and a P2WPKH chain ID.
Throws
  • An error if the addresses can’t be read from the device’s keychain.
Example Usage

getAddress

Function Signature
Parameters
  • forChainId: A Portal chain ID, in CAIP-2 format except for the Bitcoin P2WPKH IDs, which add a -p2wpkh suffix. The namespace part selects the address:
Returns
  • String?: The address for that chain, or nil when:
    • the client has no address for that namespace,
    • the chain ID is a bip122: ID other than the two P2WPKH IDs above, or
    • the chain ID is malformed or its namespace isn’t supported.
Throws This method doesn’t throw. It returns nil instead, including when the stored addresses can’t be read. Use getAddresses when you need to see errors from reading the stored addresses, such as keychain failures. A malformed or unsupported chain ID only ever produces nil. Example Usage

PortalNamespace

If you switch exhaustively over PortalNamespace, add a case for .xrpl. Notes
  • Addresses come from the client’s wallet metadata in the Portal API, not from the signing shares on the device. An address tells you the client has a wallet, not that it can sign on this device. Use isWalletOnDevice to check that.
  • The XRP Ledger, Stellar, and Tron addresses are derived from the client’s existing wallets. No new wallet is created.
  • Signing with an XRP Ledger, Stellar, or Tron chain ID isn’t supported yet. portal.request(...) and portal.rawSign(...) called with one of these chain IDs throw an unsupported request method error. Raw sign selects the key by an eip155 (SECP256K1) or solana (ED25519) chain ID.
  • The deprecated portal.address property returns nil when the client has no EVM address.
  • .xrpl, xrpl: chain IDs, the Bitcoin P2WPKH chain IDs in getAddress, and the omission of namespaces without an address are available starting from SDK version 8.1.0.
Related Documentation