How it works
When a user requests to export their private key:- Your app calls the export key method from the MoonKey SDK
- The Export Key screen appears with security warnings
- User reviews the warnings and understands the risks
- User confirms they want to proceed
- The private key is displayed to the user
- User can copy the private key for backup or import into another wallet
Triggering the Export Key screen
Use theuseExportPrivateKey hook from the MoonKey SDK to trigger the Export Key screen:
- Ethereum
- Solana
Customizing the Export Key screen
You can customize the Export Key screen by passing UI configuration:Configuration options
string
Custom title text displayed at the top of the Export Key screen.Example:
string
Description text for HD (Hierarchical Deterministic) wallet seed phrase export option.This text explains what an HD seed phrase is and its purpose.Example:
string
Description text for the private key export option.This text explains what the private key is and how it’s used.Example:
Warning text emphasizing that private keys should never be shared.This critical security warning is prominently displayed.Example:
string
Text displayed while export options are being loaded.Example:
string
URL to your company logo. Displayed at the top of the Export Key screen.Example:
Security warnings
The Export Key screen displays multiple security warnings to users:Private Key = Full Access
Private Key = Full Access
Anyone with access to your private key has complete control over your wallet and all funds in it.
Secure Storage
Secure Storage
If you choose to store your private key, keep it in a secure location like a password manager or offline storage.
Phishing Risk
Phishing Risk
Be cautious of phishing attempts. Only export your key when you initiated the action.
Use cases
Wallet backup
Allow users to backup their wallet for recovery purposes:Migrate to another wallet
Help users migrate their wallet to another application:Advanced users self-custody
Provide power users with their private key for self-custody:Complete example
Here’s a complete example with proper warnings and logging:User experience flow
1
Trigger export
User clicks button to export their private key.
2
Security warnings
The Export Key screen displays comprehensive security warnings about the risks.
3
User acknowledges risks
User must acknowledge they understand the risks before proceeding.
4
Private key displayed
The private key is displayed on screen, typically with a copy button.
5
User copies key
User copies the private key to store it securely.
6
Confirmation
User confirms they have securely stored the key before closing the screen.
Best practices
Add extra confirmation
Add extra confirmation
Require additional confirmation before showing the Export Key screen:
Log export events
Log export events
Keep a security audit log of private key exports:
Educate users
Educate users
Provide educational content about key security:
Limit export frequency
Limit export frequency
Consider rate limiting exports to prevent abuse:
Require re-authentication
Require re-authentication
For sensitive operations, require fresh authentication:
Provide alternatives
Provide alternatives
Suggest safer alternatives when appropriate:
Security considerations
For developers:- Multiple confirmations - Require users to confirm multiple times
- Clear warnings - Display unmistakable security warnings
- Audit logging - Log all export events with timestamps and IP addresses
- Rate limiting - Limit how often users can export keys
- Re-authentication - Require fresh login before export
- User education - Provide resources about key security
- Alternative options - Suggest safer backup methods when possible
- Compliance - Ensure export functionality meets regulatory requirements
- Displaying clear warnings about the risks
- Explaining what a private key is and why it’s sensitive
- Requiring explicit confirmation before revealing the key
- Providing guidance on secure storage
- Warning against common phishing attempts
- Phishing websites that trick users into entering their private key
- Malicious browser extensions that steal private keys
- Screen recording malware that captures the displayed key
- Social engineering where attackers impersonate support
- Insecure storage like plaintext files or unencrypted notes