EIP-1193 compliant Provider for the WalletConnect v2 protocol.
Built on top of Universal Provider and WalletConnectModal.
You can use this on it’s own or pass it down to libraries like ethers, viem or web3js.
showQrModal has been deprecated as WalletConnect’s Web3Modal is now rebranded as Reown’s AppKit. If you are looking to use this, please refer to the “Use with AppKit” section below.
Installation
Initialization
Initialize Ethereum Provider by calling its init method and passing down the required arguments:
- Make sure that
url from metadata matches your domain and subdomain. This will later be used by Verify API to confirm if your application has been verified or not.
- We recommend using
optionalChains (optional namespaces) over chains (required namespaces).
Required namespaces will block wallets from connecting to your application if any of the chains are not supported by the wallet. Smart Contract Wallets can only support one chain,
the one that they had been deployed to, this might cause issues when using required namespaces.
- Using
chains, methods or events will create a Required Namespaces object internally.
optionalMethods and optionalChains default to the following methods and events: Read source code.
- If
rpcMap is not defined it will fallback to Blockchain API RPCs. Keep in mind that Blockchain API supports a limited list of chains.
Init Params
The Ethereum Provider’s init method takes the following parameters:
Use with AppKit
The QRModal is enabled by default on reown’s AppKit. In order to use it, all you need to do is to create an AppKit instance.
Installation
Setup
Upon integrating the below code, you will be able to see the QRModal on your Web3 App.
Use without AppKit
You can subscribe to the display_uri event and handle the URI yourself.
You can then use the URI to generate a QR Code or redirect the user from the mobile browser to the wallet and request to connect.
The later one will require you to use the wallet’s deep link and the URI. You can get the deep link of wallets that support the WalletConnect v2 protocol from the Explorer API.
Sending Requests
Events
Session data
Once a wallet is connected you can find the session data in the provider.session object.
The session object includes the following properties, among others:
- namespaces:
session.namespaces is an object that contains the approved session data.
Note that the chains object is an optional parameter and may be undefined. Therefore, we encourage apps to obtain the approved chains from the session.accounts object instead.
- requiredNamespaces, optionalNamespaces & sessionProperties: These objects contain the namespaces and properties proposed for the session.
- peer: The
session.peer.metadata object contains the metadata of the connected wallet.
Find the complete type definition of the session object here.