< Back to articles

Web3: Protocol for Signing Transactions With Mobile Wallet

Our client Golfer Digital asked us to design a solution to connect a Web3 app with a custom mobile wallet (GolferWallet) for their token on Solana. We had 5 man-days and a challenge in front of us – how to make interaction between a Web3 app and a mobile wallet on the Solana blockchain possible?

This is something you can do on Ethereum, but not on the one of the fastest layer 1 blockchain there, Solana. Yes, its seamless and safe transactions with negligible fees are great, not to mention 99.99% less energy consumption than a single Ethereum transaction, however there isn’t a standardized communication protocol yet.

Where's the problem?

Web3 apps usually use a browser extension for authentication and signing arbitrary transactions. You don't always have access to your browser wallet, but you typically have a phone in your pocket. Therefore the natural use case is authentication with a mobile wallet.

In the Web3 ecosystem, the WalletConnect protocol allows seamless communication between a Web3 app and a mobile wallet. Version 2 of the protocol (a release candidate at the time of writing) is chain agnostic and supports the Solana blockchain.

Our solution

Ultimately, we decided to create a custom solution instead of WalletConnect for these reasons:

  • WalletConnect 2 is still a release candidate version,
  • Own solution is more lightweight (we need just a simple communication channel and don't need to support other chains and wallets),
  • Enables customizability (we can add whatever functionality we need and are not limited by the protocol, e.g. sending a push notification to the mobile wallet after an action in the Web 3 app).
  • Users can use any QR code scanner to open the mobile wallet with a custom URL protocol.

How it works

Let's present our example use case of the protocol to demonstrate how it works. We have a web app and a mobile wallet. A user wants to sign a blockchain transaction with his mobile wallet. After successfully authorizing the transaction, the web app displays a success page with the transaction's outcome in real-time.

Technically, we need to (1) transfer the transaction details and a connection ID from the web app to the mobile app, which signs and commits it to a blockchain, while the (2) web app waits for the transaction to be confirmed on the blockchain.

solana communication flow diagram

Direction 1 is straightforward. We show a QR code containing the transaction data in the web app, and the user scans it with the mobile wallet, which prompts a signing dialog with the transaction details. For direction 2, there is a need for an intermediary sending messages to the web (can be bidirectional) based on the connection ID. It can be a message broker or MQTT protocol.

Now that we established a communication channel, all successive transactions can be performed without scanning the QR code again. The web application can send a push notification to the mobile wallet with an action request the user confirms.

solana communication flow diagram II

Communication flow:

  1. The user scans a QR code containing transaction details and a connection ID.
  2. The web app subscribes for data changes under the connection ID to eventually get the transaction signature.
  3. The user signs the transaction, which is published on the blockchain.
  4. The mobile app saves the transaction signature into Firestore under the connection ID.
  5. The web app subscribes to the transaction changes on the blockchain using the signature.

As already stated, we chose Solana blockchain and its web JS and mobile SDKs, which provide all required functionality, including WebSocket connection to the blockchain or generating keypairs in the mobile wallet. We decided to use Firestore as a messaging broker for its simplicity in the proof of concept.

Conclusion

One can object that the solution isn't a plain Web3 architecture as there is a non-blockchain component. From our point of view, this hybrid solution is acceptable as we take the most suitable technology for the problem. Thanks to it, we can now connect a Web3 app with a Solana mobile wallet, which can help the whole Solana ecosystem to be more composable.

Jiří Zdvomka
Jiří Zdvomka
Frontend developerJirka is a web technologies enthusiast. Besides Ackee, he is a founder of peer-to-peer ticket marketplace Swapper and plays Ultimate Frisbee in his spare time.

Are you interested in working together? Let’s discuss it in person!

Get in touch >