Content
Links to sections on this page. Some sections are platform specific and are only visible when the platform is selected. To view a summary of useful platform specific topics, check out Extra (Platform Specific) under this section. Initialization: Creating a new WalletKit instance and initializing it with a projectId from Dashboard. Session: Connection between a dapp and a wallet.- Namespace Builder: Namespace Builder is a helper utility that greatly reduces the complexity of parsing the required and optional namespaces. It accepts as parameters a session proposal along with your user’s chains/methods/events/accounts and returns a ready-to-use object
- Session Approval: Approving a session sent from a dapp
- Session Rejection: Rejecting a session sent from a dapp
- Responding to Session Requests: Responding to session requests sent from a dapp
- Updating a Session: Updating a session sent between a dapp and wallet
- Extending a Session: Extending a session between a dapp and wallet
- Session Disconnect: Disconnecting a session between a dapp and wallet
- Register Device Token Enabling Wallet Push Notifications by registering a device token.
- Subscribe for WalletKit Publishers Publishers available to subscribe to for WalletKit
Initialization
Confirm you have configured the Network Client first. Starting from WalletConnect SDK version 1.9.5, theredirect
field in the AppMetadata
object is mandatory. Ensure that the provided value matches your app’s URL scheme to prevent redirection-related issues.
Once you’re done, in order to initialize a client just call a configure
method from the WalletKit instance wrapper
- Subscribing to a Pairing Topic
- Approving a Session
- Approving an Authenticated Session
- Trace Events: Collected to verify the proper execution of code.
- Error Events: Captured when errors occur during the trace, halting the execution trace.
- The SDK stores events and sends them to the server.
- The SDK stops storing new events and deletes all unsent events from local storage upon the next initialization.
Session
A session is a connection between a dapp and a wallet. It is established when a user approves a session proposal from a dapp. A session is active until the user disconnects from the dapp or the session expires.Namespace Builder
AutoNamespaces
is a helper utility that greatly reduces the complexity of parsing the required and optional namespaces. It accepts as parameters a session proposal along with your user’s chains/methods/events/accounts and returns ready-to-use SessionNamespace
object.
EVM methods & events
In @walletconnect/ethereum-provider, (our abstracted EVM SDK for apps) we support by default the following Ethereum methods and events:Session Approval
sessionsPublishers
will publish a Session
Session
object represents an active session connection with a dapp. It contains dapp’s metadata (that you may want to use for displaying an active session to the user), namespaces, and expiry date. There is also a topic property that you will use for linking requests with related sessions.
You can always query settled sessions from the client later with:
Connect Clients
Your Wallet should allow users to scan a QR code generated by dapps. You are responsible for implementing it on your own. For testing, you can use our test dapp at: https://react-app.walletconnect.com/, which is v2 protocol compliant. Once you derive a URI from the QR code callpair
method:
Session.Proposal
object conveys set of required and optional ProposalNamespaces
that contains blockchains methods and events. Dapp requests with methods and wallet will emit events defined in namespaces.
VerifyContext
provides a domain verification information about Session.Proposal
and Request
. It consists of origin of a Dapp from where the request has been sent, validation enum that says whether origin is unknown, valid or invalid and verify URL server.
To enable or disable verification find the Verify SDK toggle in your project dashboard.
Account
type meets the criteria.
Track Sessions
When yourWalletKit
instance receives requests from a peer it will publish a related event. Set a subscription to handle them.
To track sessions subscribe to sessionsPublisher
publisher
Session Rejection
Responding to Session requests
After the session is established, a dapp will request your wallet’s users to sign a transaction or a message. Requests will be delivered by the following publisher.AnyCodable
type. An expected object can be derived as follows:
Updating a Session
If you want to update user session’s chains, accounts, methods or events you can use session update method.Extending a Session
By default, session lifetime is set for 7 days and after that time user’s session will expire. But if you consider that a session should be extended you can call:Session Disconnect
For good user experience your wallet should allow users to disconnect unwanted sessions. In order to terminate a session usedisconnect
method.
Subscribe for WalletKit Publishers
The following publishers are available to subscribe:Register Device Token
To register a wallet to receive WalletConnect push notifications, callregister
method and pass the device token received from the didRegisterForRemoteNotificationsWithDeviceToken
method in the AppDelegate
.