You have already set up the Dynamic SDK and wrapped your app with the DynamicContextProvider.
You have enabled Dynamic-powered embedded wallets and toggled off “Create on Sign up” on in the configuration. If you have “Create on Sign up” turned on, the embedded wallet will be created for the user automatically on sign up. You can skip steps 1 and 2 in the section below.
You do not have the DynamicWidget component in your application code.
Import useEmbeddedWallet and access the variable to check if user has an embedded wallet already, as well as the method to create our new wallet and a variable to hold our new wallet ID.
Note that you can still generate a wallet if the user has one already, please read about embedded wallet accounts if that’s something you’d like to do. For this guide we’ll assume we want to generate an initial wallet.
This can take two forms, if it’s the only wallet a user has, then we can access primaryWallet from useDynamicContext and that is guaranteed to be the embedded wallet:
If however the user signed up with a branded wallet, then they will have multiple. In this case we can check via the useUserWallets hook and use the walletId returned by the create wallet call:
Copy
Ask AI
import { useUserWallets } from '@dynamic-labs/sdk-react-core';const userWallets = useUserWallets();
On the connector interface for each wallet, you’ll find an isEmbeddedWallet boolean which we can use:
Creating a transaction for the embedded wallet to sign follows exactly the same steps as our other examples here. We’ll assume you accessed the wallet via primaryWallet.
Once the sendTransaction call is triggered, there can be an optional transaction confirmation UI step. You can either keep the confirmation screen or disable it entirely - read morehere.