This project has been generated using AlgoKit. See below for default getting started instructions.
The simple-donations
smart contract is designed for the Algorand blockchain to facilitate and track charitable donations.
Developed as part of the GiveCup project, this contract allows users to donate to registered organizations and keeps a record of each user's total donations. The contract ensures transparency and security in charitable transactions.
- Donation Tracking: Tracks the total number of donations and the amount donated by each user.
- Organization Management: Allows the contract owner to add organizations that can receive donations.
- User Donation Information: Users can retrieve the total amount they have donated.
Deploy the smart contract on the Algorand network. The deployment will initialize the global state including the donation counter and the owner address.
Only the contract owner can add organizations. This is done through the add_organization
function.
@app.external
def add_organization(organization: abi.Address) -> Expr:
# Function implementation...
- Parameters:
organization
: The address of the organization to be added.
Users can donate to registered organizations using the donate
function.
@app.external
def donate(organization: abi.Address, amount: abi.Uint64) -> Expr:
# Function implementation...
- Parameters:
organization
: The address of the organization to receive the donation.amount
: The amount to be donated.
Users can check their total donated amount using the get_user_donation
function.
@app.external(read_only=True)
def get_user_donation(*, output: abi.Uint64) -> Expr:
# Function implementation...
- Clone this repository locally
- Install pre-requisites:
- Make sure to have Docker installed and running on your machine.
- Install
AlgoKit
- Link: The minimum required version is1.1
. Ensure you can executealgokit --version
and get1.1
or later. - Bootstrap your local environment; run
algokit bootstrap all
within this folder, which will:- Install
Poetry
- Link: The minimum required version is1.2
. Ensure you can executepoetry -V
and get1.2
+ - Run
poetry install
in the root directory, which will set up a.venv
folder with a Python virtual environment and also install all Python dependencies - Copy
.env.template
to.env
- Install
- Run
algokit localnet start
to start a local Algorand network in Docker. If you are using VS Code launch configurations provided by the template, this will be done automatically for you.
- Open the project and start debugging / developing via:
- VS Code
- Open the repository root in VS Code
- Install recommended extensions
- Hit F5 (or whatever you have debug mapped to) and it should start running with breakpoint debugging.
Note If using Windows: Before running for the first time you will need to select the Python Interpreter.
- Open the command palette (Ctrl/Cmd + Shift + P)
- Search for
Python: Select Interpreter
- Select
./.venv/Scripts/python.exe
- JetBrains IDEs (please note, this setup is primarily optimized for PyCharm Community Edition)
- Open the repository root in the IDE
- It should automatically detect it's a Poetry project and set up a Python interpreter and virtual environment.
- Hit Shift+F10|Ctrl+R (or whatever you have debug mapped to) and it should start running with breakpoint debugging. Please note, JetBrains IDEs on Windows have a known bug that in some cases may prevent executing shell scripts as pre-launch tasks, for workarounds refer to JetBrains forums.
- Other
- Open the repository root in your text editor of choice
- In a terminal run
poetry shell
- Run
python -m smart_contracts
through your debugger of choice
- VS Code
- If you update to the latest source code and there are new dependencies you will need to run
algokit bootstrap all
again - Follow step 3 above
For guidance on
smart_contracts
folder and adding new contracts to the project please see README on the respective folder.
This project makes use of Python to build Algorand smart contracts. The following tools are in use:
- Algorand - Layer 1 Blockchain; Developer portal, Why Algorand?
- AlgoKit - One-stop shop tool for developers building on the Algorand network; docs, intro tutorial
- Beaker - Smart contract development framework for PyTeal; docs, examples
- PyTEAL - Python language binding for Algorand smart contracts; docs
- AlgoKit Utils - A set of core Algorand utilities that make it easier to build solutions on Algorand.
- Poetry: Python packaging and dependency management.- Black: A Python code formatter.
- pytest: Automated testing.
- pip-audit: Tool for scanning Python environments for packages with known vulnerabilities. It has also been configured to have a productive dev experience out of the box in VS Code, see the .vscode folder.