Getting started as an De-centralized mobile app development [ Using ethereum blockchain]

Mobile app development is already crazy with different platforms to take care i.e Android, iOS. In Android itself lot of fragmentation for diff O.S types. On top of this now there is another layer of confusion, how to handle crypto currency and writing mobile apps which are de-centralized.

Required DApp Architecture

The DApp should be taking directly with the ethereum blockchain without any middleware component or managed server. This is the only way to achieve true decentralization.

The Framework or the lib should provide wallet services so that contracts can be executed directly with user deposited ethers. The wallet should be locally saved, encrypted and provide security features.

Various possible architectures/solutions explained below for mobile app development

MetaMask

Metamask.io provides chrome extension for users to connect to ETH blockchain. The wallet is encrypted and saved locally within the browser. While this is great option to build apps on Web3 JS interface, metamask or mobile platform eco-systems does not provides local wallet support. While lot of projects using this option to develop the web app but it’s not a great option to target mobile platforms for production Dapps.

Toshi App

Toshi (www.toshi.org) is framework and service provided by coinbase.

Toshi Architecture
  • Toshi provides iOS and Android apps with local encrypted wallet support, so it meets that requirement
  • Toshi provides browser kind of support so apps can be developed and run on top of toshi platform
  • As seen from the above toshi architecture, there is no direct communication with the ethereum blockchain for DApps, toshi provides backend services which in turn communicates with the ethereum blockchain. Even though toshi is open source and backed by coinbase, this makes toshi as not completely de-centralized. What if user looses some coins due to fraud or toshi service goes out of order etc etc.
  • Another option is to host these backend services at your own data center or cloud and customize toshi mobile apps as your mobile DApp. This way your in control of the security and end user experience rather than depending on 3rd party hosted service.

Status

Status.im developed Status Android and iOS apps which supports both the requirements i.e wallet and decentralized eco-system. If your DApp is simple and it does’t require a listing in the android or iOS app stores then it would be easier to be listed within Status as a web app. Status provides standard Web3.js interface to interact with the Ethereum blockchain on top of android/iOS webviews. This way you can develop app using standard metamask and other tools and directly integrate with Status app without worrying about de-centralization, storage, encryption, wallet support.

If you want to develop and publish an android and iOS app store DApps then I suggest developing a cross platform app using React Native or clojurescript, basically modifying the status app for you needs. Status team has done tons of work to make it cross platform and decentralized.

Status under the hood

The main status repo is https://github.com/status-im/status-react which is an integrated android/ios app. This is main react native application written in Clojurescript, Java & Objective C

The go-ethereum lib is the main library responsible for providing direct access to the ethereum blockchain. The repo is located here https://github.com/status-im/go-ethereum

The status binding’s for go-ethereum lib is provided through status-go here https://github.com/status-im/status-go. For Android JNI is used as Golang -> C -> JNI -> Java App

For Android Status pulls the .so from http://139.162.11.12:8081/artifactory/libs-release-local/, check the gradle https://github.com/status-im/status-react/blob/develop/android/build.gradle

Android lib’s loaded as part of the StatusPackage are statusgoraw and statusgo, here https://github.com/status-im/status-react/blob/develop/modules/react-native-status/android/src/main/java/im/status/ethereum/module/StatusPackage.java

Java React method @ReactMethod public void startNode needs to be executed so that Ethereum node starts running as part of the Android application. Here it’s located

https://github.com/status-im/status-react/blob/develop/modules/react-native-status/android/src/main/java/im/status/ethereum/module/StatusModule.java

It’s not straight forward to call this function as this is designed to be cross platform using React native and Clojurescript.

Here is the core files and initialize functions defined for android and ios respectively https://github.com/status-im/status-react/blob/develop/src/status_im/android/core.cljs and

The init[] function defined is the main entry point for the app. This calls init-jail and initialize-app. Initialize-app is defined in https://github.com/status-im/status-react/blob/develop/src/status_im/ui/screens/events.cljs. This is where all the DB init, loading accounts, crypto initialization, geth (initialize-geth)is being done.

init-jail is defined @https://github.com/status-im/status-react/blob/develop/src/status_im/native_module/core.cljs

initialize-geth-fx is the function where node is started. This is located @ https://github.com/status-im/status-react/blob/develop/src/status_im/ui/screens/events.cljs

Status build will take care of creating index.android.js and index.ios.js , https://github.com/status-im/status-go/wiki/Build-Process-Explained

Conculsion

Depending on the DApp and complexity, various options can be used to develop mobile version. Simplest being deploying using Status or toshi app frameworks. If the application is complex and needs dedicated app store listings with lot of native components then Status can be used and modified to make a new DApp