Current Implementation
Currently, Swig uses the compressed public key format for authentication (not the Ethereum address). A future update will introduce anEvmAddress authority type that uses the hashed form of the public key (the standard Ethereum address).
Integration Examples
Viem Integration (Recommended)
The recommended approach for Ethereum wallet integration uses the Viem library. Here’s a complete example showing different signing methods:Session-Based Authorization
For enhanced security and better UX, you can use session-based authorization with secp256k1 keys:Best Practices
-
Wallet Integration
- Use the Viem example as your primary reference for Ethereum wallet integration
- Choose the appropriate signing method based on your wallet implementation
- Always verify the signing method (eth_sign vs personal_sign) matches your wallet’s capabilities
-
Security Considerations
- Use session-based authorities for dApp integrations to limit exposure
- Keep session durations appropriate for your use case
- Remember that while using Ethereum keys, you still need a Solana account for transaction fees
-
Implementation Tips
- Use the provided helper functions like
createSecp256k1AuthorityInfo - Implement proper error handling for signing operations
- Consider implementing all three signing methods for maximum wallet compatibility
- Use the provided helper functions like
Future Developments
The upcomingEvmAddress authority type will allow using the standard Ethereum address format (the hashed form of the public key) instead of the current compressed public key format. This will make integration even more straightforward and familiar to Ethereum developers.
Additional Resources
For complete working examples, check out these files in the swig-ts repository:examples/classic/transfer/transfer-svm-viem.ts- Viem integration exampleexamples/classic/transfer/transfer-svm-secp-session.ts- Session-based authorizationexamples/classic/transfer/transfer-svm-secp.ts- Basic secp256k1 usageexamples/classic/transfer/transfer-local-secp.ts- Local testing example

