Wallet Management
Configure your widget for seamless wallet management
The widget has a built-in wallet management UI, so you can connect the wallet and use the widget as a standalone dApp out of the box. However, when embedding the widget into the dApp, reusing the existing wallet management UI of that dApp makes the most sense.
There are several ecosystems and types of chains (EVM, SVM, UTXO) supported by the widget, and therefore, there are several different libraries used to manage wallet connections to these chains.
EVM wallet connection
To manage wallet connection to EVM (Ethereum Virtual Machine) chains, switching chains, etc., the widget uses the Wagmi library internally and also provides first-class support for all Wagmi-based libraries such as RainbowKit, Dynamic, ReownAppKit
If you already manage wallets using Wagmi or Wagmi-based library in your dApp and the Widget detects that it is wrapped in WagmiProvider it will start re-using your wallet management without any additional configuration.
The example below shows how to preconfigure a basic wallet management using Wagmi.
Keep chains in sync
It is important to keep the Wagmi chains configuration in sync with the Widget chain list so all functionality, like switching chains, can keep working correctly.
There are two approaches to this:
-
Manually update the Widget and Wagmi chains configuration to specify all chains you would like to support in your dApp and the Widget. See Configure Widget page to know more about the Widget’s allow/deny chains configuration.
-
Get all available chains from LI.FI API and dynamically update Wagmi configuration. The Widget provides hooks to ease this approach.
Here is an example of how to support all available LI.FI chains dynamically using Wagmi and additional hooks from @lifi/widget
package.
Please check out our complete examples in the widget repository here.
Support for Ethers.js and other alternatives
Developers can still use Ethers.js or any other alternative library in their project and convert Signer
/Provider
objects to Wagmi’s injected connector before wrapping the Widget with WagmiProvider.
SVM wallet connection
To manage wallet connection to SVM (Solana Virtual Machine) chains the widget uses the Solana Wallet Standard library.
If you already manage wallets using Solana Wallet Standard library in your dApp and the Widget detects that it is wrapped in ConnectionProvider and WalletProvider it will start re-using your wallet management without any additional configuration.
The example below shows how to preconfigure a basic wallet management for SVM.
Configuration
There are additional configurations to smooth integration for external wallet management or in case of internal one provide options for WalletConnect and Coinbase Wallet.
Connect wallet button
Using internal wallet management clicking the Connect wallet
button triggers the opening of an internal wallet menu. In cases where external wallet management is used we provide onConnect
configuration option. This option allows developers to specify a callback function that will be executed when the Connect wallet
button is clicked.
Please see modified RainbowKit example below. Here we use openConnectModal
function provided by useConnectModal
hook to open RainbowKit wallet menu when the Connect wallet
button is clicked.
WalletConnect and Coinbase Wallet
We provide additional configuration for WalletConnect and Coinbase Wallet Wagmi connectors so when using built-in wallet management in the widget you can set WalletConnect’s projectId
or Coinbase Wallet’s appName
parameters.
Partial Wallet Management
Your external wallet management may not support all ecosystems provided by our widget, or you may be in the process of migrating to a new setup. To help with these cases, we’ve got you covered!
The usePartialWalletManagement
configuration option allows the widget to offer partial wallet management functionality. When enabled, this option provides a hybrid approach, effectively combining both external and internal wallet management.
In partial mode, external wallet management is used for “opt-out” providers, while internal management applies to any remaining providers that do not opt out. This setup creates a flexible balance between the integrator’s custom wallet menu and the widget’s native wallet menu, ensuring a smooth user experience across all ecosystems, even if external support is incomplete or in transition.
Partial wallet management example
As shown in the example above, this setup allows both the integrator’s and the widget’s wallet menus to operate together, each supporting different ecosystems. In the example, RainbowKit manages EVM wallet support, while the internal wallet menu handles Solana and Bitcoin.