Core Functions
generateKeyPair
Generates a new P256 key pair for use with Base Account.getKeypair
Retrieves an existing P256 key pair if one has been previously generated and stored.getCryptoKeyAccount
Complete Integration Example
Here’s how these utilities work together in a typical application:Error Handling
Handle common errors when using these utilities:Best Practices
-
Check for existing accounts: Always use
getCryptoKeyAccount()
first to check if a user is already connected -
Handle null returns: These functions can return
null
- always check before using the results -
Secure key management: If using
generateKeyPair()
orgetKeypair()
, handle private keys securely - Error handling: Wrap calls in try-catch blocks to handle authentication and network errors
- User experience: Provide clear feedback when accounts aren’t found or need to be created