This solution will guide you in developing and deploying android application using the Algorand blockchain atomic transfer and smart contract that addresses the following use case:
-
Account creation
-
Funding accounts
-
Create and compile the teal program
-
Atomic transfer signed by the sender
-
Atomic transfer signed by a smart contract
-
Android studio setup
-
Familiarity with the Java and Kotlin programming language and its use within the Android Environment.
-
Basic understanding of some blockchain terminologies.
-
Basic understanding of teal and stateless smart contract
Below are some of the important libraries used:
- Algorand SDK
- Coroutines
- Glide
- Databinding
To get started, your android studio should be up and running. To get the code on your android studio, simply click the clone button to clone the project or download the the project. Then from Android studio click on file and select import to import the project from your local machine.
To successfully run this program, you need to generate/create four different accouts one for the contract owner and the remaining three for the employees. You can create accounts using myalgo.
To install the app, here is the link to the apk
EmployeeAdapter
handles the recyclerview for the list of employeesconstants
handles constant variables used in the MainActivity and DetailActivityMainActivity
handles the main logic of the applicationDetailActivity
handles the detail page for each employeesEmployee
handles the data modelEmployeeDataSource
handles dummy data/list of empployees
val tealSource = """#pragma version 5
// Check the Fee is resonable, In this case 1,000 microalgos
txn Fee
int 1000
<=
//Check that the first group transaction is equal to 2000000
gtxn 0 Amount
int 2000000
==
assert
//Check that the second group transaction is equal to 1000000
gtxn 1 Amount
int 1000000
==
assert
//Check that the third group transaction is equal to 2000000
gtxn 2 Amount
int 2000000
==
assert
//Check that the transaction amount is less than 5000000 or equal to 5000000
txn Amount
int 5000000
<=
assert
//Check the number of transactions in this atomic transaction group
global GroupSize
int 3
==
assert
//CloseRemainderTo should be the intended recipient or equal to global ZeroAddress.
txn CloseRemainderTo
global ZeroAddress
==
assert
//This check to prevent the transaction from been assigned to a new private key.
txn RekeyTo
global ZeroAddress
==
assert
""".trimIndent()
After installation..
- It takes you to the
MainActivity
. TheMainActivity
contains a list of employees, two fabs and two buttons - The
green fab
enables you to fund the contract/senders account - The
purple fab
enables you to copy the contract/senders address - The explore button takes you to the algoexplorer page
- The
pay employees
button calls the atomic transfer method to send algo to the employees either using the smart contract logic sig option or the sender option
Distributed under the MIT License. See for more information. LICENSE
For more details you can checkout the blog post here . And here is the link to the youtube demo
This project is not audited and should not be used in a production environment.