Web Wallet in Reown AppKit & WalletButtons
Abstract Global Wallet to Wolfswap
Safe Wallet Connecting to AppKit Lab
walletKit
globally and use the same instance for all your sessions. For React-based apps, you can initialize it in the root component and export it to use in other components.customStoragePrefix
in production - this will cause the client to create new storage each time it is initialized. The client will not be able to persist/read existing data and all existing sessions will be lost after each reload.WC_URI
will be in the following format in the query parameters:
window.opener.location.href
window.close()
redirect
URL in the session proposalrequired
and optional
namespaces. It accepts as parameters a session proposal
along with your user’s chains/methods/events/accounts
and returns ready-to-use namespaces
object.
eip155
,cosmos
& near
Your supportedNamespaces
should look like the following example.
getActiveSessions
function.
session_proposal
event is emitted when a dapp initiates a new session with a user’s wallet. The event will include a proposal
object with information about the dapp and requested permissions. The wallet should display a prompt for the user to approve or reject the session. If approved, call approveSession
and pass in the proposal.id
and requested namespaces
.
The pair
method initiates a WalletConnect pairing process with a dapp using the given uri
(QR code from the dapps). To learn more about pairing, checkout out the docs.
No matching key. proposal id doesn't exist: 1
proposal.id
- in this example 1
.
This can happen when the proposal has expired (by default 5 minutes) or if you attempt to respond to a proposal that has already been approved/rejected.
If you are seeing this error, please make sure that you are calling approveSession
with the correct proposal.id
that is available within the proposal payload.
Error: Missing or invalid. approve(), namespaces should be an object with data
namespaces
parameter passed to approveSession
is either missing or invalid. Please check that you are passing a valid namespaces
object that satisfies all required properties.
Non conforming namespaces. approve() namespaces <property> don't satisfy required namespaces.
namespaces
object do not satisfy the required namespaces requested by the dapp.
To provide additional guidance, the message might include info about the exact property that is missing or invalid e.g. Required: eip155:1 Approved: eip155:137
.
Please check CAIP-25 to familiarize yourself with the standard and it’s nuances.
Additionally, we highly recommend you to use our namespace
builder utility that would greatly simplify the process of parsing & building a valid namespaces
object.
rejectSession
method. The getSDKError
function comes from the @walletconnect/utils
library.
No matching key. proposal id doesn't exist: 1
proposal.id
- in this example 1
.
This can happen when the proposal has expired (by default 5 minutes) or if you attempt to respond to a proposal that has already been approved/rejected.
If you are seeing this error, please make sure that you are calling rejectSession
with the correct proposal.id
that is available within the proposal payload.
Error: Missing or invalid. reject() reason:
reason
parameter passed to rejectSession
is either missing or invalid.
We recommend using the getSDKError
function from the @walletconnect/utils
library that will populate & format the parameter for you.
session_request
event is emitted when the SDK received a request from the peer and it needs the wallet to perform a specific action, such as signing a transaction. The event contains a topic
and a request
object, which will vary depending on the action requested.
To respond to the request, you can access the topic
and request
object by destructuring them from the event payload. To see a list of possible request
and response
objects, refer to the relevant JSON-RPC Methods for Ethereum, Solana, Cosmos, or Stellar.
As an example, if the dapp requests a personal_sign
method, you can extract the params
array from the request
object. The first item in the array is the hex version of the message to be signed, which can be converted to UTF-8 and assigned to a message
variable. The second item in params
is the user’s wallet address.
To sign the message, you can use your wallet’s signMessage
method and pass in the message. The signed message, along with the id
from the event payload, can then be used to create a response
object, which can be passed into respondSessionRequest
.
Error: No matching key. session topic doesn't exist: 'xyz...'
topic
- in this example xyz...
.
This can happen when the session has been disconnected by either the wallet or the dapp while the session request was being processed or if a session with such topic doesn’t exist.
If you are seeing this error, please make sure that you are using a correct topic that is available within the request payload.
Error: Missing or invalid. respond() response:
response
parameter passed to respondSessionRequest
is either missing or invalid. The response should be a valid JSON-RPC 2.0 response object.
We recommend you to use our formatJsonRpcResult
utility from "@walletconnect/jsonrpc-utils"
that will format the response for you.
Example usage:
id
argument being the request id from the request payload.
updateSession
allows you to do so.
You need pass in the topic
and a new Namespaces
object that contains all of the existing namespaces as well as the new data you wish to include.
After you update the session, the other peer will receive a session_update
event.
An example adding a new account to an existing session:
namespaces
validation applies and you still have to satisfy the required namespaces requested by the dapp.
Error: No matching key. session topic doesn't exist: 'xyz...'
topic
- in this example xyz...
.
This can happen when the session you’re trying to update has already been disconnected by either the wallet or the dapp or if a session with such topic doesn’t exist.
If you are seeing this error, please make sure that you are using a correct topic of an active session.
Error: Missing or invalid. update(), namespaces should be an object with data
namespaces
parameter passed to updateSession
is either missing or invalid. Please check that you are passing a valid namespaces
object that satisfies all required properties.
Non conforming namespaces. update() namespaces <property> don't satisfy required namespaces.
namespaces
object do not satisfy the required namespaces requested by the dapp.
To provide additional guidance, the message might include info about the exact property that is missing or invalid e.g. Required: eip155:1 Approved: eip155:137
.
Please check CAIP-25 to familiarize yourself with the standard and it’s nuances.
Additionally, we highly recommend you to use our namespace
builder utility that would greatly simplify the process of parsing & building a valid namespaces
object.
.extendSession
method and pass in the topic
of the session you wish to extend.
Error: No matching key. session topic doesn't exist: 'xyz...'
topic
- in this example xyz...
.
This can happen when the session you’re trying to update has already been disconnected by either the wallet or the dapp or if a session with such topic doesn’t exist.
If you are seeing this error, please make sure that you are using a correct topic of an active session.
.disconnectSession
by passing a topic
& reason
for the disconnect.
The other peer will receive a session_delete
and be notified that the session has been disconnected.
session_delete
event as well, to be notified when the other peer initiates a disconnect.getSDKError
utility function, that will provide ready-to-use reason
payloads and is available in the @walletconnect/utils
library.Error: No matching key. session topic doesn't exist: 'xyz...'
topic
- in this example xyz...
.
This can happen when the session you’re trying to update has already been disconnected by either the wallet or the dapp or if a session with such topic doesn’t exist.
If you are seeing this error, please make sure that you are using a correct topic of an active session.
emitSessionEvent
and pass in the params. If you wish to switch to chain/account that is not approved (missing from session.namespaces
) you will have to update the session first. In the following example, the wallet will emit session_event
that will instruct the dapp to switch the active accounts.
session_event
when the wallet switches chains.