Skip to main content
MoonKey enables you to create embedded wallets for your users programmatically. These self-custodial wallets are owned by the authenticated user and secured using distributed key sharding. You can create wallets either automatically when users authenticate, or manually when needed using the SDK.
MoonKey supports automatically creating embedded wallets for your users when they log in to your app. View the automatic wallet creation guide to learn more.

React SDK

To create an Ethereum wallet with the React SDK, use the createWallet method from the useCreateWallet hook:

Usage

Returns

Promise<Wallet>
A Promise for the wallet object containing the created wallet’s details.

Callbacks

You can optionally register onSuccess or onError callbacks on the useCreateWallet hook:
(wallet: Wallet) => void
Optional callback to run after a user successfully creates a wallet.
(error: Error) => void
Optional callback to run if there is an error during wallet creation.

Complete example

REST API

To create a new wallet for a user via the REST API, make a POST request to:
You must specify the user ID as the owner of the wallet. You can obtain a user ID by first creating a user before creating the wallet.

Authentication

Include your Secret API Key in the Authorization header:

Request body

'ethereum' | 'solana'
required
The type of wallet to create.
  • 'ethereum' - Create an Ethereum/EVM wallet
  • 'solana' - Create a Solana/SVM wallet
string
required
The ID of the user who will own this wallet (e.g., user_2Cu2uVhYy0OVgRcO913OsqIVaPI).

Response

string
Unique ID of the created wallet. This is the primary identifier for the wallet.
string
The ID of your MoonKey application.
string
The ID of the user who owns this wallet.
string
The wallet’s public address (Ethereum address or Solana public key).
'ethereum' | 'solana'
The type of wallet created.
boolean
Whether the wallet has been verified. Always true for newly created wallets.
boolean
Whether this is the user’s default wallet for this chain type.
number
Unix timestamp (in seconds) when the wallet was created.
number
Unix timestamp (in seconds) when the wallet was last updated.

Example request

Example response

Automatic vs manual wallet creation

MoonKey provides two approaches to wallet creation:

Automatic creation

Configure MoonKey to automatically create wallets when users authenticate:
Best for:
  • Apps where all users need wallets
  • Gaming applications
  • NFT marketplaces
  • DeFi applications
  • Simplest onboarding experience
Learn more about automatic wallet creation.

Manual creation

Use the useCreateWallet hook to create wallets programmatically:
Best for:
  • Apps with optional blockchain features
  • Progressive onboarding flows
  • Users who opt-in to web3 features
  • When you want to delay wallet creation for UX reasons

Checking if a user has a wallet

Before creating a wallet, check if the user already has one:

Common use cases

Onboarding flow with wallet creation

Optional wallet creation

Server-side wallet creation

Best practices

Always check if a user already has a wallet before attempting to create one:
Provide clear feedback when wallet creation fails:
Display loading indicators during wallet creation:
Explain what a wallet is and why they’re creating one:
Handle navigation or UI updates after successful wallet creation:
Never expose your Secret API Key in client-side code:

Error handling

Common errors and how to handle them:

Next steps

Automatic Wallet Creation

Configure automatic wallet creation on login

Send Transactions

Learn how to send transactions with the wallet

Sign Messages

Sign messages for authentication

Export Private Key

Allow users to export their private key