Using walletInstance
The walletInstance property provides direct access to the underlying wallet provider through WalletConnect. While WalletConnect offers a unified API for common operations, the wallet instance enables advanced interactions and access to wallet-specific features.
Overview
When a wallet connection is established, WalletConnect exposes the connected wallet's provider through the walletInstance property. This allows developers to bypass the WalletConnect abstraction layer when necessary and interact directly with the wallet's native API.
The walletInstance is null when no wallet is connected. Always verify the returned value before using it.
The walletInstance does not have a fixed type. Its structure depends on the connected wallet extension and may vary between providers.
Accessing the walletInstance
Access the walletInstance through WalletConnect using the useWalletConnect() hook.
import { useWalletConnect } from "@btc-vision/walletconnect";
function App() {
const {walletInstance} = useWalletConnect();
if(walletInstance){
...
}
}When to Use walletInstance
Use the walletInstance when you need to:
- Access wallet-specific features not available through WalletConnect.
- Perform advanced operations.
- Interact with wallet-specific APIs or extensions.
For standard operations such as connecting, disconnecting, and basic transaction signing, the WalletConnect API is recommended as it provides a consistent interface across all supported wallets.