The web3 landscape is evolving rapidly, with new Layer 1 (L1) and Layer 2 (L2) blockchains emerging in the EVM ecosystem, while the altVM brings a surge of innovative chains. In this expanding multichain world, wallets must seamlessly support these networks to deliver the best UX.
In this guide, we’ll explore how to build a multichain wallet and integrate WalletConnect to support networks beyond EVM, including Solana, Polkadot, and more.
Multichain Connection Request
When connecting your wallet, you need to include approvedNamespaces in the dApp's approval request. This parameter specifies which chains, accounts, methods, and events you want the wallet to support.
The buildApprovedNamespaces method requires information about all desired namespaces, such as eip155 for EVM, solana, polkadot, or any other chains you wish to connect.
You can find the appropriate chainId for approvedNamespaces on this page.
After creating approvedNamespaces, make sure to include it when approving the session. Learn more about this process here.
Multichain Requests
To handle multichain requests, you can extract the method that the dApp is calling from the request received via session_request. After identifying the method name, you can process it accordingly.
Let's handle signing methods from different namespaces: solana_signMessage and solana_signTransaction for Solana, polkadot_signMessage for Polkadot, and personal_sign and eth_sendTransaction for eip155 (EVM).
Now that we have a helper function to sign messages and return signatures, let's implement it in session_request.
Switching a Chain
When creating a multichain wallet, you need to handle chain-switching events from the wallet. This ensures that when users switch chains in their wallet, the change is reflected in your dApp, assuming the dApp supports that chain. To achieve this, emit a chainChanged event with the chain details, allowing the dApp to detect and implement the chain switch.
Congratulations! You’ve successfully learned how to build a multichain wallet using WalletConnect, enabling seamless interaction with Solana, Polkadot, and EVM-based chains.
For a complete implementation, check out this GitHub repository, where you’ll find the full source code to create a multichain wallet.
Keep building! Let’s improve onchain UX and drive better experiences for Web3 users

