How to generate multiple wallets for a single user with PnP Flutter SDK and firebase custom authentication

Hello, I am using web3auth flutter with firebase custom authentication.

Since this gives us the private key for a single wallet, is it possible to generate multiple wallets from the same session?

From the docs, I believe we can get the dappShare value from userInfo = await Web3AuthFlutter.getUserInfo();

Taking an example of Metamask, once we have the mnemonic, we can generate multiple wallet accounts, is this possible with web3auth flutter?

And if so, any guides on how to go about it?

Hi Dickens!

Thanks for reaching out! It sounds like you’re looking to work with multiple wallets using the PnP Flutter SDK and Firebase custom authentication.

You mentioned needing to generate multiple wallets based on the dappShare from userInfo. While you can create a single wallet using the provided private key, to enable users to add multiple wallets, you’ll likely need to generate new key pairs for each wallet.

If you have the dappShare, you might consider using it to create multiple instances of wallets with different keys. Unfortunately, Web3Auth does not natively support wallet generation from a single Firebase user through dappShare.

Here are some suggested steps you might take:

  1. Use the dappShare to authenticate the user and maintain their session.
  2. Generate new wallets as needed either using a keystore approach or by creating new keys on the client-side.

If you have specific code snippets or additional details about how you’re currently initializing Web3Auth or any other related integration, please share! That way, I can assist you better.

Best of luck with your integration, and feel free to ask if you have more questions!

Note: This response was generated by an AI bot and may require further verification. The Web3Auth support team has tracked this issue and will be responding as soon as possible.

Yes, I am using PnP Flutter SDK and Firebase custom authentication to generate a user’s wallet/key pair from the idToken from firebase.

To get the session status if active or not, I am fetching the private key value with the recommended final privateKey = await Web3AuthFlutter.getPrivKey();

Just thinking out loud if there is a way I can use web3auth Pnp Flutter SDK and firebase custom authentication to generate multiple wallets for a user and enable them to switch between the generated wallets.

Hey @dickensodera9 directly you won’t be able to use the Web3Auth package to have multiple accounts. What you can do is, use the Web3Auth generated private key as an entropy to generate the 12/24 words mnemonic. For the mnemonic you can checkout this package: bip39_mnemonic | Dart package

These mnemonic can be then used to create a HD Wallet, there are lot of Dart packages which allows you to create HD Wallet. In HD Wallet you can use the account index to get a new account. Learn more about HD Wallet.

1 Like

Hi @Ayush, thank you so much for the response and suggestions. I’ll check them out.

I am stuck in similar situation and I am wondering if doing so will make us non custodial or breach the compliance for the same.

I am using flutter SFA with custom verifier. I get the privatekey and this private key is by default give option to get emv based address for eth and bsc chain.

My requirement is to create non-evm based address as well but for this i can not use the same privatekey.

Also it’s confusing,how to generate mnemonic for user to backup.

If I use privatekey as entropy and generate mnemonic and manage privatekey on my own to create non-evm and evm wallet. How would I ensure if the same user login to different devices get his all the wallets access.

When you generate a Mnemonic, a random entropy is generated which helps to generate the 12 words/ 24 words for the mnemonic. If you use the private key from the Web3Auth as an entropy, the function won’t generate the random entropy.

When you login into different device, the key given by the SFA Flutter won’t change. Since you are using private key as an entropy you can get the same wallet on multiple devices.

so you are suggesting that i can use the privateKey of SFA as entropy to generate mnemonic.

would this approach be a standard or recommended one?
would this not breach the compliance of non custodial wallet?

Thanks