Getting the embeddeded wallet address
When your user creates an embedded wallet, that wallet becomes the active wallet for that user. You can access your user's active (embedded) wallet at
user.wallet to get their
address and more.
const embeddedWallet = user.wallet?.address;
Alternatively, you can also access the user's embedded wallet from the
user.linkedAccounts array of the
user object. The entry in
user.linkedAccounts corresponding to the embedded wallet will have a
type of 'wallet' and a
walletClient of 'privy'.
const embeddedWallet = user.linkedAccounts.find((account) => (account.type === 'wallet' && account.walletClient === 'privy'));