Creating Embedded Wallets
No matter how your user signs up, whether it’s using social login i.e. Telegram, email/phone login or even with a branded wallet i.e. Metamask, you can create an embedded wallet for them using Dynamic. Simply decide when you want this wallet created and follow the guides below.
During Signup (automatic)
By default, wallets are created automatically for users when they sign up for your application. All you have to do is check that the “Create on Sign up” toggle is turned on in the Embedded Wallet configuration page.
Automatic embedded wallet creation only creates a single wallet for a user on
each chain you have selected. If you want to create multiple wallets per chain
you will need to use the
createEmbeddedWalletAccount
method from the useEmbeddedWallet
hook. See creating additional wallets
Before Signup (pre-generated)
Pre-generated wallets allow you to create a wallet for a user prior to their first interaction with your application using either an email, phone number or social identifier (i.e. Farcaster or Twitter).
Simply provide an identifier to our API and receive the new wallet address in the response. The user can receive funds and assets into their wallet!
Check out the createEmbeddedWallet API to see all the available identifier types.
Creating wallets on additional chains
For users with an existing embedded wallet on a single chain, you can create an embedded wallet on an additional chain using the createEmbeddedWalletAccount method exported from the useEmbeddedWallet
hook.
Custom Logic (manual)
Creating wallets any time
If you do not want to create wallets for users automatically when they sign up, you can create wallets for users using custom logic, calling the createEmbeddedWallet
method from the useEmbeddedWallet
hook when you want to create a wallet for a user.
Creating additional wallets
For users with an existing embedded wallet, you can create additional embedded wallets using the createEmbeddedWalletAccount method exported from the useEmbeddedWallet
hook.
Using the createEmbeddedWalletAccount
method to create additional wallets on the same chain derives wallets from the user’s existing secret recovery phrase. This means that the user can access all their wallets using the same exported recovery phrase for each chain. The private keys for each wallet are derived from the recovery phrase and are unique to each wallet.
Embedded wallets created in Live environments cannot be deleted or removed. Ensure that you only create the desired quantity of wallets for each user.
The limitations for creating additional wallets are as follows:
- Maximum of 5 wallets per chain
- Maximum of 15 wallets per user
- If Smart Wallets are enabled, each generated signer wallet will have its own AA enabled wallet
Creating Embedded Wallet alongside Branded Wallet
Keep the “Create on Sign up” toggle in the Embedded Wallet configuration page toggled on, and then use the createEmbeddedWallet
method from the useEmbeddedWallet
hook to create a wallet for a user who has signed up using a branded wallet.
You can tell if you need to create that wallet post signup by checking userHasEmbeddedWallet
from the useEmbeddedWallet
hook.
Notes
Content Security Policy (CSP)
Embedded wallets use iframes to provide one more security layer to the wallet. If you enforce CSP on your website, you will need to add the following to your frame-src
directive:
- https://auth.turnkey.com - used for establishing sessions with one-time codes
- https://recovery.turnkey.com - used for creating a new passkey for an existing wallet
- https://export.turnkey.com - used for exporting a wallet’s private key or seed phrase
What Next?
- Learn how to use/interact with the wallet in the Using Wallets section
- Learn how to customize the transaction flow in the Embedded Transaction UI guide
Was this page helpful?