Original title: “Understand WalletConnect in One Article”
- What can WalletConnect do
- Market support of WalletConnect
- How WalletConnect messaging works
- How to ensure WalletConnect message security
- How WalletConnect can quickly access push
01 What can WalletConnect do
It is a basic communication facility that establishes connections based on two-dimensional codes. You can build various interactions based on it, and its default interaction protocol is the interaction with Ethereum. Of course, you can also do all kinds of things you can imagine, not just for Dapp communication interaction. If you change the default Ethereum protocol, it also means that you will be disconnected from other WalletConnect wallets and Dapps. compatible.
Now there are many Dapp applications for large screens such as computers. Before WalletConnect appeared, Chrome plug-ins or desktop wallets had to be used to authorize operations, which made the operation and usage habits of users who originally used mobile wallets appear to be fragmented. You also need to download the plug-in or wallet separately, and then import the private key, which is very troublesome.
02 Market support of WalletConnect
Recently, the more common wallets are supporting, such as:
- Wheat wallet
- Trust Wallet
03 The working principle of WalletConnect message communication
// WalletConnect establishes the connection principle
Topic term explanation: The text means “topic”. In WalletConnect, the wallet side and the Dapp side each have a Topic topic, which can be subscribed by the other party, thus forming a channel that can communicate with each other.
- The Dapp side establishes a Socket connection with the relay server;
- The Dapp terminal generates Dapp ClientID (monitoring the topic will get the message sent to the Dapp), Dapp Topic (monitoring the topic will get the login request sent by the Dapp), and subscribe to the Dapp ClientID;
- The Dapp side sends the information that the Topic is the Dapp Topic to the relay server, and carries the Dapp ClientID information;
- The two-dimensional code displayed on the Dapp side contains Dapp Topic information, the address of the relay server, and the password;
- The wallet side scans the two-dimensional code on the Dapp side, and parses out the two-dimensional code information to obtain the Dapp Topic, relay server address, and password;
- The wallet side establishes a socket connection with the relay server, and then generates a Wallet PeerID (monitoring the topic to get the message sent to the wallet side), and subscribes to Dapp Topic and Wallet PeerID;
- Next, the wallet side will receive the Dapp login request forwarded by the relay server;
- The wallet side processes whether to approve the login of Dapp, sends a message with Topic being Dapp ClientID, and transmits back the processing result and Wallet PeerID information;
- At this point, the connection is successfully established. If the “Dapp” wants to send a message to the “Wallet”, then send the message that the Topic is Wallet PeerID;
- If the “wallet” wants to send a message to “Dapp”, just send the message that Topic is Dapp ClientID.
Topic on the wallet side and Topic on the Dapp side together form the Session. The Session life cycle of WalletConnect is the life cycle of the connection established between the Dapp and the wallet. WebSocket is just its “communication tool”. The disconnection of WebSocket does not mean that the connection with the wallet is disconnected.
04 The working principle of WalletConnect communication
- WalletConnect is just a set of communication protocols, any information can be communicated in two ways;
- By default, WalletConnect supports push services through WebHook. You can notify users to process information when the mobile app is not opened;
- If one party A disconnects the Socket connection, the message sent by the other party B will be temporarily stored in the relay service. The next time A establishes a Socket connection with the relay server and subscribes to the related topic, the relay service will be temporarily stored. The saved message is sent to A.
05 How to ensure WalletConnect message security
- Use AES-256 symmetric encryption to encrypt communication information, and HMAC-SHA256 for Hash signature;
- The two-dimensional code generated by the Dapp terminal contains a symmetrically encrypted password. The mobile terminal scans the two-dimensional code to obtain the password, so the Dapp two-dimensional code will not be transmitted over the Internet.
06 How WalletConnect can quickly access push notifications
//The underlying technology WebHook
- WebHook is a kind of HTTP callback: HTTP POST request triggered under certain conditions;
- The Relay Service of WalletConnect also has this API interface that accepts WebHook URL;
- WalletConnect provides Firebase push service separately.
- The message receiver sends a URL and the desired message to the message sender;
- When the message sender reaches a certain condition, it will call the URL of the message receiver to notify the message receiver to receive the message.
//WalletConnect push usage process
- The mobile terminal receives the login request from the Dapp. If the mobile terminal agrees to the login request, it can use the Topic Dapp ClientID and Firebase ID to subscribe to the “Push Service”;
- “Push Service” will continue to send WebHook to “Relay Service” after receiving Topic to subscribe to Topic;
- If the “relay server” finds that the topic subscribed by the “push service” has information, it will notify the “push service”;
- “Push Service” finds the fitbase ID of the relevant topic subscribed to and initiates the push.
WalletConnect is an open protocol that connects desktop DApps to mobile devices by scanning QR codes using end-to-end encryption technology. It opened up the entire world of DApps that were once only available for Metamask wallets. Users can interact with any DApp without compromising the security of their private keys, and can receive notifications on their mobile devices to sign and agree to any transaction requests.
Posted by:CoinYuppie，Reprinted with attribution to:https://coinyuppie.com/who-opened-the-defi-world-that-was-once-only-available-with-metamask-wallet-understand-the-working-principle-of-wallet-connect-in-one-article/
Coinyuppie is an open information publishing platform, all information provided is not related to the views and positions of coinyuppie, and does not constitute any investment and financial advice. Users are expected to carefully screen and prevent risks.