# Android DApp

## Requirements

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

* A live [ZAct server](https://github.com/nestorbonilla/z-act/tree/master/server).
* A ZCash shielded wallet account, with funds to create events. If you don't have one, please visit this [link](https://z.cash/wallets/).
* A Google Maps [API key](https://developers.google.com/maps/documentation/android-sdk/get-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](https://github.com/nestorbonilla/z-act/blob/master/dapp/app/src/main/java/me/nestorbonilla/zact/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)
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://nestorbonilla.gitbook.io/zact/android-dapp.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
