Technical Specification
Last updated
Was this helpful?
Last updated
Was this helpful?
袙 协孝袨袦 袪袗袟袛袝袥袝 袧校袞袧袨 袨袩袠小袗孝鞋 孝袝啸袧袠效袝小袣校挟 小孝袨袪袨袧校 袩袪袨袝袣孝袗
The initiator, is the first peer who requests connection (Dapp). Dapp posts an encrypted payload consisting of one-time topic (used for handshake only) and connection request details to the Bridge Server. Then using the WalletConnect Standard URI format (EIP-1328) Dapp assembles together the required parameters to establish the connection: (handshake) topic, bridge (url) and (symmetric) key.
Other query string parameters are all optional.
Establishing Connection
The second peer (Wallet) will read the URI using either a QR Code or a deep link. After reading the URI the peer will immediately receive and decrypt the connection request payload.
The Wallet will then display to the user request details provided by the Dapp. The user will then approve or reject the connection. If rejected, the Dapp will disconnect from the Bridge Server immediately and throw an error message if provided by the Wallet. If approved, the Dapp will receive provided account and chainId from the Wallet.
Once the connection is established, the Dapp will be able to send any JSON-RPC call requests to be handled by the Wallet either to read data from its node or make signing requests for transactions or messages.
Call Requests
Additionally, there is an option from the Wallet side to subscribe for push notifications using a Push Server. This push notification subscription will be registered only when connection request has been approved by the user. This subscription can be customized with varying degrees of privacy. It can either display a generic message, include the name of the peer making the request or even display a localized message. (read Push Notifications sections for more details)
There are various events that happen both internally and across peers. These events are all accompanied by a corresponding payload. The internal events are client-specific but all cross-peer events are JSON-RPC 2.0 complaint.
Internal events include: connect
, disconnect
, session_update
, call_request
. The structure of the internal events are as follows:
Cross-peer events include: wc_sessionRequest
, wc_sessionUpdate
, all Ethereum JSON-RPC requests and eth_signTypedData
(EIP-712)
These events are structured as JSON-RPC 2.0 requests and responses as follows:
The first dispatched JSON RPC request is the connection request including the details of the requesting peers with the following parameters:
The peerId
is the sender's client id, the peerMeta
is the sender's client metadata.
The client metadata is structured as follows:
In browser applications, this is scraped from the loaded webpage's head meta-tags. In native applications, this is provided by the application developer.
The wc_sessionRequest
will expect a response with the following parameters:
This JSON RPC request is dispatched by the Wallet when updating the session. This can occur either when the session is killed by the Wallet, when it provides new accounts or when it changes the active chain id. It has the following parameters:
All payloads are consequently encrypted using the active symmetric key and also signed before they are posted as messages to the Bridge server.
The encryption and signing algorithms used are AES-256-CBC and HMAC-SHA256 respectively. The encryption payloads are structured as follows:
All fields (data, hmac and iv) are hexadecimal strings. The receiving peer will consequently verify the hmac before decrypting the data field using the active key and provided iv.
The communications are all relayed using WebSockets 'stringified' payloads with the following structure:
The Bridge Server acts as pub/sub controller which guarantees published messages are always received by their subscribers.
An example subscription socket message looks as follows:
An example published socket messages looks as follows:
Additionally the Bridge Server will trigger any existing push notifications' subscriptions that listen to any incoming payloads with matching topics.
Push notification subscription is only available for native applications (current libraries only support mobile applications). The Push Server will require a topic, bridge url, type of notification and a token for the notification. The topic will match the client id that will receive the call requests, the bridge url is the one to subscribe to, the type of notification will differ for each mobile platform and the token is used to target the specific mobile device.
Additionally there are also options to provide a peerName of the other peer to customize the notification messages and language code (ISO-639-1) in order to localize push notification message content.
When registering a push notification subscription, Push Server will post a subscription request to the Bridge Server to listen for any incoming payloads matching the provided topic. It will also share a webhook to trigger the push notification.