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.

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!

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));

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)

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.

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);
  }
};

Create 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.

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);
    }
  }
};

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:

What Next?