Implementation
This library is compatible with Node.js, browsers and React Native applications (Node.js modules require polyfills for React Native).Dapps will also need to install Reown AppKit for the UI.2. Add listeners for desired 3. Create a new AppKit instance.4. Connect the application and specify session permissions.
@walletconnect/modal
is now deprecated. Please use @reown/appkit
instead. For migration guidance, see the WalletConnect Modal to Reown AppKit Core migration guide.For an example implementation, please refer to our
react-dapp-v2
example.Install Packages
Create a Session
1. Initiate your WalletConnect client with the relay server, using your Project ID.SignClient
events.To listen to pairing-related events, please follow the guidance for Pairing
API event
listeners.
Session Authenticate with ReCaps
The authenticate() method enhances the WalletConnect protocol, offering EVM dApps a sophisticated mechanism to request wallet authentication and simultaneously establish a session. This innovative approach not only authenticates the user but also facilitates a seamless session creation, integrating the capabilities defined by ERC-5573, also known as ReCaps.ReCaps extend the SIWE protocol, enabling users to give informed consent for dApps to exercise scoped capabilities on their behalf. This consent mechanism is crucial for authorizing a dApp to perform actions or access resources, thus ensuring security and trust in dApp interactions. These scoped capabilities are specified through ReCap URIs in the resources field of the AuthRequestParams, which translate to human-readable consent in the SIWE message, detailing the actions a dApp is authorized to undertake.To initiate an authentication and authorization request, a dApp invokes the authenticate() method, passing in parameters that include desired capabilities as outlined in EIP-5573. The method generates a pairing URI for user interaction, facilitating a streamlined authentication and consent process.Example of initiating an authentication request with ReCaps:Making Requests
Once the session has been established successfully, you can start making JSON-RPC requests to be approved and signed by the wallet:For more information on available JSON-RPC requests, see the JSON-RPC reference.
Restoring a Session
Sessions are saved to localstorage, meaning that even if the web page is reloaded, the session can still be retrieved, as demonstrated in the following code:Finding a Specific Session
If you need to find a specific session, you can do so by passing in a knownrequiredNamespace
and calling find
.