An optimising compiler for Algorand Python
Project description
Algorand Python
Algorand Python is a partial implementation of the Python programming language that runs on the AVM. It includes a statically typed framework for development of Algorand smart contracts and logic signatures, with Pythonic interfaces to underlying AVM functionality that works with standard Python tooling.
Algorand Python is compiled for execution on the AVM by PuyaPy, an optimising compiler that ensures the resulting AVM bytecode execution semantics that match the given Python code. PuyaPy produces output that is directly compatible with AlgoKit typed clients to make deployment and calling easy.
Documentation | Language guide
Installation
Recommended method
The easiest way to use Algorand Python is to instantiate a template with AlgoKit via:
algokit init -t python
This will give you a full development environment with intellisense, linting, automatic formatting, breakpoint debugging, deployment and CI/CD.
A sample smart contract will be placed under PROJECT_NAME/projects/PROJECT_NAME/smart_contracts/SMART_CONTRACT_NAME/contract.py (replacing PROJECT_NAME and SMART_CONTRACT_NAME with the values you chose during the template wizard.)
Manual Alternative
Alternatively, if you want to start from scratch you can do the following:
- Ensure you have Python 3.12+
- Install AlgoKit CLI
- Check you can run the compiler:
algokit compile py -h
- Install Algorand Python into your project
poetry add algorand-python - Create a contract in a (e.g.)
contract.pyfile:from algopy import ARC4Contract, arc4 class HelloWorldContract(ARC4Contract): @arc4.abimethod def hello(self, name: arc4.String) -> arc4.String: return "Hello, " + name
Usage
- Navigate to your contract and compile it:
algokit compile py contract.py
- You should now have
HelloWorldContract.approval.tealandHelloWorldContract.clear.tealon the file system! - We generally recommend using ARC-56 and generated typed clients to have the most optimal deployment and consumption experience; PuyaPy produces an ARC-56 compatible app spec file by default:
algokit compile py contract.py --no-output-teal
- You should now have
HelloWorldContract.arc56.json, which can be generated into a client e.g. using AlgoKit CLI:algokit generate client HelloWorldContract.arc56.json --output client.py
- From here you can dive into the examples or look at the documentation.
Examples
There are many examples in this repo, here are some of the more useful ones that showcase what is possible.
The compiled output is available under the out/ directory alongside these, e.g. the approval
TEAL for voting is available at examples/voting/out/VotingRoundApp.approval.teal.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file puyapy-5.7.1-py3-none-any.whl.
File metadata
- Download URL: puyapy-5.7.1-py3-none-any.whl
- Upload date:
- Size: 730.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
20e38743f8086f59622a57b40d5b4a4c4e3097ba232dbfaa2df0ea5781c937b1
|
|
| MD5 |
5120d6771de94ff179d7b3697fc0eae6
|
|
| BLAKE2b-256 |
b749bd5dfa39890a496bedf85195c3101235b6d8c7ed0108162d327565b19e2d
|
Provenance
The following attestation bundles were made for puyapy-5.7.1-py3-none-any.whl:
Publisher:
cd.yaml on algorandfoundation/puya
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
puyapy-5.7.1-py3-none-any.whl -
Subject digest:
20e38743f8086f59622a57b40d5b4a4c4e3097ba232dbfaa2df0ea5781c937b1 - Sigstore transparency entry: 845821588
- Sigstore integration time:
-
Permalink:
algorandfoundation/puya@1e6109da02fef0bea6d541c2d47255b621013efd -
Branch / Tag:
refs/heads/main - Owner: https://github.com/algorandfoundation
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
cd.yaml@1e6109da02fef0bea6d541c2d47255b621013efd -
Trigger Event:
workflow_dispatch
-
Statement type: