Android DApp

This is an Android DApp that helps coordinate marches and activism activities under an anonymity layer using geofence validation and zk-SNARK (Zero-Knowledge Succinct Non-Interactive Argument of Knowl

Requirements

To run this app on your mobile end, you will need:

  • A live ZAct server.

  • A ZCash shielded wallet account, with funds to create events. If you don't have one, please visit this link.

  • A Google Maps API key.

ZCash libraries

To interact with the ZCash Blockchain on your Android Dapp, you will need to use install some libraries. For this, let's place this under the graddle app file:

// SDK
zcashmainnetImplementation 'cash.z.ecc.android:sdk-mainnet:1.1.0-beta02'
zcashtestnetImplementation 'cash.z.ecc.android:sdk-testnet:1.1.0-beta02'

// sample mnemonic plugin
implementation 'com.github.zcash:zcash-android-wallet-plugins:1.0.1'
implementation 'cash.z.ecc.android:kotlin-bip39:1.0.0-beta09'

// SDK: grpc
implementation 'io.grpc:grpc-okhttp:1.25.0'
implementation "io.grpc:grpc-android:1.25.0"
implementation 'io.grpc:grpc-protobuf-lite:1.25.0'
implementation 'io.grpc:grpc-stub:1.25.0'
implementation 'javax.annotation:javax.annotation-api:1.3.2'

// SDK: Room
implementation 'androidx.room:room-ktx:2.2.5'
implementation 'androidx.paging:paging-runtime-ktx:2.1.2'
implementation 'com.google.guava:guava:27.0.1-android'
kapt 'androidx.room:room-compiler:2.2.5'

// SDK: Other
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.5'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.5'

Initializers

To connect to the ZCash Blockchain, either with the test or main net, we will need to initialize the connection. To have an accessible way to call it on all the DApp, we created the following two functions on the APP.kt file:

fun onOpenWallet() {
    val initializer = Initializer(this, host = config.host, port = config.port)
    initializer.open(config.newWalletBirthday())
    synchronizer = Synchronizer(initializer)
    synchronizer?.start(appScope)
}

fun onCreateWallet(seedPhrase: String) {
    val initializer = Initializer(this, host = config.host, port = config.port)
    val seed: ByteArray = Mnemonics.MnemonicCode(seedPhrase.toCharArray()).toSeed()
    initializer.new(seed, config.newWalletBirthday())
}

Read transactions

To read a transaction from the Blockchain, once we have an initialized wallet, we can call:

App.instance.onOpenWallet()
App.instance.synchronizer?.status?.collectWith(App.instance.appScope, ::onStatusUpdate)
App.instance.synchronizer?.clearedTransactions?.collectWith(App.instance.appScope, ::onStatusTransaction)

Last updated