Get user connected wallets
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:
Usage
The wallets
array includes an object for all wallets a user has connected to your site.
To access connected wallets with the React SDK, use the wallets
array from the useWallets
hook:
Usage
The wallets
array includes an object for all wallets a user has connected to your site.
To access connected wallets with the React SDK, use the wallets
array from the useSolanaWallets
hook:
Usage
The wallets
array includes an object for all wallets a user has connected to your site. The array is ordered from most recently connected to least recently connected.
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
anduseSolanaWallets
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.
To access connected wallets with the React SDK, use the wallets
array from the useWallets
hook:
Usage
The wallets
array includes an object for all wallets a user has connected to your site.
To access connected wallets with the React SDK, use the wallets
array from the useWallets
hook:
Usage
The wallets
array includes an object for all wallets a user has connected to your site.
To access connected wallets with the React SDK, use the wallets
array from the useSolanaWallets
hook:
Usage
The wallets
array includes an object for all wallets a user has connected to your site. The array is ordered from most recently connected to least recently connected.
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
anduseSolanaWallets
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.
To access connected wallets with the React Native SDK, use the wallets
array from the useEmbeddedEthereumWallet
hook:
Usage
To access connected Ethereum wallets using the Swift SDK, use the embeddedEthereumWallets
property from the PrivyUser
object:
Usage
To access connected Ethereum wallets using the Android SDK, use the embeddedEthereumWallets
property from the PrivyUser
object:
Usage
The embeddedEthereumWallets
property includes an array of objects for all Ethereum wallets a user has connected to your app. The array is ordered from most recently connected to least recently connected.
To access connected Ethereum wallets using the Android SDK, use the embeddedEthereumWallets
property from the PrivyUser
object:
Usage
The embeddedEthereumWallets
property includes an array of objects for all Ethereum wallets a user has connected to your app. The array is ordered from most recently connected to least recently connected.
To access connected Solana wallets using the Android SDK, use the embeddedSolanaWallets
property from the PrivyUser
object:
Usage
The embeddedSolanaWallets
property includes an array of objects for all Solana wallets a user has connected to your app. The array is ordered from most recently connected to least recently connected.
To retrieve a user’s Ethereum wallet using the Flutter SDK, follow these steps:
Usage
The embeddedEthereumWallets
property includes an array of objects for all Ethereum wallets a user has connected to your app. The array is ordered from most recently connected to least recently connected.
To retrieve a user’s Ethereum wallet using the Flutter SDK, follow these steps:
Usage
The embeddedEthereumWallets
property includes an array of objects for all Ethereum wallets a user has connected to your app. The array is ordered from most recently connected to least recently connected.
To retrieve a user’s Solana wallet using the Flutter SDK, follow these steps:
Usage
The embeddedSolanaWallets
property includes an array of objects for all Solana wallets a user has connected to your app. The array is ordered from most recently connected to least recently connected.