Skip to content

Getting a user's delegated wallets

To get a list of embedded wallets for whom the user has granted your app delegated actions, first find all of the user's embedded wallets from the user's linked accounts. Simply filter the user.linkedAccounts array for wallet entries with walletClientType: 'privy':

tsx
import {usePrivy, type WalletWithMetadata} from '@privy-io/react-auth';
...
const {user} = usePrivy();
const embeddedWallets = user.linkedAccounts.filter((account): account is WalletWithMetadata => (account.type === 'wallet' && account.walletClientType === 'privy'));

Then, filter the array of embedded wallets for entries where the delegated flag is set to true:

tsx
const delegatedWallets = embeddedWallets.filter((wallet) => wallet.delegated);

This constitutes the user's delegated wallets. Delegated wallets will always have the delegated flag set to true.

For embedded wallets that are not delegated, you may prompt users to delegate actions to your app to allow your app to execute certain transactions on their behalf.

For embedded wallets that are delegated, your app may execute wallet actions on the user's behalf within the set of permissions that the user has consented to. Alternatively, you may give users the option to revoke delegation to prevent your app from taking further actions on their behalf.