Skip to main content
The Base Account SDK provides several core utility functions for managing cryptographic keys and accessing account information. These functions are essential for advanced integrations and Sub Account management.

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

  1. Check for existing accounts: Always use getCryptoKeyAccount() first to check if a user is already connected
  2. Handle null returns: These functions can return null - always check before using the results
  3. Secure key management: If using generateKeyPair() or getKeypair(), handle private keys securely
  4. Error handling: Wrap calls in try-catch blocks to handle authentication and network errors
  5. User experience: Provide clear feedback when accounts aren’t found or need to be created
These utilities provide the foundation for advanced Base Account integrations, particularly when working with Sub Accounts and custom authentication flows.