This project has been generated using AlgoKit. See below for default getting started instructions.
- Python 3.12 or later
- Docker (only required for LocalNet)
For interactive tour over the codebase, download vsls-contrib.codetour extension for VS Code, then open the
.codetour.json
file in code tour extension.
Start by cloning this repository to your local machine.
Ensure the following pre-requisites are installed and properly configured:
- Docker: Required for running a local Algorand network. Install Docker.
- AlgoKit CLI: Essential for project setup and operations. Install the latest version from AlgoKit CLI Installation Guide. Verify installation with
algokit --version
, expecting2.0.0
or later.
Run the following commands within the project folder:
- Install Poetry: Required for Python dependency management. Installation Guide. Verify with
poetry -V
to see version1.2
+. - Setup Project: Execute
algokit project bootstrap all
to:- Install dependencies and setup a Python virtual environment in
.venv
. - Copy
.env.template
to.env
.
- Install dependencies and setup a Python virtual environment in
- Start LocalNet: Use
algokit localnet start
to initiate a local Algorand network.
Directly manage and interact with your project using AlgoKit commands:
- Build Contracts:
algokit project run build
compiles all smart contracts. - Deploy: Use
algokit project deploy localnet
to deploy contracts to the local network.
For a seamless experience with breakpoint debugging and other features:
- Open Project: In VS Code, open the repository root.
- Install Extensions: Follow prompts to install recommended extensions.
- Debugging:
- Use
F5
to start debugging. - Windows Users: Select the Python interpreter at
./.venv/Scripts/python.exe
viaCtrl/Cmd + Shift + P
>Python: Select Interpreter
before the first run.
- Use
While primarily optimized for VS Code, JetBrains IDEs are supported:
- Open Project: In your JetBrains IDE, open the repository root.
- Automatic Setup: The IDE should configure the Python interpreter and virtual environment.
- Debugging: Use
Shift+F10
orCtrl+R
to start debugging. Note: Windows users may encounter issues with pre-launch tasks due to a known bug. See JetBrains forums for workarounds.
This project supports both standalone and monorepo setups through AlgoKit workspaces. Leverage algokit project run
commands for efficient monorepo project orchestration and management across multiple projects within a workspace.
For guidance on
smart_contracts
folder and adding new contracts to the project please see README on the respective folder.### Continuous Integration / Continuous Deployment (CI/CD)
This project uses GitHub Actions to define CI/CD workflows, which are located in the .github/workflows folder.
Please note, if you instantiated the project with --workspace flag in
algokit init
it will automatically attempt to move the contents of the.github
folder to the root of the workspace.
To define custom algokit project run
commands refer to documentation. This allows orchestration of commands spanning across multiple projects within an algokit workspace based project (monorepo).
This project is optimized to work with AlgoKit AVM Debugger extension. To activate it:
Refer to the commented header in the __main__.py
file in the smart_contracts
folder.
If you have opted in to include VSCode launch configurations in your project, you can also use the Debug TEAL via AlgoKit AVM Debugger
launch configuration to interactively select an available trace file and launch the debug session for your smart contract.
For information on using and setting up the AlgoKit AVM Debugger
VSCode extension refer here. To install the extension from the VSCode Marketplace, use the following link: AlgoKit AVM Debugger extension.
- Every time you have a change to your smart contract, and when you first initialize the project you need to build the contract and then commit the
smart_contracts/artifacts
folder so the output stability tests pass - Decide what values you want to use for the
allow_update
,allow_delete
and theon_schema_break
,on_update
parameters specified incontract.py
. When deploying to LocalNet these values are both set to allow update and replacement of the app for convenience. But for non-LocalNet networks the defaults are more conservative. These default values will allow the smart contract to be deployed initially, but will not allow the app to be updated or deleted if is changed and the build will instead fail. To help you decide it may be helpful to read the AlgoKit Utils app deployment documentation or the AlgoKit smart contract deployment architecture. - Create a Github Environment named
Test
. Note: If you have a private repository and don't have GitHub Enterprise then Environments won't work and you'll need to convert the GitHub Action to use a different approach. Ignore this step if you pickedStarter
preset. - Create or obtain a mnemonic for an Algorand account for use on TestNet to deploy apps, referred to as the
DEPLOYER
account. - Store the mnemonic as a secret
DEPLOYER_MNEMONIC
in the Test environment created in step 3. - The account used to deploy the smart contract will require enough funds to create the app, and also fund it. There are two approaches available here:
- Either, ensure the account is funded outside of CI/CD. In Testnet, funds can be obtained by using the Algorand TestNet dispenser and we recommend provisioning 50 ALGOs.
- Or, fund the account as part of the CI/CD process by using a
DISPENSER_MNEMONIC
GitHub Environment secret to point to a separateDISPENSER
account that you maintain ALGOs in (similarly, you need to provision ALGOs into this account using the TestNet dispenser).
For pull requests and pushes to main
branch against this repository the following checks are automatically performed by GitHub Actions:
- Python dependencies are audited using pip-audit
- Code formatting is checked using Black
- Linting is checked using Ruff
- Types are checked using mypy
- Python tests are executed using pytest
- Smart contract artifacts are built
- Smart contract artifacts are checked for output stability
- Smart contract is deployed to a AlgoKit LocalNet instance
For pushes to main
branch, after the above checks pass, the following deployment actions are performed:
- The smart contract(s) are deployed to TestNet using AlgoNode.
Please note deployment is also performed via
algokit deploy
command which can be invoked both via CI as seen on this project, or locally. For more information on how to usealgokit deploy
please see AlgoKit documentation.
This project makes use of Algorand 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
-
Algorand Python - A semantically and syntactically compatible, typed Python language that works with standard Python tooling and allows you to express smart contracts (apps) and smart signatures (logic signatures) for deployment on the Algorand Virtual Machine (AVM); docs, examples
-
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.- Ruff: An extremely fast Python linter.
-
mypy: Static type checker.
-
pytest: Automated testing.
-
pip-audit: Tool for scanning Python environments for packages with known vulnerabilities.
-
pre-commit: A framework for managing and maintaining multi-language pre-commit hooks, to enable pre-commit you need to run
pre-commit install
in the root of the repository. This will install the pre-commit hooks and run them against modified files when committing. If any of the hooks fail, the commit will be aborted. To run the hooks on all files, usepre-commit run --all-files
. It has also been configured to have a productive dev experience out of the box in VS Code, see the .vscode folder.