Skip to main content

Overview

The Embedded Wallet Kit provides a straightforward way to create and manage embedded wallets in your React application. EWK offers function abstractions to easily create embedded wallets, derive accounts, import and export wallets and more. Before we start, ensure you’re familiar with the concepts of Wallets and Wallet Accounts.

Creating an embedded wallet

After your user has authenticated, you can create an embedded wallet using the createWallet function from the useTurnkey hook. This will create a new wallet within the end-user’s sub-organization with one Ethereum and one Solana wallet account.
This wallet can then be accessed through the wallets array in the useTurnkey hook, which contains all embedded wallets associated with the sub-organization and all linked external wallets. This array is updated automatically when wallets are created, updated or removed.
You can also manually refresh the wallets by calling the refreshWallets function from the useTurnkey hook.

Creating wallet accounts

You can specify which accounts to create in the wallet by passing an array of account formats or account objects to the accounts parameter.

Using address formats

You can use predefined account formats to create accounts in the wallet. The wallet account will be automatically created with the correct path and path index based on the existing wallet the sub-organization has.

Using account objects

You can also create accounts by passing an array of account objects. This allows you to specify the curve, pathFormat, path, and addressFormat.

After wallet creation

You can use the createWalletAccount function to add more accounts to an existing wallet.

Importing and exporting wallets

You can also import and export wallets using the handleImportWallet and handleExportWallet functions. These functions open up UI modals that allows users to export or import wallets through a secure iframe. You can learn more about importing using an iframe and exporting using an iframe before continuing.
You will see this import modal when you click the “Import Wallet” button: Import Wallet Modal and this export modal when you click the “Export Wallet” button: Export Wallet Modal Check out this example showing how to import / export wallets, wallet accounts and private keys using @turnkey/react-wallet-kit.

Next steps

Now that you know how to create and manage embedded wallets in your React application, check out the Connecting External Wallets guide to learn how to connect and use external wallets. Looking to add funds via on ramp? Check out the OnRamp guide to learn how to add funds to your Turnkey Wallet. Don’t want to use external wallets? Check out the Signing guide to learn how to sign transactions and messages with the embedded wallets you’ve created.