Skip to content

gconnect/AlgorandPayrollContract

Repository files navigation

Algorand Android Payroll Smart Contract using the Java SDK

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

Demo

BACKIMAGE

Requirements

  • 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

Tools/ Libraries used

Below are some of the important libraries used:

  • Algorand SDK
  • Coroutines
  • Glide
  • Databinding

Setup Development Environment

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.

App Installation Guide

To install the app, here is the link to the apk

File Structure

  • EmployeeAdapter handles the recyclerview for the list of employees
  • constants handles constant variables used in the MainActivity and DetailActivity
  • MainActivity handles the main logic of the application
  • DetailActivity handles the detail page for each employees
  • Employee handles the data model
  • EmployeeDataSource handles dummy data/list of empployees

Teal Program/Smart Contract

 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()

How the app works

After installation..

  • It takes you to the MainActivity. The MainActivity 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

License

Distributed under the MIT License. See for more information. LICENSE

Blog and Video Tutorial

For more details you can checkout the blog post here . And here is the link to the youtube demo

Disclaimer

This project is not audited and should not be used in a production environment.

About

This is an android app developed on the Algorand Blockchain

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages