Wallet addresses are required to create users in Snag. If you’re migrating existing users, see our migration guide for step-by-step instructions.
Option 1: Generate with viem Library
For backend wallet generation, you can use the viem library to create new EVM wallet addresses. This approach gives you full control over wallet generation and is ideal for server-side implementations.Installation
Generate a Wallet
Complete Integration Example
Here’s a full example showing how to generate a wallet and create a Snag user:Option 2: Smart Contract Wallet Providers
For a managed solution, use embedded wallet providers that handle wallet creation and key management automatically. These providers abstract away the complexity of private key management and provide a better user experience.Recommended Providers
Dynamic
Easy-to-integrate embedded wallets with email/social login support
Privy
Embedded wallets with excellent UX for Web2 users transitioning to Web3
Biconomy
Smart account infrastructure with gasless transactions and account abstraction
Thirdweb
Comprehensive wallet SDK with smart accounts and social login
Advantages of Smart Wallet Providers
These providers offer several advantages over self-managed wallet generation:- Automatic key management - No need to handle private keys yourself
- Social login integration - Email or social login → wallet address mapping
- Better UX - Seamless onboarding for Web2 users
- Built-in security - Industry best practices implemented out of the box
- Account recovery - Users can recover access without managing seed phrases
- Multi-chain support - Easy support for multiple blockchain networks
Integration Example with Dynamic
Here’s a basic example of how you might integrate Dynamic’s embedded wallets:Best Practices
Regardless of which approach you choose, follow these best practices:Link to Internal User IDs
Link to Internal User IDs
Always use the
externalIdentifier field to link Snag users to your internal user ID system. This makes it easy to query and manage users across your systems.Implement Backup and Recovery
Implement Backup and Recovery
For self-managed wallets, implement a secure backup and recovery mechanism. Consider using deterministic wallet generation (HD wallets) for easier recovery.
Use Environment-Specific Keys
Use Environment-Specific Keys
Separate wallet generation between development, staging, and production environments. Never use production keys in development.
Audit Access to Private Keys
Audit Access to Private Keys
Log and monitor all access to private keys. Implement alerts for unusual access patterns.
Consider Regulatory Requirements
Consider Regulatory Requirements
Be aware of regulatory requirements in your jurisdiction regarding custody of user assets and key management.