Building Mobile Apps on Solana

A Technical Deep Dive

ยท

14 min read

Building Mobile Apps on Solana

Hi there ๐Ÿ‘‹

So you are here. Maybe you were scrolling around the internet to learn more about the Solana Mobile Stack. Or you came here from my profile on some social media. Or you simply came here from some of my other blogs on Solana.

In every case, if your intent is to learn more about Solana Mobile Stack or you have the question "How to build mobile apps on Solana?", you are at the right place. ๐Ÿฅ

This blog will give you a comprehensive overview of building on Solana Mobile Stack, Solana Saga Phone, SDKs, and toolings available to make your work significantly easier. The best way to learn from this blog is to give a quick but careful read to grasp the concepts presented here and then implement everything step by step and create your project. Some words are highlighted and you can check the articles by clicking on them if you want more information about those topics.

Have your favorite brew โ˜•๏ธ by your side and let's get started!

Solana Mobile Stack (SMS)

The first thing that we will learn about is the Solana Mobile Stack.

The Solana Mobile Stack (SMS) is a collection of key technologies for building mobile applications that can interact with the Solana blockchain.

The SDK provides enabling libraries for wallets and apps, allowing developers to create rich mobile experiences for the Solana network.

The SMS provides a straightforward and powerful platform for developers to build mobile-native dApps, offering features such as instant notifications, camera interactions, sensor integration, and GPS location services, all within a secure and seamless user experience

The key elements of the Solana Mobile Stack include:

  1. Mobile Wallet Adapter (MWA)

  2. Seed Vault

  3. Solana dApp Store

  4. Solana Pay

Mobile Wallet Adapter (MWA)

Mobile Wallet Adapter (MWA) is a protocol specification for connecting mobile dApps to mobile Wallet Apps, enabling communication for Solana transactions and message signing.

Did it go over your head? ๐Ÿคจ

Let's break it down.๐Ÿค

Mobile Wallet Adapter (MWA) is like a universal language for mobile apps to talk to mobile Wallet Apps. It lets them chat and work together smoothly, especially for handling Solana transactions and messages.

Now since you are reading this blog, I assume you want to build an awesome mobile app on Solana, someday. With MWA, you don't have to worry about making your app speak different languages for each wallet out there. Instead, you integrate MWA once, and your app can then connect and work with any compatible MWA Wallet App.

What are compatible MWA Wallet Apps?

All your popular Solana wallet apps like Phantom, solflare, Expresso Cash, etc are compatible with a Mobile Wallet Adapter. A regularly updated list can be found on this link.

This is super handy because it saves you tons of time and effort. You don't need to reinvent the wheel for every wallet. Plus, it makes life easier for users too, as they can use their favorite wallet with your app hassle-free.

Currently, it supports the following platforms:

(The image has been directly taken from the official Solana mobile docs for illustration purposes.)

To use and learn more about the Mobile Wallet Adapter, you can refer to the official documentation.

Some other good detailed blogs and resources to build on the MWA SDK are mentioned in the "Integration of SMS with popular frameworks" section of this blog.

Seed Vault

Imagine the Seed Vault as your app's personal guardian, keeping your keys and secrets safe and sound. It's like having a super-secure vault right on your mobile device!

Here's how it works: The Seed Vault teams up with the most secure parts of your device, like special processor modes and extra-guarded sections. It takes your secrets and stashes them away in this ultra-safe environment. And guess what? Your keys and seeds never leave this secure zone, so you can breathe easy knowing they're locked up tight.

Now, here's the cool part: Your users get a smooth, secure experience. They can sign transactions with confidence, knowing that everything's protected behind the scenes. ๐ŸŒŸ

For dApps

The Seed Vault SDK is designed for usage by wallet apps. If you are building a mobile dApp, you should just use Mobile Wallet Adapter for your usecase.

For Wallet Appsโ€‹

To integrate and provide Seed Vault custody in a wallet app, follow the integration guide for a deep dive into the SDK. The repo includes a Seed vault simulator, which can be used to simulate and test for Saga Seed Vault integration on emulators.

Solana dApp Store

As the name suggests, this is an alternate app distribution system, for Solana developers. Your Google Play Store and App Store have a lot of rules, restrictions, and policies for launching apps on their platform. They take large revenue shares from the apps on their platforms. This limits the developers and teams both in terms of income generated from their applications and relationships with their users.

Moreover, while the Google Play Store and the App Store are centralized platforms managed by large corporations, the Solana dApp Store aims to decentralize app distribution. It empowers the Solana community to actively participate in managing the contents of the store, making it a more community-driven platform.

The only catch is that the Solana dApp Store is currently available only on the Saga phone. Solana Saga is a new mobile phone created by Solana in collaboration with Osom. It is a smartphone designed for the Web3 era, focusing on crypto & dApps with secure hardware like Seed Vault. (More on this later in the blog.)

To learn more about solana dApp store, please read this.

Solana Pay

Solana Pay is this cool protocol that lets developers like you seamlessly integrate decentralized payments into your apps and services. And guess what? It's super easy to get started!

By using Solana Pay, your app can accept payments in SOL or any SPL token directly, without any middlemen getting in the way. With Solana Pay, users get a seamless experience, and transactions are confirmed in less than a second โ€“ talk about lightning-fast! โšก๏ธ

With Solana Pay, you can integrate payment links, pay now buttons, or QR codes into your app, dApp, website, or blog, making it simple for users to pay and businesses to accept payments.

A reference implementation for Solana pay can be found here.

Since we have covered all the elements of the Solana mobile stack, let's start building. ๐Ÿ’ช

Pre-requisites and Development setup

If you have been doing mobile development, you can skip this section. The only additional stuff is following the installation of a wallet (4th point) for solana development. If it's your first time creating and deploying a mobile app, follow the installation links mentioned below and you are good to go. ๐Ÿ˜

  1. Install Android Studio or Visual Studio Code or any other IDE of your choice that supports mobile development.

    You can also work in a cloud environment like Github codespaces, provided you are familiar with how to connect an emulator with codespaces.

  2. Set up Hardware Device or Emulator on the IDE of your choice.

  3. Set up your environment for the framework you want to work with. So your choice could be any of the following: Flutter, React Native, Kotlin, Unity, Unreal Engine .

    So you can use any popular cross-platform or native android specific framework of your choice to build solana mobile apps.

    There are several blockers for developing Solana mobile apps on iOS.
    First, the Mobile Wallet Adapter protocol is not supported on iOS due to technical limitations of the operating system. In addition to this, the Apple App Store has a more restrictive policy against web3/crypto apps.

    For now, the current recommendation for iOS is to create a mobile web app, that is โ€” a web app designed/optimized for mobile browsers.

  4. Install a wallet app. The Mobile Wallet Adapter(MWA) library allows your dApp to connect and interface with Wallet Apps that implement the MWA protocol. For testing, you want to have an MWA-compatible wallet on the same device or emulator as your dApp.

    Download, build, and install fakewallet: The fakewalletapp is a 'fake' Mobile Wallet Adapter compliant wallet. Install it on your Android emulator or device. It does not store persistent keypairs, and the wallet is "reset" each time the app is exited.

    Installation steps:

    1. Clone the Mobile Wallet Adapter repo, containing the fakewallet app from the github repository
    git clone https://github.com/solana-mobile/mobile-wallet-adapter.git
  1. In Android Studio, Open project > Navigate to the cloned directory > Select mobile-wallet-adapter/android/build.gradle

  2. After Android Studio finishes loading the project, select fakewallet in the build/run configuration dropdown in the top right.

fakewallet build

After it builds successfully, you should see the app on your Android device or emulator.

Install real wallet appsโ€‹

fakewallet was created for implementation reference and quick testing purposes. You should also test your dApp with popular MWA-compatible wallet apps like Phantom, Solflare, and Ultimate.

You can install these onto an emulator by using an emulator with Google Play Store support. From there, you can log in to your Google account and search for Phantom or Solflare to install it onto the emulator.

Solana Mobile Stack supports building on all major mobile frameworks and languages including:

  1. React Native: To get started with the React Native SDK of SMS, the best place to start learning is from the official docs and resources prepared by the Solana mobile team.
    The docs contain a mobile NFT minter tutorial and a template mobile app integrating features like signing transactions, airdrops, integrating Mobile wallet adapter, etc. This will give you the best headstart you can get to integrate elements of the Solana mobile stack like the Mobile Wallet Adapter. These resources will directly help you integrate MWA into your React native app.

    To use the Seed Vault SDK of the Solana mobile stack, there is no direct integration with the React native app. The Seed Vault SDK is written in Kotlin and needs significant implementation for React Native.

    You can launch apps written in any framework on the Solana dapp store using the publishing guidelines.

    Solana Pay has a TypeScript implementation so can be used quite directly with a React Native app.

  2. Kotlin:
    For the Kotlin SDK, again the official documentation serves as the best resource for getting a headstart. This developer tutorial by Anam Ansari will walk you through an example dapp that works using the Kotlin SDK of SMS and integrates a Mobile Wallet Adapter in a Kotlin application.

    Another very good example is the Minty Fresh project. Minty Fresh is a multi-module app written 100% in Kotlin, that can be deployed and used to mint nfts. It has an extensive usage of Mobile Wallet Adapter and would help you gather a lot of insights into the usage of mobile wallet adapter with Kotlin.

    Seed Vault SDK is primarily written keeping Java and Kotlin in mind so implementation is easier than that for React Native.
    This and other factors make Kotlin, the best framework to build Solana dapps using the Solana Mobile Stack.

    (Source: Minty fresh project)

  3. Flutter: The Solana Mobile officially has SDKs only for Kotlin and React Native. All other SDKs are maintained and supported by community members. So certain areas are still in active development.

    The Solana Mobile Flutter SDK is maintained by the Expresso Cash team.

    The team has worked awesomely to bring both the Mobile Wallet Adapter (MWA) and Seed Vault SDKs to Flutter. The GitHub repo contains a fake dApp example.

    To start building on Flutter you should check out my earlier blog on integrating SMS into Flutter dAPPs. It contains an example dApp for your reference and I am constantly improving the blog.

    This blog by Raunak is also great and will help you in building a full-blown dapp using Solana Mobile Stack and Flutter.

    You can use the Solana Pay dart package to integrate Solana Pay into your dapp.

  4. Unity:
    The Unity SDK is unofficially maintained by the community.๐Ÿง‘โ€๐Ÿ’ป
    The Solana Unity SDK is an open-source community-led project that enables Solana NFT support and RPC functionality for Unity games and projects. If you are a game developer looking to incorporate web3 features using the Solana blockchain, check out the Solana.Unity-SDK.

    The SDK has elaborative docs to help you get started with building games on Solana. It also has well-detailed docs to integrate the Mobile wallet adapter of the SMS.

    The Seed Vault integration with Unity is still under active development.

    To work with Unity and Solana, you can find a lot of regularly used implementations in the guides section of the docs, and a lot of additional examples can be found in this GitHub repo.

  5. Unreal Engine:
    The solana-saga-unreal-sdk is an open-source Unreal Engine plugin that integrates with the Solana Mobile Stack to provide features like wallet signing. It is a community-developed SDK, maintained unofficially by the CaveWorld team.

    Currently, the status of the SDK is still in the pre-release stage and in development.

    The SDK includes:

  6. Solana KMP: Solana KMP is a Kotlin Multiplatform library that can be used on both Android (Java/Kotlin) and iOS (obj-C/swift).

    Metaplex Foundation's KMP SDK for Solana will serve as the best resource to help you get started with Solana KMP.

Other tools and community projects

Some other community projects and toolings that will help to build mobile dApps on Solana:

  1. Saganize: Saganize's Kotlin SDK enables in-app transactions for Solana Mobile dApps, allowing users to interact with transactions within their app, without the need to build a separate wallet infrastructure.

  2. CandyPay: CandyPay is a payment processing platform for merchants, providing a fast and secure way to accept cryptocurrency payments on Solana.

  3. Sollinked: Sollinked is the Mail, Calendar, and GitHub Platform built on Solana. Users can create @sollinked.com emails, schedule appointments through our Calendar feature, and manage GitHub issues all in one place.

  4. Solana Gaming SDKs: The Solana Gaming SDKs are a set of software development kits (SDKs) that enable game developers to build and deploy games on the Solana blockchain. The Solana Mobile Stack provides various SDKs for game development, including Unity and Unreal Engine, which allow developers to create immersive and interactive experiences on the Solana network

Saga Phone and Solana Mobile Stack

Building on the Solana Mobile Stack can be done with or without the Saga phone. The Saga phone provides additional security features, such as the integrated Secure Element for seed storage and instant transaction approval. However, building on SMS is not limited to the Saga phone and can be done using standard Android devices. The key difference lies in the enhanced security and user experience offered by the Saga phone for Solana-based mobile applications.

(Source: How to use Solana Saga to buy and sell crypto )

Building on SMS: Saga vs. No Saga

SAGA Phone

Here's a comparison of building on the Solana Mobile Stack (SMS) with and without the Saga phone:

With Saga Phone:

  • Seamless dApp integration: Built-in Seed Vault hardware securely stores private keys, enabling smooth interaction with dApps. No need for additional hardware wallets.

  • Dedicated user base: Targets crypto and Web3 enthusiasts, providing access to a niche but engaged audience for your dApp.

  • Optimized experience: Hardware and software designed specifically for SMS, potentially leading to better performance and smoother user experience for dApps.

  • Limited reach: Smaller user base compared to regular Android phones, potentially restricting your dApp's reach.

  • Dependence on proprietary hardware: Locks developers into the Saga ecosystem, limiting potential user base.

Without Saga Phone:

  • Wider reach: Reaches a larger user base across regular Android phones.

  • Hardware agnostic: Works with existing hardware, reducing development complexity and entry barrier for users.

  • Independent development: More autonomy in dApp design and user experience.

  • Potential user friction: Requires additional setup with external hardware wallets, possibly impacting user adoption.

  • Less optimized experience: Might experience performance limitations or compatibility issues on diverse Android devices.

Overall:

  • Saga benefits: Secure, seamless dApp experience, targeted user base, potential performance/UX optimization.

  • Saga drawbacks: Limited reach, hardware dependence, smaller user base.

  • No Saga benefits: Wider reach, hardware agnostic, independent development.

  • No Saga drawbacks: Potential user friction, less optimized experience.

Conclusion

The Solana Mobile Stack (SMS) provides a robust framework for building mobile applications on the Solana blockchain. With components like the Mobile Wallet Adapter (MWA), Seed Vault, Solana dApp Store, and Solana Pay, developers have the tools to create secure, seamless experiences for users.

Whether leveraging the enhanced capabilities of the Saga phone or targeting a broader audience with regular Android devices, the SMS empowers developers to innovate and contribute to the growing Solana ecosystem.

As you embark on your Solana mobile development journey, embrace learning, experimentation, and community engagement. With the SMS as your guide, you're equipped to create transformative mobile experiences in the world of decentralized finance and blockchain technology. Happy coding! ๐Ÿš€๐Ÿ“ฑ

References and other helpful resources

Apart from the references and links given above, the following served as a source of inspiration for this blog post:

  1. Solana Mobile Stack docs

  2. Deep Dive : Solana Mobile Stack & Saga

  3. Solana Mobile

  4. Join Solana Mobile Discord

  5. https://solana.stackexchange.com/

  6. https://github.com/solana-mobile

  7. https://twitter.com/solanamobile

  8. https://www.linkedin.com/pulse/intro-solana-mobile-stack-5-essential-aspects-understand

  9. https://zerocap.com/insights/snippets/solana-mobile-saga-phone/

  10. https://www.reddit.com/r/solana/comments/11ydpri/solana_mobile_stack_sms_is_now_officially/

  11. https://solanacompass.com/learn/breakpoint-23/breakpoint-2023-solana-mobile-evolving-the-tech-stack

  12. A very good resource to learn more about Solana Mobile: https://www.soldev.app/course/intro-to-solana-mobile

ย