This project has been generated using AlgoKit. See below for default getting started instructions.
-
Clone this repository locally
-
Install pre-requisites:
- Install
AlgoKit
- Link: Ensure you can executealgokit --version
. - 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
- Run
npm install
insmart_contracts
to install NPM packages
- Install
- Install
-
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
- IDEA (e.g. PyCharm)
- 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+F9 (or whatever you have debug mapped to) and it should start running with breakpoint debugging.
- 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
This project uses GitHub Actions to define CI/CD workflows, which are located in the .github/workflows
folder.
- Every time you have a change to your smart contract, and when you first initialise 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
allowUpdate
andallowDelete
parameters specified indeploy-config.ts
When deploying to LocalNet these values are both set totrue
for convenience. But for non-LocalNet networks they are more conservative and usefalse
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. - 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:
- 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.
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.
-
Ruff: An extremely fast Python linter.
-
mypy: Static type checker.
-
pytest: Automated testing.
-
npm: Node.js package manager
-
TypeScript: Strongly typed programming language that builds on JavaScript
-
ts-node-dev: TypeScript development execution environment
It has also been configured to have a productive dev experience out of the box in VS Code, see the .vscode folder.