> ## Documentation Index
> Fetch the complete documentation index at: https://docs.dynamic.xyz/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Creating Embedded Wallets (Legacy)

<Card title="Recommended: JavaScript SDK with React Hooks" icon="react" color="#4779FE">
  For new React apps, we recommend the JavaScript SDK with React Hooks (`@dynamic-labs-sdk/react-hooks`) instead of the legacy React SDK documented here. The JS SDK comes with many benefits such as a much smaller bundle size and other optimizations. Use the [React quickstart (JavaScript SDK)](/javascript/reference/react-quickstart) to get started.
</Card>

<Warning>
  Note that this guide is for legacy (V2) embedded wallets. If you are looking for current embedded wallet documentation, please go [here](/react/wallets/embedded-wallets/mpc/creating-wallets).
</Warning>

No matter how a user signs up, whether it's through social login (like Telegram), email or phone, or even a branded wallet (such as MetaMask), you can create an embedded wallet for them using Dynamic. Simply choose when you want the wallet to be created and follow the guides below.

<Info>
  Please make sure you are on V4 of the SDK on your frontend before continuing.
</Info>

## During Signup (Automatic)

### Creating wallets for non-wallet authentication login

By default, embedded wallets are created automatically for users during sign-up if they don't already have a wallet on the enabled chain. All you have to do is check that the "Create on Sign up" toggle is turned on in [the Embedded Wallet configuration page](https://app.dynamic.xyz/dashboard/embedded-wallets/dynamic).

<Frame>
  <img src="https://mintcdn.com/dynamic-docs/DXbjtpFZjzIwv2VQ/images/dashboard/dashboard-wallets-on-signup-toggle.png?fit=max&auto=format&n=DXbjtpFZjzIwv2VQ&q=85&s=468ee174be1775dfd815be980097c807" alt="" width="1420" height="220" data-path="images/dashboard/dashboard-wallets-on-signup-toggle.png" />
</Frame>

### Creating wallets for external wallet login

Embedded wallets can be automatically created for users signing in with external wallets, such as Metamask. To enable this feature, click on the “Create on Sign up” card and expand the “Advanced Options” panel. Lastly, ensure that the "Embedded Wallet for Third-Party Wallets" toggle is enabled.

<Frame>
  <img src="https://mintcdn.com/dynamic-docs/DXbjtpFZjzIwv2VQ/images/dashboard/dashboard-third-party-wallets-on-sign-in.png?fit=max&auto=format&n=DXbjtpFZjzIwv2VQ&q=85&s=ffec607034d504cc7fa6e2b65bd3d64e" alt="" width="1160" height="660" data-path="images/dashboard/dashboard-third-party-wallets-on-sign-in.png" />
</Frame>

<Note>
  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](/react/reference/hooks/legacy-embedded-wallets/useembeddedwallet#create-embedded-wallet-account)
  method from the `useEmbeddedWallet` hook. See [creating additional wallets](/react/wallets/embedded-wallets/legacy/create-embedded-wallets#creating-additional-wallets)
</Note>

## 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 before they sign up!

```javascript theme={"system"}
const options = {
  method: "POST",
  headers: {
    Authorization: "Bearer <token>",
    "Content-Type": "application/json",
  },
  body: '{"identifier":"me@myemail.com","type":"email", "chain":"ETH", ,"socialProvider":"emailOnly"}',
};

fetch(
  "https://app.dynamicauth.com/api/v0/environments/YOUR_ENVIRONMENT_ID/embeddedWallets",
  options
)
  .then((response) => response.json())
  .then((response) => console.log(response))
  .catch((err) => console.error(err));
```

<Tip>
  Check out the [createEmbeddedWallet
  API](/api-reference/wallets/legacy/creates-a-new-embedded-wallet-for-a-user-given-an-identifier) to see all the
  available identifier types.
</Tip>

## 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](/react/reference/hooks/legacy-embedded-wallets/useembeddedwallet#create-embedded-wallet-account) 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. This can be done by calling the `createEmbeddedWallet` method from the `useEmbeddedWallet` hook.

```javascript theme={"system"}
import { useEmbeddedWallet } from "@dynamic-labs/sdk-react-core";

// component declaration and all other logic you might need

const { createEmbeddedWallet } = useEmbeddedWallet();

const onCreateWalletHandler = async () => {
  try {
    await createEmbeddedWallet();
  } catch (e) {
    console.error(e);
  }
};
```

### Creating additional wallets

For users with an existing embedded wallet, you can create additional embedded wallets using the [createEmbeddedWalletAccount](/react/reference/hooks/legacy-embedded-wallets/useembeddedwallet#create-embedded-wallet-account) 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.

<Warning>
  Embedded wallets created in Live environments cannot be deleted or removed. Ensure that you only create the desired quantity of wallets for each user.
</Warning>

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

First, ensure that the "Create on Sign up" toggle in the [Embedded Wallet configuration page](https://app.dynamic.xyz/dashboard/embedded-wallets/dynamic) is toggled on. 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.

```javascript theme={"system"}
import { useEmbeddedWallet } from "@dynamic-labs/sdk-react-core";

// component declaration and all other logic you might need

const { createEmbeddedWallet, userHasEmbeddedWallet } = useEmbeddedWallet();

const onCreateWalletHandler = async () => {
  if (!userHasEmbeddedWallet) {
    try {
      await createEmbeddedWallet();
    } catch (e) {
      console.error(e);
    }
  }
};
```
