A user may come in with both embedded and external wallets. Privy makes it easy to find all of a user’s connected wallets so you can help them take an onchain action with the appropriate wallet.

It’s worth distinguishing connected vs linked wallets for Privy:

  • Linked wallets are embedded or external wallets tied to a user object. They may or may not be connected.
  • Connected wallets are embedded or external wallets currently available for the web client. They may or may not be linked to a user’s account.

Not seeing all of the external wallets connected to the application? Make sure you have completed the steps to connect any wallets to your application.

Both external wallets (that users connect to your site) and embedded wallets (that users create within your app) result in a unified object representing the wallet.

To access connected wallets with the React SDK, use the wallets array from the useWallets hook:

const wallets: ConnectedWallet[]

Usage

import {useWallets} from '@privy-io/react-auth';
const { wallets } = useWallets();
const desiredWallet = wallets.find((wallet) => wallet.address === desiredAddress);

The wallets array includes an object for all wallets a user has connected to your site.

Waiting for wallets to be ready

When your page loads in the user’s browser, the Privy SDK determines what wallets the user has connected to your app in two ways:

  • For external wallets, Privy determines what wallets are connected via EIP-6963 for injected wallets (e.g. browser extension wallets) and via WalletConnect for mobile wallets.
  • For embedded wallets, Privy determines if the user has an embedded wallet by loading the Privy iframe which stores the private key material used for the wallet.

To determine if Privy has fully processed all external and embedded EVM wallet connections, use the ready boolean returned by the useWallets hook, or the ready boolean returned by the useSolanaWallets hook for Solana wallets.

Concretely, ready will be false while Privy is determining what wallets are available for the user, and will be true once Privy has settled on the current set of connected wallets.


useWallets and useSolanaWallets vs. usePrivy

The useWallets, useSolanaWallets, and usePrivy hooks all return information about a user’s wallets. The key difference between the them is:

  • useWallets and useSolanaWallets will return all connected wallets (EVM and Solana, respectively), which you can use to request signatures or take onchain actions (via transactions).
  • usePrivy will return all linked wallets, which you can use to verify that a user owns a given wallet address.

Linked wallets are not necessarily actively connected to your site, so you may not always be able to request a signature or transaction from them. Similarly, connected wallets are not necessarily linked, as a user may have connected their wallet without signing a message to verify that they own the wallet address.

Concretely, if your use case only requires you to verify that a user owns a given wallet address, you should use the wallets information returned by the usePrivy hook.

Otherwise, if your use case requires you to take actions on a connected wallet, such as getting its network or requesting a signature or transaction, you should use the wallets information returned by the useWallets and useSolanaWallets hook instead.