React SDK
- Ethereum
- Solana
REST API
To create a new wallet for a user via the REST API, make aPOST 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 theAuthorization header:
Request body
The type of wallet to create.
'ethereum'- Create an Ethereum/EVM wallet'solana'- Create a Solana/SVM wallet
Response
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:- Apps where all users need wallets
- Gaming applications
- NFT marketplaces
- DeFi applications
- Simplest onboarding experience
Manual creation
Use theuseCreateWallet hook to create wallets programmatically:
- 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
Check for existing wallets
Check for existing wallets
Always check if a user already has a wallet before attempting to create one:
Handle errors gracefully
Handle errors gracefully
Provide clear feedback when wallet creation fails:
Show loading states
Show loading states
Display loading indicators during wallet creation:
Educate users
Educate users
Explain what a wallet is and why they’re creating one:
Use callbacks for post-creation actions
Use callbacks for post-creation actions
Handle navigation or UI updates after successful wallet creation:
Secure your API keys
Secure your API keys
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