When I first joined a blockchain company as an Android developer, I didn’t really know what I would actually do. I didn’t get a clear understanding of how the app would interact with blockchains with such limited hardware resources.
However, having been through several projects, things have been connected. I’m noting this high level architecture of a typical Web3 mobile app for my own references, and for those who are interested in the field.
Disclaimer: The content here is based on my own understanding. It could be misaligned with industry standards.
Overview
Generally, a Web3 wallet app does 3 things:
- It lets users manage wallets. Users can create new wallets, back up existing ones, select what wallet to use for a transaction, etc. Besides, the app must also be able to work with cold wallets (hardware wallets).
- It lets users to interact with blockchains. Users can transfer tokens, interact with smart contracts, deploy their own smart contracts, etc.
- It lets users interact with Dapps (decentralised application). Those Dapps could be implemented as a Web app or a mobile app. Regardless of how they are implemented, they all need wallets to operate. Thus, the wallet app must expose interfaces for those Dapps to retrieve information of wallets.
A typical architecture of a mobile Web3 wallet is as follows.
Let’s understand the basic components on the diagram:
- Chain interactors; briefly, they are nodes in different blockchain networks. Chain interactors do 2 things: aggregate on-chain data and broadcast transactions to blockchain networks.
- Microservices; they act as the middle layer between mobile apps and chain interactors.
- Web3 wallet app; the app collect user inputs such as addresses, transfer amount, gas fee, etc. Then, it prepares the payload and signs that payload with the corresponding key. Finally, it sends the signed payload to chain interactors to broadcast the transaction to the blockchain network.
- Cryptographic SDK; different chains and protocols have different set of parameters and require different signing algorithms. The cryptographic SDK implements those signing algorithms. Companies tend to build their own cryptographic SDK and reuse it across their ecosystem.
- Mobile SDK & JS bridges; as mentioned above, Dapps need to retrieve wallet info and user signature to operate. In order to do that, wallet apps need to expose interfaces that Dapps can invoke. Depending on which platform Dapps operate, those interfaces can be implemented as mobile SDKs or Javascript bridges.
What are the challenges
Just like building any other mobile apps, mobile developers implement convenient UI/UX, reliable networking layer, secure local storage, etc.
So what makes building Web3 wallet apps different? The short answer is the frequent changes.
In blockchain industry, new blockchains, protocols, proposals arise and fade rapidly. What is trending today may become obsolete next week. Each change might require different user inputs, signing algorithms, and even different workflows.
With such drastic changes, it takes a great deal of engineering expertise and management experience to maintain a code base that is robust and flexible enough to adopt changes yet keep up with high product quality and stability.
Closing thought
Building a Web3 wallet app is a unique experience. It requires constant utilisation and cultivation of expertise while keeping one in the loop of cutting-edge technologies.