Wallet Integration
A smooth wallet integration is crucial for providing a seamless user experience when interacting with Mach Exchange. This guide outlines best practices for wallet integration based on proven implementations.Multi-Chain Wallet Support
When integrating with Mach Exchange, it’s important to support multiple wallet types to accommodate different blockchain ecosystems:- EVM Wallets: For Ethereum, Arbitrum, Optimism, Base, and other EVM chains
- Solana Wallets: For interacting with the Solana ecosystem
- Tron Wallets: For Tron blockchain interactions
Wallet Connection UI
Connection Button
The wallet connection button should:- Clearly indicate the current connection state (connected/disconnected)
- Display relevant wallet information when connected
- Provide easy access to connection options for different chains
Wallet Portfolio Drawer
The WalletPortfolioDrawer component is an effective way to show connected wallets and their assets. Key features to implement:- Dynamic Connected Wallet Count: Display the number of connected wallets with proper singular/plural handling (e.g., “1 Connected Wallet” vs “2 Connected Wallets”)
- Chain Indicators: Show chain icons as small badges at the bottom right of wallet connector icons:
- Chain Filtering: Implement a chain filter to allow users to filter tokens by different blockchain networks:
Wallet Connection Flow
Implement a clear wallet connection flow that guides users through the process:- Initial Connection: Prompt users to connect their wallet when they first interact with Mach-related features
- Chain Selection: Allow users to select which chain they want to connect to
- Wallet Selection: Present wallet options based on the selected chain
- Connection Confirmation: Show a confirmation when the wallet is successfully connected
Supporting Multiple Connected Wallets
Mach’s cross-chain capabilities mean users might want to connect multiple wallets across different chains simultaneously. Your integration should:- Track all connected wallets separately
- Display appropriate information for each wallet
- Use the correct wallet for each transaction based on the chain
Chain-Specific Considerations
Different blockchain ecosystems have their own unique considerations for wallet integration:EVM Wallets
- Support popular EVM wallets like MetaMask, WalletConnect, Coinbase Wallet
- Handle chain switching for multi-chain EVM wallets
- Manage approvals for ERC-20 tokens
Solana Wallets
- Support Phantom, Solflare, and other Solana wallets
- Use Solana-specific signing methods
- Handle Solana’s different address format
Tron Wallets
- Support TronLink and other Tron-compatible wallets
- Manage energy and bandwidth resources for Tron transactions
- Handle Tron’s different address format (starting with “T”)
Best Practices
- Error Handling: Provide clear error messages when wallet connections fail
- Visual Feedback: Show loading states during connection attempts
- Chain Indicators: Use consistent chain badges/icons to indicate which chain a wallet or token belongs to
- Persistence: Remember user’s wallet connections where appropriate (with user consent)
- Mobile Support: Ensure wallet connection flows work well on mobile devices
- Security: Never ask for or store private keys or seed phrases