Skip to main content

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

Quick start

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.

Alternatively, if you want to start from scratch you can do the following:

  1. Ensure you have Python 3.12+
  2. Install the PuyaPy compiler into your project poetry add puya --group=dev and/or install AlgoKit CLI
  3. Check you can run the compiler:
    puyapy -h
    # OR
    algokit compile py -h
    
  4. Create a contract in a (e.g.) contact.py file:
    from algopy import ARC4Contract, arc4
    class HelloWorldContract(ARC4Contract):
        @arc4.abimethod
        def hello(self, name: arc4.String) -> arc4.String:
            return "Hello, " + name
    
  5. Compile the contract:
    # After running `poetry shell`:
    puyapy contract.py
    # OR if using AlgoKit CLI:
    algokit compile py contract.py
    
  6. You should now have HelloWorldContract.approval.teal and HelloWorldContract.clear.teal on the file system!
  7. We generally recommend using ARC-32 and generated typed clients to have the most optimal deployment and consumption experience; to do this you need to ask PuyaPy to output an ARC-32 compatible app spec file:
    puyapy contract.py --output-arc32 --no-output-teal
    # OR
    algokit compile py contract.py --output-arc32 --no-output-teal
    
  8. You should now have HelloWorldContract.arc32.json, which can be generated into a client e.g. using AlgoKit CLI:
    algokit generate client HelloWorldContract.arc32.json --output client.py
    
  9. 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.

Metadata

Release files for puyapy 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for puyapy 1.0.1
File Interpreter ABI Platform Actions
puyapy-1.0.1-py3-none-any.whl Python 3 none any Details for puyapy-1.0.1-py3-none-any.whl

Release files / puyapy-1.0.1-py3-none-any.whl

Download URL puyapy-1.0.1-py3-none-any.whl
Size 2.1 MB
Tags Python 3
SHA-256 checksum
How to use checksums
afef6d685d8aa4d19e97baed91a1e013913ee216f3f19ac00490f2e2c96032d5
BLAKE2b-256 checksum
How to use checksums
9d77b12497df52386192e53e6f72244190ca9883ac1587de71125df0b75d2255
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.0.0 CPython/3.12.2

Security for puyapy 1.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.1 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page