zcash-android-wallet-sdk/demo-app
Honza Rychnovský ce612ab12d
[#1471] Add new LWD servers to Demo app
Closes #1471
2024-04-30 08:40:03 +02:00
..
assets [#255] Refactor Gradle Modules 2021-08-31 14:53:25 -04:00
src [#1471] Add new LWD servers to Demo app 2024-04-30 08:40:03 +02:00
README.md [#255] Refactor Gradle Modules 2021-08-31 14:53:25 -04:00
build.gradle.kts [#1170] Regular transaction flow emitting 2023-09-08 20:19:51 +02:00
lint-baseline.xml [#343] Store database files in no_backup folder 2022-08-12 11:05:00 -04:00
proguard-project.txt [#921] AGP 8.0.2 2023-06-09 15:18:11 +02:00

README.md

Android demo app

This is a demo app that exercises code in https://github.com/zcash/zcash-android-wallet-sdk, which has all the Android-related functionalities necessary to build a mobile Zcash shielded wallet.

It relies on Lightwalletd, a backend service that provides a bandwidth-efficient interface to the Zcash blockchain. There is an equivalent iOS demo app.

Contents

Requirements

The demo app is built in Kotlin, and targets API 21. The demo pulls the pre-built SDK from jcenter so, unlike the SDK, it does not require Rust or the NDK!

Back to contents

Installation

In short, you simply will need to:

  1. (pre-requisite) Install Android Studio and setup an emulator or device
  2. Clone this repo: https://github.com/zcash/zcash-android-wallet-sdk
  3. Open the demo-app folder in Android Studio and launch the app
    (recommended build variant: zcashmainnetDebug)

Back to contents

Exploring the demo app

After building the app, the emulator should launch with a basic app that exercises the SDK (see picture below). To explore the app, click on each menu item, in order, and also look at the associated code.

The android demo app, running in Android Studio

The demo app is not trying to show what's possible, but to present how to accomplish the building blocks of wallet functionality in a simple way in code. It is comprised of the following self-contained demos. All data is reset between demos in order to keep the behavior repeatable and independent of state.

Demos

Menu Item Related Code Description
Get Private Key GetPrivateKeyFragment.kt Given a seed, display its viewing key and spending key
Get Address GetAddressFragment.kt Given a seed, display its z-addr
Get Balance GetBalanceFragment.kt Display the balance
Get Latest Height GetLatestHeightFragment.kt Given a lightwalletd server, retrieve the latest block height
Get Block GetBlockFragment.kt Given a lightwalletd server, retrieve a compact block
Get Block Range GetBlockRangeFragment.kt Given a lightwalletd server, retrieve a range of compact blocks
List Transactions ListTransactionsFragment.kt Given a seed, list all related shielded transactions
Send SendFragment.kt Send and monitor a transaction, the most complex demo

Back to contents

Getting started

Were assuming you already have a brilliant app idea, a vision for the apps UI, and know the ins and outs of the Android lifecycle. Well just stick to the Zcash app part of “getting started.”

Similarly, the best way to build a functioning Zcash shielded app is to implement the functionalities that are listed in the demo app, in roughly that order:

  1. Generate and safely store your private key.
  2. Get the associated address, and display it to the user on a receive screen. You may also want to generate a QR code from this address.
  3. Make sure your app can talk to the lightwalletd server and check by asking for the latest height, and verify that its current with the Zcash network.
  4. Try interacting with lightwalletd by fetching a block and processing it. Then try fetching a range of blocks, which is much more efficient.
  5. Now that you have the blocks process them and list transactions that send to or are from that wallet, to calculate your balance.
  6. With a current balance (and funds, of course), send a transaction and monitor its transaction status and update the UI with the results.

Back to contents

Resources

You dont need to do it all on your own.

Back to contents