Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ PyTeal provides high level, functional programming style abstractions over TEAL

PyTeal requires Python version >= 3.10.

To manage multiple Python versions use tooling like [pyenv](https://github.com/pyenv/pyenv).
If your operating system (OS) Python version < 3.10, we recommend:
* Rather than override the OS Python version, install Python >= 3.10 alongside the OS Python version.
* Use [pyenv](https://github.com/pyenv/pyenv#installation) or similar tooling to manage multiple Python versions.

### Recommended: Install from PyPi

Expand Down
7 changes: 7 additions & 0 deletions docs/installation.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
Install PyTeal
==============

PyTeal requires Python version >= 3.10.

If your operating system (OS) Python version < 3.10, we recommend:

* Rather than override the OS Python version, install Python >= 3.10 alongside the OS Python version.
* Use `pyenv <https://github.com/pyenv/pyenv#installation>`_ or similar tooling to manage multiple Python versions.

The easiest way of installing PyTeal is using :code:`pip` : ::

$ pip3 install pyteal
Expand Down
30 changes: 15 additions & 15 deletions pyteal/ast/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ def optedIn(cls, account: Expr, app: Expr) -> "App":
account: An index into Txn.Accounts that corresponds to the account to check,
must be evaluated to uint64 (or, since v4, an account address that appears in
Txn.Accounts or is Txn.Sender, must be evaluated to bytes).
app: An index into Txn.ForeignApps that corresponds to the application to read from,
app: An index into Txn.applications that corresponds to the application to read from,
must be evaluated to uint64 (or, since v4, an application id that appears in
Txn.ForeignApps or is the CurrentApplicationID, must be evaluated to int).
Txn.applications or is the CurrentApplicationID, must be evaluated to int).
"""
require_type(account, TealType.anytype)
require_type(app, TealType.uint64)
Expand Down Expand Up @@ -121,9 +121,9 @@ def localGetEx(cls, account: Expr, app: Expr, key: Expr) -> MaybeValue:
account: An index into Txn.Accounts that corresponds to the account to check,
must be evaluated to uint64 (or, since v4, an account address that appears in
Txn.Accounts or is Txn.Sender, must be evaluated to bytes).
app: An index into Txn.ForeignApps that corresponds to the application to read from,
app: An index into Txn.applications that corresponds to the application to read from,
must be evaluated to uint64 (or, since v4, an application id that appears in
Txn.ForeignApps or is the CurrentApplicationID, must be evaluated to int).
Txn.applications or is the CurrentApplicationID, must be evaluated to int).
key: The key to read from the account's local state. Must evaluate to bytes.
"""
require_type(account, TealType.anytype)
Expand All @@ -148,9 +148,9 @@ def globalGetEx(cls, app: Expr, key: Expr) -> MaybeValue:
"""Read from the global state of an application.

Args:
app: An index into Txn.ForeignApps that corresponds to the application to read from,
app: An index into Txn.applications that corresponds to the application to read from,
must be evaluated to uint64 (or, since v4, an application id that appears in
Txn.ForeignApps or is the CurrentApplicationID, must be evaluated to uint64).
Txn.applications or is the CurrentApplicationID, must be evaluated to uint64).
key: The key to read from the global application state. Must evaluate to bytes.
"""
require_type(app, TealType.uint64)
Expand Down Expand Up @@ -221,7 +221,7 @@ def approvalProgram(cls, app: Expr) -> MaybeValue:
"""Get the bytecode of Approval Program for the application.

Args:
app: An index into Txn.ForeignApps that correspond to the application to check.
app: An index into Txn.applications that correspond to the application to check.
Must evaluate to uint64.
"""
require_type(app, TealType.uint64)
Expand All @@ -237,7 +237,7 @@ def clearStateProgram(cls, app: Expr) -> MaybeValue:
"""Get the bytecode of Clear State Program for the application.

Args:
app: An index into Txn.ForeignApps that correspond to the application to check.
app: An index into Txn.applications that correspond to the application to check.
Must evaluate to uint64.
"""
require_type(app, TealType.uint64)
Expand All @@ -253,7 +253,7 @@ def globalNumUint(cls, app: Expr) -> MaybeValue:
"""Get the number of uint64 values allowed in Global State for the application.

Args:
app: An index into Txn.ForeignApps that correspond to the application to check.
app: An index into Txn.applications that correspond to the application to check.
Must evaluate to uint64.
"""
require_type(app, TealType.uint64)
Expand All @@ -269,7 +269,7 @@ def globalNumByteSlice(cls, app: Expr) -> MaybeValue:
"""Get the number of byte array values allowed in Global State for the application.

Args:
app: An index into Txn.ForeignApps that correspond to the application to check.
app: An index into Txn.applications that correspond to the application to check.
Must evaluate to uint64.
"""
require_type(app, TealType.uint64)
Expand All @@ -285,7 +285,7 @@ def localNumUint(cls, app: Expr) -> MaybeValue:
"""Get the number of uint64 values allowed in Local State for the application.

Args:
app: An index into Txn.ForeignApps that correspond to the application to check.
app: An index into Txn.applications that correspond to the application to check.
Must evaluate to uint64.
"""
require_type(app, TealType.uint64)
Expand All @@ -301,7 +301,7 @@ def localNumByteSlice(cls, app: Expr) -> MaybeValue:
"""Get the number of byte array values allowed in Local State for the application.

Args:
app: An index into Txn.ForeignApps that correspond to the application to check.
app: An index into Txn.applications that correspond to the application to check.
Must evaluate to uint64.
"""
require_type(app, TealType.uint64)
Expand All @@ -317,7 +317,7 @@ def extraProgramPages(cls, app: Expr) -> MaybeValue:
"""Get the number of Extra Program Pages of code space for the application.

Args:
app: An index into Txn.ForeignApps that correspond to the application to check.
app: An index into Txn.applications that correspond to the application to check.
Must evaluate to uint64.
"""
require_type(app, TealType.uint64)
Expand All @@ -333,7 +333,7 @@ def creator(cls, app: Expr) -> MaybeValue:
"""Get the creator address for the application.

Args:
app: An index into Txn.ForeignApps that correspond to the application to check.
app: An index into Txn.applications that correspond to the application to check.
Must evaluate to uint64.
"""
require_type(app, TealType.uint64)
Expand All @@ -346,7 +346,7 @@ def address(cls, app: Expr) -> MaybeValue:
"""Get the escrow address for the application.

Args:
app: An index into Txn.ForeignApps that correspond to the application to check.
app: An index into Txn.applications that correspond to the application to check.
Must evaluate to uint64.
"""
require_type(app, TealType.uint64)
Expand Down
50 changes: 25 additions & 25 deletions pyteal/ast/asset.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def balance(cls, account: Expr, asset: Expr) -> MaybeValue:
must be evaluated to uint64 (or, since v4, an account address that appears in
Txn.Accounts or is Txn.Sender, must be evaluated to bytes).
asset: The ID of the asset to get, must be evaluated to uint64 (or, since v4,
a Txn.ForeignAssets offset).
a Txn.assets offset).
"""
require_type(account, TealType.anytype)
require_type(asset, TealType.uint64)
Expand All @@ -38,7 +38,7 @@ def frozen(cls, account: Expr, asset: Expr) -> MaybeValue:
must be evaluated to uint64 (or, since v4, an account address that appears in
Txn.Accounts or is Txn.Sender, must be evaluated to bytes).
asset: The ID of the asset to get, must be evaluated to uint64 (or, since v4,
a Txn.ForeignAssets offset).
a Txn.assets offset).
"""
require_type(account, TealType.anytype)
require_type(asset, TealType.uint64)
Expand Down Expand Up @@ -94,9 +94,9 @@ def total(cls, asset: Expr) -> MaybeValue:
"""Get the total number of units of an asset.

Args:
asset: An index into Txn.ForeignAssets that corresponds to the asset to check,
asset: An index into Txn.assets that corresponds to the asset to check,
must be evaluated to uint64 (or since v4, an asset ID that appears in
Txn.ForeignAssets).
Txn.assets).
"""
require_type(asset, TealType.uint64)
return MaybeValue(
Expand All @@ -111,9 +111,9 @@ def decimals(cls, asset: Expr) -> MaybeValue:
"""Get the number of decimals for an asset.

Args:
asset: An index into Txn.ForeignAssets that corresponds to the asset to check,
asset: An index into Txn.assets that corresponds to the asset to check,
must be evaluated to uint64 (or since v4, an asset ID that appears in
Txn.ForeignAssets).
Txn.assets).
"""
require_type(asset, TealType.uint64)
return MaybeValue(
Expand All @@ -128,9 +128,9 @@ def defaultFrozen(cls, asset: Expr) -> MaybeValue:
"""Check if an asset is frozen by default.

Args:
asset: An index into Txn.ForeignAssets that corresponds to the asset to check,
asset: An index into Txn.assets that corresponds to the asset to check,
must be evaluated to uint64 (or since v4, an asset ID that appears in
Txn.ForeignAssets).
Txn.assets).
"""
require_type(asset, TealType.uint64)
return MaybeValue(
Expand All @@ -145,9 +145,9 @@ def unitName(cls, asset: Expr) -> MaybeValue:
"""Get the unit name of an asset.

Args:
asset: An index into Txn.ForeignAssets that corresponds to the asset to check,
asset: An index into Txn.assets that corresponds to the asset to check,
must be evaluated to uint64 (or since v4, an asset ID that appears in
Txn.ForeignAssets).
Txn.assets).
"""
require_type(asset, TealType.uint64)
return MaybeValue(
Expand All @@ -162,9 +162,9 @@ def name(cls, asset: Expr) -> MaybeValue:
"""Get the name of an asset.

Args:
asset: An index into Txn.ForeignAssets that corresponds to the asset to check,
asset: An index into Txn.assets that corresponds to the asset to check,
must be evaluated to uint64 (or since v4, an asset ID that appears in
Txn.ForeignAssets).
Txn.assets).
"""
require_type(asset, TealType.uint64)
return MaybeValue(
Expand All @@ -179,9 +179,9 @@ def url(cls, asset: Expr) -> MaybeValue:
"""Get the URL of an asset.

Args:
asset: An index into Txn.ForeignAssets that corresponds to the asset to check,
asset: An index into Txn.assets that corresponds to the asset to check,
must be evaluated to uint64 (or since v4, an asset ID that appears in
Txn.ForeignAssets).
Txn.assets).
"""
require_type(asset, TealType.uint64)
return MaybeValue(
Expand All @@ -198,9 +198,9 @@ def metadataHash(cls, asset: Expr) -> MaybeValue:
If set, this will be 32 bytes long.

Args:
asset: An index into Txn.ForeignAssets that corresponds to the asset to check,
asset: An index into Txn.assets that corresponds to the asset to check,
must be evaluated to uint64 (or since v4, an asset ID that appears in
Txn.ForeignAssets).
Txn.assets).
"""
require_type(asset, TealType.uint64)
return MaybeValue(
Expand All @@ -215,9 +215,9 @@ def manager(cls, asset: Expr) -> MaybeValue:
"""Get the manager address for an asset.

Args:
asset: An index into Txn.ForeignAssets that corresponds to the asset to check,
asset: An index into Txn.assets that corresponds to the asset to check,
must be evaluated to uint64 (or since v4, an asset ID that appears in
Txn.ForeignAssets).
Txn.assets).
"""
require_type(asset, TealType.uint64)
return MaybeValue(
Expand All @@ -232,9 +232,9 @@ def reserve(cls, asset: Expr) -> MaybeValue:
"""Get the reserve address for an asset.

Args:
asset: An index into Txn.ForeignAssets that corresponds to the asset to check,
asset: An index into Txn.assets that corresponds to the asset to check,
must be evaluated to uint64 (or since v4, an asset ID that appears in
Txn.ForeignAssets).
Txn.assets).
"""
require_type(asset, TealType.uint64)
return MaybeValue(
Expand All @@ -249,9 +249,9 @@ def freeze(cls, asset: Expr) -> MaybeValue:
"""Get the freeze address for an asset.

Args:
asset: An index into Txn.ForeignAssets that corresponds to the asset to check,
asset: An index into Txn.assets that corresponds to the asset to check,
must be evaluated to uint64 (or since v4, an asset ID that appears in
Txn.ForeignAssets).
Txn.assets).
"""
require_type(asset, TealType.uint64)
return MaybeValue(
Expand All @@ -266,9 +266,9 @@ def clawback(cls, asset: Expr) -> MaybeValue:
"""Get the clawback address for an asset.

Args:
asset: An index into Txn.ForeignAssets that corresponds to the asset to check,
asset: An index into Txn.assets that corresponds to the asset to check,
must be evaluated to uint64 (or since v4, an asset ID that appears in
Txn.ForeignAssets).
Txn.assets).
"""
require_type(asset, TealType.uint64)
return MaybeValue(
Expand All @@ -283,7 +283,7 @@ def creator(cls, asset: Expr) -> MaybeValue:
"""Get the creator address for an asset.

Args:
asset: An index into Txn.ForeignAssets that corresponds to the asset to check. Must
asset: An index into Txn.assets that corresponds to the asset to check. Must
evaluate to uint64.
"""
require_type(asset, TealType.uint64)
Expand Down
23 changes: 22 additions & 1 deletion pyteal/ast/itxn.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from enum import Enum
from typing import TYPE_CHECKING, cast
import algosdk

from pyteal.ast.abi.util import type_specs_from_signature
from pyteal.ast.int import EnumInt

from pyteal.ast.methodsig import MethodSignature
from pyteal.types import TealType, require_type
from pyteal.errors import TealInputError, TealTypeError, verifyTealVersion
Expand Down Expand Up @@ -186,6 +186,27 @@ def SetField(cls, field: TxnField, value: Expr | list[Expr]) -> Expr:
]
)

@classmethod
def Execute(cls, fields: dict[TxnField, Expr | list[Expr]]) -> Expr:
"""Performs a single transaction given fields passed in.

A convenience method that accepts fields to submit a single inner transaction, which is equivalent to:

.. code-block:: python

InnerTxnBuilder.Begin()
InnerTxnBuilder.SetFields(fields)
InnerTxnBuilder.End()

Requires TEAL version 5 or higher. This operation is only permitted in application mode.

Args:
fields: A dictionary whose keys are fields to set and whose values are the value each
field should take. Each value must evaluate to a type that is compatible with the
field being set.
"""
return Seq(cls.Begin(), cls.SetFields(fields), cls.Submit())

@classmethod
def SetFields(cls, fields: dict[TxnField, Expr | list[Expr]]) -> Expr:
"""Set multiple fields of the current inner transaction.
Expand Down
Loading