PyTeal Package¶
-
pyteal.
Txn
= <pyteal.TxnObject object>¶ The current transaction being evaluated. This is an instance of
TxnObject
.
-
pyteal.
Gtxn
= <pyteal.TxnGroup object>¶ The current group of transactions being evaluated. This is an instance of
TxnGroup
.
-
pyteal.
InnerTxn
= <pyteal.TxnObject object>¶ The most recently submitted inner transaction. This is an instance of
TxnObject
.
-
class
pyteal.
Expr
¶ Bases:
abc.ABC
Abstract base class for PyTeal expressions.
-
And
(other: pyteal.Expr) → pyteal.Expr¶ Take the logical And of this expression and another one.
This expression must evaluate to uint64.
This is the same as using
And()
with two arguments.
-
Or
(other: pyteal.Expr) → pyteal.Expr¶ Take the logical Or of this expression and another one.
This expression must evaluate to uint64.
This is the same as using
Or()
with two arguments.
-
getDefinitionTrace
() → List[str]¶
-
has_return
() → bool¶ Check if this expression always returns from the current subroutine or program.
-
type_of
() → pyteal.TealType¶ Get the return type of this expression.
-
-
class
pyteal.
LeafExpr
¶ Bases:
pyteal.Expr
Leaf expression base class.
-
has_return
()¶ Check if this expression always returns from the current subroutine or program.
-
-
class
pyteal.
Addr
(address: str)¶ Bases:
pyteal.LeafExpr
An expression that represents an Algorand address.
-
__init__
(address: str) → None¶ Create a new Addr expression.
Parameters: address – A string containing a valid base32 Algorand address
-
type_of
()¶ Get the return type of this expression.
-
-
class
pyteal.
Bytes
(arg1: Union[str, bytes, bytearray], arg2: str = None)¶ Bases:
pyteal.LeafExpr
An expression that represents a byte string.
-
__init__
(arg1: Union[str, bytes, bytearray], arg2: str = None) → None¶ Create a new byte string.
Depending on the encoding, there are different arguments to pass:
- For UTF-8 strings:
- Pass the string as the only argument. For example,
Bytes("content")
. - For raw bytes or bytearray objects:
- Pass the bytes or bytearray as the only argument. For example,
Bytes(b"content")
. - For base16, base32, or base64 strings:
- Pass the base as the first argument and the string as the second argument. For example,
Bytes("base16", "636F6E74656E74")
,Bytes("base32", "ORFDPQ6ARJK")
,Bytes("base64", "Y29udGVudA==")
. - Special case for base16:
- The prefix “0x” may be present in a base16 byte string. For example,
Bytes("base16", "0x636F6E74656E74")
.
-
type_of
()¶ Get the return type of this expression.
-
-
class
pyteal.
Int
(value: int)¶ Bases:
pyteal.LeafExpr
An expression that represents a uint64.
-
__init__
(value: int) → None¶ Create a new uint64.
Parameters: value – The integer value this uint64 will represent. Must be a positive value less than 2**64.
-
type_of
()¶ Get the return type of this expression.
-
-
class
pyteal.
EnumInt
(name: str)¶ Bases:
pyteal.LeafExpr
An expression that represents uint64 enum values.
-
__init__
(name: str) → None¶ Create an expression to reference a uint64 enum value.
Parameters: name – The name of the enum value.
-
type_of
()¶ Get the return type of this expression.
-
-
class
pyteal.
MethodSignature
(methodName: str)¶ Bases:
pyteal.LeafExpr
An expression that represents an ABI method selector
-
__init__
(methodName: str) → None¶ Create a new method selector for ABI method call.
Parameters: methodName – A string containing a valid ABI method signature
-
type_of
() → pyteal.TealType¶ Get the return type of this expression.
-
-
class
pyteal.
Arg
(index: Union[int, pyteal.Expr])¶ Bases:
pyteal.LeafExpr
An expression to get an argument when running in signature verification mode.
-
__init__
(index: Union[int, pyteal.Expr]) → None¶ Get an argument for this program.
Should only be used in signature verification mode. For application mode arguments, see
TxnObject.application_args
.Parameters: index – The index of the argument to get. The index must be between 0 and 255 inclusive. Starting in TEAL v5, the index may be a PyTeal expression that evaluates to uint64.
-
type_of
()¶ Get the return type of this expression.
-
-
class
pyteal.
TxnType
¶ Bases:
object
Enum of all possible transaction types.
-
ApplicationCall
= <pyteal.EnumInt object>¶
-
AssetConfig
= <pyteal.EnumInt object>¶
-
AssetFreeze
= <pyteal.EnumInt object>¶
-
AssetTransfer
= <pyteal.EnumInt object>¶
-
KeyRegistration
= <pyteal.EnumInt object>¶
-
Payment
= <pyteal.EnumInt object>¶
-
Unknown
= <pyteal.EnumInt object>¶
-
-
class
pyteal.
TxnField
(id: int, name: str, type: pyteal.TealType, is_array: bool, min_version: int)¶ Bases:
enum.Enum
An enumeration.
-
accounts
= (28, 'Accounts', <TealType.bytes: 1>, True, 2)¶
-
amount
= (8, 'Amount', <TealType.uint64: 0>, False, 2)¶
-
application_args
= (26, 'ApplicationArgs', <TealType.bytes: 1>, True, 2)¶
-
application_id
= (24, 'ApplicationID', <TealType.uint64: 0>, False, 2)¶
-
applications
= (50, 'Applications', <TealType.uint64: 0>, True, 3)¶
-
approval_program
= (30, 'ApprovalProgram', <TealType.bytes: 1>, False, 2)¶
-
asset_amount
= (18, 'AssetAmount', <TealType.uint64: 0>, False, 2)¶
-
asset_close_to
= (21, 'AssetCloseTo', <TealType.bytes: 1>, False, 2)¶
-
asset_receiver
= (20, 'AssetReceiver', <TealType.bytes: 1>, False, 2)¶
-
asset_sender
= (19, 'AssetSender', <TealType.bytes: 1>, False, 2)¶
-
assets
= (48, 'Assets', <TealType.uint64: 0>, True, 3)¶
-
clear_state_program
= (31, 'ClearStateProgram', <TealType.bytes: 1>, False, 2)¶
-
close_remainder_to
= (9, 'CloseRemainderTo', <TealType.bytes: 1>, False, 2)¶
-
config_asset
= (33, 'ConfigAsset', <TealType.uint64: 0>, False, 2)¶
-
config_asset_clawback
= (44, 'ConfigAssetClawback', <TealType.bytes: 1>, False, 2)¶
-
config_asset_decimals
= (35, 'ConfigAssetDecimals', <TealType.uint64: 0>, False, 2)¶
-
config_asset_default_frozen
= (36, 'ConfigAssetDefaultFrozen', <TealType.uint64: 0>, False, 2)¶
-
config_asset_freeze
= (43, 'ConfigAssetFreeze', <TealType.bytes: 1>, False, 2)¶
-
config_asset_manager
= (41, 'ConfigAssetManager', <TealType.bytes: 1>, False, 2)¶
-
config_asset_metadata_hash
= (40, 'ConfigAssetMetadataHash', <TealType.bytes: 1>, False, 2)¶
-
config_asset_name
= (38, 'ConfigAssetName', <TealType.bytes: 1>, False, 2)¶
-
config_asset_reserve
= (42, 'ConfigAssetReserve', <TealType.bytes: 1>, False, 2)¶
-
config_asset_total
= (34, 'ConfigAssetTotal', <TealType.uint64: 0>, False, 2)¶
-
config_asset_unit_name
= (37, 'ConfigAssetUnitName', <TealType.bytes: 1>, False, 2)¶
-
config_asset_url
= (39, 'ConfigAssetURL', <TealType.bytes: 1>, False, 2)¶
-
created_application_id
= (61, 'CreatedApplicationID', <TealType.uint64: 0>, False, 5)¶
-
created_asset_id
= (60, 'CreatedAssetID', <TealType.uint64: 0>, False, 5)¶
-
extra_program_pages
= (56, 'ExtraProgramPages', <TealType.uint64: 0>, False, 4)¶
-
fee
= (1, 'Fee', <TealType.uint64: 0>, False, 2)¶
-
first_valid
= (2, 'FirstValid', <TealType.uint64: 0>, False, 2)¶
-
first_valid_time
= (3, 'FirstValidTime', <TealType.uint64: 0>, False, 2)¶
-
freeze_asset
= (45, 'FreezeAsset', <TealType.uint64: 0>, False, 2)¶
-
freeze_asset_account
= (46, 'FreezeAssetAccount', <TealType.bytes: 1>, False, 2)¶
-
freeze_asset_frozen
= (47, 'FreezeAssetFrozen', <TealType.uint64: 0>, False, 2)¶
-
global_num_byte_slices
= (53, 'GlobalNumByteSlice', <TealType.uint64: 0>, False, 3)¶
-
global_num_uints
= (52, 'GlobalNumUint', <TealType.uint64: 0>, False, 3)¶
-
group_index
= (22, 'GroupIndex', <TealType.uint64: 0>, False, 2)¶
-
last_log
= (62, 'LastLog', <TealType.bytes: 1>, False, 6)¶
-
last_valid
= (4, 'LastValid', <TealType.uint64: 0>, False, 2)¶
-
lease
= (6, 'Lease', <TealType.bytes: 1>, False, 2)¶
-
local_num_byte_slices
= (55, 'LocalNumByteSlice', <TealType.uint64: 0>, False, 3)¶
-
local_num_uints
= (54, 'LocalNumUint', <TealType.uint64: 0>, False, 3)¶
-
logs
= (58, 'Logs', <TealType.bytes: 1>, True, 5)¶
-
nonparticipation
= (57, 'Nonparticipation', <TealType.uint64: 0>, False, 5)¶
-
note
= (5, 'Note', <TealType.bytes: 1>, False, 2)¶
-
num_accounts
= (2, 'NumAccounts', <TealType.uint64: 0>, False, 2)¶
-
num_app_args
= (27, 'NumAppArgs', <TealType.uint64: 0>, False, 2)¶
-
num_applications
= (51, 'NumApplications', <TealType.uint64: 0>, False, 3)¶
-
num_assets
= (49, 'NumAssets', <TealType.uint64: 0>, False, 3)¶
-
num_logs
= (59, 'NumLogs', <TealType.uint64: 0>, False, 5)¶
-
on_completion
= (25, 'OnCompletion', <TealType.uint64: 0>, False, 2)¶
-
receiver
= (7, 'Receiver', <TealType.bytes: 1>, False, 2)¶
-
rekey_to
= (32, 'RekeyTo', <TealType.bytes: 1>, False, 2)¶
-
selection_pk
= (11, 'SelectionPK', <TealType.bytes: 1>, False, 2)¶
-
sender
= (0, 'Sender', <TealType.bytes: 1>, False, 2)¶
-
state_proof_pk
= (63, 'StateProofPK', <TealType.bytes: 1>, False, 6)¶
-
tx_id
= (23, 'TxID', <TealType.bytes: 1>, False, 2)¶
-
type
= (15, 'Type', <TealType.bytes: 1>, False, 2)¶
-
type_enum
= (16, 'TypeEnum', <TealType.uint64: 0>, False, 2)¶
-
type_of
() → pyteal.TealType¶
-
vote_first
= (12, 'VoteFirst', <TealType.uint64: 0>, False, 2)¶
-
vote_key_dilution
= (14, 'VoteKeyDilution', <TealType.uint64: 0>, False, 2)¶
-
vote_last
= (13, 'VoteLast', <TealType.uint64: 0>, False, 2)¶
-
vote_pk
= (10, 'VotePK', <TealType.bytes: 1>, False, 2)¶
-
xfer_asset
= (17, 'XferAsset', <TealType.uint64: 0>, False, 2)¶
-
-
class
pyteal.
TxnExpr
(op: pyteal.Op, name: str, field: pyteal.TxnField)¶ Bases:
pyteal.LeafExpr
An expression that accesses a transaction field from the current transaction.
-
type_of
()¶ Get the return type of this expression.
-
-
class
pyteal.
TxnaExpr
(staticOp: pyteal.Op, dynamicOp: Optional[pyteal.Op], name: str, field: pyteal.TxnField, index: Union[int, pyteal.Expr])¶ Bases:
pyteal.LeafExpr
An expression that accesses a transaction array field from the current transaction.
-
type_of
()¶ Get the return type of this expression.
-
-
class
pyteal.
TxnArray
(txnObject: pyteal.TxnObject, accessField: pyteal.TxnField, lengthField: pyteal.TxnField)¶ Bases:
pyteal.Array
Represents a transaction array field.
-
__getitem__
(index: Union[int, pyteal.Expr]) → pyteal.TxnaExpr¶ Get the value at a given index in this array.
-
length
() → pyteal.TxnExpr¶ Get the length of the array.
-
-
class
pyteal.
TxnObject
(makeTxnExpr: Callable[[pyteal.TxnField], pyteal.TxnExpr], makeTxnaExpr: Callable[[pyteal.TxnField, Union[int, pyteal.Expr]], pyteal.TxnaExpr])¶ Bases:
object
Represents a transaction and its fields.
-
amount
() → pyteal.TxnExpr¶ Get the amount of the transaction in micro Algos.
Only set when
type_enum()
isTxnType.Payment
.For more information, see https://developer.algorand.org/docs/reference/transactions/#amount
-
application_id
() → pyteal.TxnExpr¶ Get the application ID from the ApplicationCall portion of the current transaction.
Only set when
type_enum()
isTxnType.ApplicationCall
.
-
applications
¶ The applications array in an ApplicationCall transaction.
Type: TxnArray Requires TEAL version 3 or higher.
-
approval_program
() → pyteal.TxnExpr¶ Get the approval program.
Only set when
type_enum()
isTxnType.ApplicationCall
.
-
asset_amount
() → pyteal.TxnExpr¶ Get the amount of the asset being transferred, measured in the asset’s units.
Only set when
type_enum()
isTxnType.AssetTransfer
.For more information, see https://developer.algorand.org/docs/reference/transactions/#assetamount
-
asset_close_to
() → pyteal.TxnExpr¶ Get the closeout address of the asset transfer.
Only set when
type_enum()
isTxnType.AssetTransfer
.For more information, see https://developer.algorand.org/docs/reference/transactions/#assetcloseto
-
asset_receiver
() → pyteal.TxnExpr¶ Get the recipient of the asset transfer.
Only set when
type_enum()
isTxnType.AssetTransfer
.For more information, see https://developer.algorand.org/docs/reference/transactions/#assetreceiver
-
asset_sender
() → pyteal.TxnExpr¶ Get the 32 byte address of the subject of clawback.
Only set when
type_enum()
isTxnType.AssetTransfer
.For more information, see https://developer.algorand.org/docs/reference/transactions/#assetsender
-
assets
¶ The foreign asset array in an ApplicationCall transaction.
Type: TxnArray Requires TEAL version 3 or higher.
-
clear_state_program
() → pyteal.TxnExpr¶ Get the clear state program.
Only set when
type_enum()
isTxnType.ApplicationCall
.
-
close_remainder_to
() → pyteal.TxnExpr¶ Get the 32 byte address of the CloseRemainderTo field.
Only set when
type_enum()
isTxnType.Payment
.For more information, see https://developer.algorand.org/docs/reference/transactions/#closeremainderto
-
config_asset
() → pyteal.TxnExpr¶ Get the asset ID in asset config transaction.
Only set when
type_enum()
isTxnType.AssetConfig
.For more information, see https://developer.algorand.org/docs/reference/transactions/#configasset
-
config_asset_clawback
() → pyteal.TxnExpr¶ Get the 32 byte asset clawback address.
Only set when
type_enum()
isTxnType.AssetConfig
.For more information, see https://developer.algorand.org/docs/reference/transactions/#clawbackaddr
-
config_asset_decimals
() → pyteal.TxnExpr¶ Get the number of digits to display after the decimal place when displaying the asset.
Only set when
type_enum()
isTxnType.AssetConfig
.For more information, see https://developer.algorand.org/docs/reference/transactions/#decimals
-
config_asset_default_frozen
() → pyteal.TxnExpr¶ Check if the asset’s slots are frozen by default or not.
Only set when
type_enum()
isTxnType.AssetConfig
.For more information, see https://developer.algorand.org/docs/reference/transactions/#defaultfrozen
-
config_asset_freeze
() → pyteal.TxnExpr¶ Get the 32 byte asset freeze address.
Only set when
type_enum()
isTxnType.AssetConfig
.For more information, see https://developer.algorand.org/docs/reference/transactions/#freezeaddr
-
config_asset_manager
() → pyteal.TxnExpr¶ Get the 32 byte asset manager address.
Only set when
type_enum()
isTxnType.AssetConfig
.For more information, see https://developer.algorand.org/docs/reference/transactions/#manageraddr
-
config_asset_metadata_hash
() → pyteal.TxnExpr¶ Get the 32 byte commitment to some unspecified asset metdata.
Only set when
type_enum()
isTxnType.AssetConfig
.For more information, see https://developer.algorand.org/docs/reference/transactions/#metadatahash
-
config_asset_name
() → pyteal.TxnExpr¶ Get the asset name.
Only set when
type_enum()
isTxnType.AssetConfig
.For more information, see https://developer.algorand.org/docs/reference/transactions/#assetname
-
config_asset_reserve
() → pyteal.TxnExpr¶ Get the 32 byte asset reserve address.
Only set when
type_enum()
isTxnType.AssetConfig
.For more information, see https://developer.algorand.org/docs/reference/transactions/#reserveaddr
-
config_asset_total
() → pyteal.TxnExpr¶ Get the total number of units of this asset created.
Only set when
type_enum()
isTxnType.AssetConfig
.For more information, see https://developer.algorand.org/docs/reference/transactions/#total
-
config_asset_unit_name
() → pyteal.TxnExpr¶ Get the unit name of the asset.
Only set when
type_enum()
isTxnType.AssetConfig
.For more information, see https://developer.algorand.org/docs/reference/transactions/#unitname
-
config_asset_url
() → pyteal.TxnExpr¶ Get the asset URL.
Only set when
type_enum()
isTxnType.AssetConfig
.For more information, see https://developer.algorand.org/docs/reference/transactions/#url
-
created_application_id
() → pyteal.TxnExpr¶ Get the application ID allocated by the creation of an application.
Only set when
type_enum()
isTxnType.ApplicationCall
and this is an app creation call.Requires TEAL version 5 or higher.
- v5 - Only works on inner transactions.
- >= v6 - Works on top-level and inner transactions.
-
created_asset_id
() → pyteal.TxnExpr¶ Get the asset ID allocated by the creation of an ASA.
Only set when
type_enum()
isTxnType.AssetConfig
and this is an asset creation transaction.Requires TEAL version 5 or higher.
- v5 - Only works on inner transactions.
- >= v6 - Works on top-level and inner transactions.
-
extra_program_pages
() → pyteal.TxnExpr¶ Get the number of additional pages for each of the application’s approval and clear state programs.
1 additional page means 2048 more total bytes, or 1024 for each program.
Only set when
type_enum()
isTxnType.ApplicationCall
and this is an app creation call.Requires TEAL version 4 or higher.
-
fee
() → pyteal.TxnExpr¶ Get the transaction fee in micro Algos.
For more information, see https://developer.algorand.org/docs/reference/transactions/#fee
-
first_valid
() → pyteal.TxnExpr¶ Get the first valid round number.
For more information, see https://developer.algorand.org/docs/reference/transactions/#firstvalid
-
freeze_asset
() → pyteal.TxnExpr¶ Get the asset ID being frozen or un-frozen.
Only set when
type_enum()
isTxnType.AssetFreeze
.For more information, see https://developer.algorand.org/docs/reference/transactions/#freezeasset
-
freeze_asset_account
() → pyteal.TxnExpr¶ Get the 32 byte address of the account whose asset slot is being frozen or un-frozen.
Only set when
type_enum()
isTxnType.AssetFreeze
.For more information, see https://developer.algorand.org/docs/reference/transactions/#freezeaccount
-
freeze_asset_frozen
() → pyteal.TxnExpr¶ Get the new frozen value for the asset.
Only set when
type_enum()
isTxnType.AssetFreeze
.For more information, see https://developer.algorand.org/docs/reference/transactions/#assetfrozen
-
global_num_byte_slices
() → pyteal.TxnExpr¶ Get the schema count of global state byte slices in an application creation call.
Only set when
type_enum()
isTxnType.ApplicationCall
and this is an app creation call.Requires TEAL version 3 or higher.
-
global_num_uints
() → pyteal.TxnExpr¶ Get the schema count of global state integers in an application creation call.
Only set when
type_enum()
isTxnType.ApplicationCall
and this is an app creation call.Requires TEAL version 3 or higher.
-
group_index
() → pyteal.TxnExpr¶ Get the position of the transaction within the atomic transaction group.
A stand-alone transaction is implictly element 0 in a group of 1.
For more information, see https://developer.algorand.org/docs/reference/transactions/#group
-
last_log
() → pyteal.TxnExpr¶ A convenience method for getting the last logged message from a transaction.
Only application calls may log a message. Returns an empty string if no messages were logged.
Only set when
type_enum()
isTxnType.ApplicationCall
.Requires TEAL version 6 or higher.
-
last_valid
() → pyteal.TxnExpr¶ Get the last valid round number.
For more information, see https://developer.algorand.org/docs/reference/transactions/#lastvalid
-
lease
() → pyteal.TxnExpr¶ Get the transaction lease.
For more information, see https://developer.algorand.org/docs/reference/transactions/#lease
-
local_num_byte_slices
() → pyteal.TxnExpr¶ Get the schema count of local state byte slices in an application creation call.
Only set when
type_enum()
isTxnType.ApplicationCall
and this is an app creation call.Requires TEAL version 3 or higher.
-
local_num_uints
() → pyteal.TxnExpr¶ Get the schema count of local state integers in an application creation call.
Only set when
type_enum()
isTxnType.ApplicationCall
and this is an app creation call.Requires TEAL version 3 or higher.
-
logs
¶ The log messages emitted by an application call.
Type: TxnArray Requires TEAL version 5 or higher.
- v5 - Only works on inner transactions.
- >= v6 - Works on top-level and inner transactions.
-
nonparticipation
() → pyteal.TxnExpr¶ Marks an account nonparticipating for rewards.
Only set when
type_enum()
isTxnType.KeyRegistration
.For more information, see https://developer.algorand.org/docs/reference/transactions/#nonparticipation
Requires TEAL version 5 or higher.
-
note
() → pyteal.TxnExpr¶ Get the transaction note.
For more information, see https://developer.algorand.org/docs/reference/transactions/#note
-
on_completion
() → pyteal.TxnExpr¶ Get the on completion action from the ApplicationCall portion of the transaction.
Only set when
type_enum()
isTxnType.ApplicationCall
.
-
receiver
() → pyteal.TxnExpr¶ Get the 32 byte address of the receiver.
Only set when
type_enum()
isTxnType.Payment
.For more information, see https://developer.algorand.org/docs/reference/transactions/#receiver
-
rekey_to
() → pyteal.TxnExpr¶ Get the sender’s new 32 byte AuthAddr.
For more information, see https://developer.algorand.org/docs/reference/transactions/#rekeyto
-
selection_pk
() → pyteal.TxnExpr¶ Get the VRF public key.
Only set when
type_enum()
isTxnType.KeyRegistration
.For more information, see https://developer.algorand.org/docs/reference/transactions/#selectionpk
-
sender
() → pyteal.TxnExpr¶ Get the 32 byte address of the sender.
For more information, see https://developer.algorand.org/docs/reference/transactions/#sender
-
state_proof_pk
() → pyteal.TxnExpr¶ Get the state proof public key commitment from a transaction.
Requires TEAL version 6 or higher.
-
tx_id
() → pyteal.TxnExpr¶ Get the 32 byte computed ID for the transaction.
-
type
() → pyteal.TxnExpr¶ Get the type of this transaction as a byte string.
In most cases it is preferable to use
type_enum()
instead.For more information, see https://developer.algorand.org/docs/reference/transactions/#type
-
vote_first
() → pyteal.TxnExpr¶ Get the first round that the participation key is valid.
Only set when
type_enum()
isTxnType.KeyRegistration
.For more information, see https://developer.algorand.org/docs/reference/transactions/#votefirst
-
vote_key_dilution
() → pyteal.TxnExpr¶ Get the dilution for the 2-level participation key.
Only set when
type_enum()
isTxnType.KeyRegistration
.For more information, see https://developer.algorand.org/docs/reference/transactions/#votekeydilution
-
vote_last
() → pyteal.TxnExpr¶ Get the last round that the participation key is valid.
Only set when
type_enum()
isTxnType.KeyRegistration
.For more information, see https://developer.algorand.org/docs/reference/transactions/#votelast
-
vote_pk
() → pyteal.TxnExpr¶ Get the root participation public key.
Only set when
type_enum()
isTxnType.KeyRegistration
.For more information, see https://developer.algorand.org/docs/reference/transactions/#votepk
-
xfer_asset
() → pyteal.TxnExpr¶ Get the ID of the asset being transferred.
Only set when
type_enum()
isTxnType.AssetTransfer
.For more information, see https://developer.algorand.org/docs/reference/transactions/#xferasset
-
-
class
pyteal.
GtxnExpr
(txnIndex: Union[int, pyteal.Expr], field: pyteal.TxnField)¶ Bases:
pyteal.TxnExpr
An expression that accesses a transaction field from a transaction in the current group.
-
class
pyteal.
GtxnaExpr
(txnIndex: Union[int, pyteal.Expr], field: pyteal.TxnField, index: Union[int, pyteal.Expr])¶ Bases:
pyteal.TxnaExpr
An expression that accesses a transaction array field from a transaction in the current group.
-
class
pyteal.
TxnGroup
¶ Bases:
object
Represents a group of transactions.
-
__getitem__
(txnIndex: Union[int, pyteal.Expr]) → pyteal.TxnObject¶
-
-
class
pyteal.
GeneratedID
(txnIndex: Union[int, pyteal.Expr])¶ Bases:
pyteal.LeafExpr
An expression to obtain the ID of an asset or application created by another transaction in the current group.
-
__init__
(txnIndex: Union[int, pyteal.Expr]) → None¶ Create an expression to extract the created ID from a transaction in the current group.
Requires TEAL version 4 or higher. This operation is only permitted in application mode.
Parameters: - txnIndex – The index of the transaction from which the created ID should be obtained.
- index may be a Python int, or it may be a PyTeal expression that evaluates at (This) –
- If it's an expression, it must evaluate to a uint64. In all cases, the index (runtime.) –
- be less than the index of the current transaction. (must) –
-
type_of
()¶ Get the return type of this expression.
-
-
class
pyteal.
ImportScratchValue
(txnIndex: Union[int, pyteal.Expr], slotId: Union[int, pyteal.Expr])¶ Bases:
pyteal.LeafExpr
An expression to load a scratch value created by another transaction in the current group
-
__init__
(txnIndex: Union[int, pyteal.Expr], slotId: Union[int, pyteal.Expr]) → None¶ Create an expression to load a scratch space slot from a transaction in the current group.
Requires TEAL version 4 or higher. This operation is only permitted in application mode.
Parameters: - txnIndex – The index of the transaction from which the created ID should be obtained. This index may be a Python int, or it may be a PyTeal expression that evaluates at runtime. If it’s an expression, it must evaluate to a uint64. In all cases, the index must be less than the index of the current transaction.
- slotId – The index of the scratch slot that should be loaded. This index may be a Python int, or it may be a PyTeal expression that evaluates at runtime. If it’s an expression, it must evaluate to a uint64. In all cases, the index must be in the range [0, 256).
-
type_of
()¶ Get the return type of this expression.
-
-
class
pyteal.
Global
(field: pyteal.GlobalField)¶ Bases:
pyteal.LeafExpr
An expression that accesses a global property.
-
classmethod
caller_app_address
() → pyteal.Global¶ Get the address of the app that submitted the InnerTransaction that triggered this app to execute.
If not called from another app, this will return the ZeroAddress
Requires TEAL version 6 or higher.
-
classmethod
caller_app_id
() → pyteal.Global¶ Get the id of the app that submitted the InnerTransaction that triggered this app to execute.
If not called from another app, this will return 0
Requires TEAL version 6 or higher.
-
classmethod
creator_address
() → pyteal.Global¶ Address of the creator of the current application.
Fails during Signature mode. Requires TEAL version 3 or higher.
-
classmethod
current_application_address
() → pyteal.Global¶ Get the address of that the current application controls.
Fails during Signature mode. Requires TEAL version 5 or higher.
-
classmethod
current_application_id
() → pyteal.Global¶ Get the ID of the current application executing.
Fails during Signature mode.
-
classmethod
group_id
() → pyteal.Global¶ Get the ID of the current transaction group.
If the current transaction is not part of a group, this will return 32 zero bytes.
Requires TEAL version 5 or higher.
-
classmethod
group_size
() → pyteal.Global¶ Get the number of transactions in this atomic transaction group.
This will be at least 1.
-
classmethod
latest_timestamp
() → pyteal.Global¶ Get the latest confirmed block UNIX timestamp.
Fails if negative.
-
classmethod
logic_sig_version
() → pyteal.Global¶ Get the maximum supported TEAL version.
-
classmethod
max_txn_life
() → pyteal.Global¶ Get the maximum number of rounds a transaction can have.
-
classmethod
min_balance
() → pyteal.Global¶ Get the minumum balance in micro Algos.
-
classmethod
min_txn_fee
() → pyteal.Global¶ Get the minumum transaction fee in micro Algos.
-
classmethod
opcode_budget
() → pyteal.Global¶ Get the remaining opcode execution budget
Requires TEAL version 6 or higher.
-
classmethod
round
() → pyteal.Global¶ Get the current round number.
-
type_of
()¶ Get the return type of this expression.
-
classmethod
zero_address
() → pyteal.Global¶ Get the 32 byte zero address.
-
classmethod
-
class
pyteal.
GlobalField
(id: int, name: str, type: pyteal.TealType, min_version: int)¶ Bases:
enum.Enum
An enumeration.
-
caller_app_address
= (14, 'CallerApplicationAddress', <TealType.bytes: 1>, 6)¶
-
caller_app_id
= (13, 'CallerApplicationID', <TealType.uint64: 0>, 6)¶
-
creator_address
= (9, 'CreatorAddress', <TealType.bytes: 1>, 3)¶
-
current_app_address
= (10, 'CurrentApplicationAddress', <TealType.bytes: 1>, 5)¶
-
current_app_id
= (8, 'CurrentApplicationID', <TealType.uint64: 0>, 2)¶
-
group_id
= (11, 'GroupID', <TealType.bytes: 1>, 5)¶
-
group_size
= (4, 'GroupSize', <TealType.uint64: 0>, 2)¶
-
latest_timestamp
= (7, 'LatestTimestamp', <TealType.uint64: 0>, 2)¶
-
logic_sig_version
= (5, 'LogicSigVersion', <TealType.uint64: 0>, 2)¶
-
max_txn_life
= (2, 'MaxTxnLife', <TealType.uint64: 0>, 2)¶
-
min_balance
= (1, 'MinBalance', <TealType.uint64: 0>, 2)¶
-
min_txn_fee
= (0, 'MinTxnFee', <TealType.uint64: 0>, 2)¶
-
opcode_budget
= (12, 'OpcodeBudget', <TealType.uint64: 0>, 6)¶
-
round
= (6, 'Round', <TealType.uint64: 0>, 2)¶
-
type_of
() → pyteal.TealType¶
-
zero_address
= (3, 'ZeroAddress', <TealType.bytes: 1>, 2)¶
-
-
class
pyteal.
App
(field: pyteal.AppField, args)¶ Bases:
pyteal.LeafExpr
An expression related to applications.
-
classmethod
globalDel
(key: pyteal.Expr) → pyteal.App¶ Delete a key from the global state of the current application.
Parameters: key – The key to delete from the global application state. Must evaluate to bytes.
-
classmethod
globalGet
(key: pyteal.Expr) → pyteal.App¶ Read from the global state of the current application.
Parameters: key – The key to read from the global application state. Must evaluate to bytes.
-
classmethod
globalGetEx
(app: pyteal.Expr, key: pyteal.Expr) → pyteal.MaybeValue¶ Read from the global state of an application.
Parameters: - app – An index into Txn.ForeignApps 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).
- key – The key to read from the global application state. Must evaluate to bytes.
-
classmethod
globalPut
(key: pyteal.Expr, value: pyteal.Expr) → pyteal.App¶ Write to the global state of the current application.
Parameters: - key – The key to write in the global application state. Must evaluate to bytes.
- value – THe value to write in the global application state. Can evaluate to any type.
-
classmethod
id
() → pyteal.Global¶ Get the ID of the current running application.
This is the same as
Global.current_application_id()
.
-
classmethod
localDel
(account: pyteal.Expr, key: pyteal.Expr) → pyteal.App¶ Delete a key from an account’s local state for the current application.
Parameters: - 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).
- key – The key to delete from the account’s local state. Must evaluate to bytes.
-
classmethod
localGet
(account: pyteal.Expr, key: pyteal.Expr) → pyteal.App¶ Read from an account’s local state for the current application.
Parameters: - 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).
- key – The key to read from the account’s local state. Must evaluate to bytes.
-
classmethod
localGetEx
(account: pyteal.Expr, app: pyteal.Expr, key: pyteal.Expr) → pyteal.MaybeValue¶ Read from an account’s local state for an application.
Parameters: - 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, 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).
- key – The key to read from the account’s local state. Must evaluate to bytes.
-
classmethod
localPut
(account: pyteal.Expr, key: pyteal.Expr, value: pyteal.Expr) → pyteal.App¶ Write to an account’s local state for the current application.
Parameters: - 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).
- key – The key to write in the account’s local state. Must evaluate to bytes.
- value – The value to write in the account’s local state. Can evaluate to any type.
-
classmethod
optedIn
(account: pyteal.Expr, app: pyteal.Expr) → pyteal.App¶ Check if an account has opted in for an application.
Parameters: - 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, 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).
-
type_of
()¶ Get the return type of this expression.
-
classmethod
-
class
pyteal.
AppField
(op: pyteal.Op, type: pyteal.TealType)¶ Bases:
enum.Enum
Enum of app fields used to create
App
objects.-
get_op
() → pyteal.Op¶
-
globalDel
= (<Op.app_global_del: OpType(value='app_global_del', mode=<Mode.Application: 2>, min_version=2)>, <TealType.none: 3>)¶
-
globalGet
= (<Op.app_global_get: OpType(value='app_global_get', mode=<Mode.Application: 2>, min_version=2)>, <TealType.anytype: 2>)¶
-
globalGetEx
= (<Op.app_global_get_ex: OpType(value='app_global_get_ex', mode=<Mode.Application: 2>, min_version=2)>, <TealType.none: 3>)¶
-
globalPut
= (<Op.app_global_put: OpType(value='app_global_put', mode=<Mode.Application: 2>, min_version=2)>, <TealType.none: 3>)¶
-
localDel
= (<Op.app_local_del: OpType(value='app_local_del', mode=<Mode.Application: 2>, min_version=2)>, <TealType.none: 3>)¶
-
localGet
= (<Op.app_local_get: OpType(value='app_local_get', mode=<Mode.Application: 2>, min_version=2)>, <TealType.anytype: 2>)¶
-
localGetEx
= (<Op.app_local_get_ex: OpType(value='app_local_get_ex', mode=<Mode.Application: 2>, min_version=2)>, <TealType.none: 3>)¶
-
localPut
= (<Op.app_local_put: OpType(value='app_local_put', mode=<Mode.Application: 2>, min_version=2)>, <TealType.none: 3>)¶
-
optedIn
= (<Op.app_opted_in: OpType(value='app_opted_in', mode=<Mode.Application: 2>, min_version=2)>, <TealType.uint64: 0>)¶
-
type_of
() → pyteal.TealType¶
-
-
class
pyteal.
OnComplete
¶ Bases:
object
An enum of values that
TxnObject.on_completion()
may return.-
ClearState
= <pyteal.EnumInt object>¶
-
CloseOut
= <pyteal.EnumInt object>¶
-
DeleteApplication
= <pyteal.EnumInt object>¶
-
NoOp
= <pyteal.EnumInt object>¶
-
OptIn
= <pyteal.EnumInt object>¶
-
UpdateApplication
= <pyteal.EnumInt object>¶
-
-
class
pyteal.
AppParam
¶ Bases:
object
-
classmethod
address
(app: pyteal.Expr) → pyteal.MaybeValue¶ Get the escrow address for the application.
Parameters: app – An index into Txn.ForeignApps that correspond to the application to check. Must evaluate to uint64.
-
classmethod
approvalProgram
(app: pyteal.Expr) → pyteal.MaybeValue¶ Get the bytecode of Approval Program for the application.
Parameters: app – An index into Txn.ForeignApps that correspond to the application to check. Must evaluate to uint64.
-
classmethod
clearStateProgram
(app: pyteal.Expr) → pyteal.MaybeValue¶ Get the bytecode of Clear State Program for the application.
Parameters: app – An index into Txn.ForeignApps that correspond to the application to check. Must evaluate to uint64.
-
classmethod
creator
(app: pyteal.Expr) → pyteal.MaybeValue¶ Get the creator address for the application.
Parameters: app – An index into Txn.ForeignApps that correspond to the application to check. Must evaluate to uint64.
-
classmethod
extraProgramPages
(app: pyteal.Expr) → pyteal.MaybeValue¶ Get the number of Extra Program Pages of code space for the application.
Parameters: app – An index into Txn.ForeignApps that correspond to the application to check. Must evaluate to uint64.
-
classmethod
globalNumByteSlice
(app: pyteal.Expr) → pyteal.MaybeValue¶ Get the number of byte array values allowed in Global State for the application.
Parameters: app – An index into Txn.ForeignApps that correspond to the application to check. Must evaluate to uint64.
-
classmethod
globalNumUnit
(app: pyteal.Expr) → pyteal.MaybeValue¶ Get the number of uint64 values allowed in Global State for the application.
Parameters: app – An index into Txn.ForeignApps that correspond to the application to check. Must evaluate to uint64.
-
classmethod
localNumByteSlice
(app: pyteal.Expr) → pyteal.MaybeValue¶ Get the number of byte array values allowed in Local State for the application.
Parameters: app – An index into Txn.ForeignApps that correspond to the application to check. Must evaluate to uint64.
-
classmethod
localNumUnit
(app: pyteal.Expr) → pyteal.MaybeValue¶ Get the number of uint64 values allowed in Local State for the application.
Parameters: app – An index into Txn.ForeignApps that correspond to the application to check. Must evaluate to uint64.
-
classmethod
-
class
pyteal.
AssetHolding
¶ Bases:
object
-
classmethod
balance
(account: pyteal.Expr, asset: pyteal.Expr) → pyteal.MaybeValue¶ Get the amount of an asset held by an account.
Parameters: - 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).
- asset – The ID of the asset to get, must be evaluated to uint64 (or, since v4, a Txn.ForeignAssets offset).
-
classmethod
frozen
(account: pyteal.Expr, asset: pyteal.Expr) → pyteal.MaybeValue¶ Check if an asset is frozen for an account.
A value of 1 indicates frozen and 0 indicates not frozen.
Parameters: - 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).
- asset – The ID of the asset to get, must be evaluated to uint64 (or, since v4, a Txn.ForeignAssets offset).
-
classmethod
-
class
pyteal.
AssetParam
¶ Bases:
object
-
classmethod
clawback
(asset: pyteal.Expr) → pyteal.MaybeValue¶ Get the clawback address for an asset.
Parameters: asset – An index into Txn.ForeignAssets that corresponds to the asset to check, must be evaluated to uint64 (or since v4, an asset ID that appears in Txn.ForeignAssets).
-
classmethod
creator
(asset: pyteal.Expr) → pyteal.MaybeValue¶ Get the creator address for an asset.
Parameters: asset – An index into Txn.ForeignAssets that corresponds to the asset to check. Must evaluate to uint64.
-
classmethod
decimals
(asset: pyteal.Expr) → pyteal.MaybeValue¶ Get the number of decimals for an asset.
Parameters: asset – An index into Txn.ForeignAssets that corresponds to the asset to check, must be evaluated to uint64 (or since v4, an asset ID that appears in Txn.ForeignAssets).
-
classmethod
defaultFrozen
(asset: pyteal.Expr) → pyteal.MaybeValue¶ Check if an asset is frozen by default.
Parameters: asset – An index into Txn.ForeignAssets that corresponds to the asset to check, must be evaluated to uint64 (or since v4, an asset ID that appears in Txn.ForeignAssets).
-
classmethod
freeze
(asset: pyteal.Expr) → pyteal.MaybeValue¶ Get the freeze address for an asset.
Parameters: asset – An index into Txn.ForeignAssets that corresponds to the asset to check, must be evaluated to uint64 (or since v4, an asset ID that appears in Txn.ForeignAssets).
-
classmethod
manager
(asset: pyteal.Expr) → pyteal.MaybeValue¶ Get the manager address for an asset.
Parameters: asset – An index into Txn.ForeignAssets that corresponds to the asset to check, must be evaluated to uint64 (or since v4, an asset ID that appears in Txn.ForeignAssets).
-
classmethod
metadataHash
(asset: pyteal.Expr) → pyteal.MaybeValue¶ Get the arbitrary commitment for an asset.
If set, this will be 32 bytes long.
Parameters: asset – An index into Txn.ForeignAssets that corresponds to the asset to check, must be evaluated to uint64 (or since v4, an asset ID that appears in Txn.ForeignAssets).
-
classmethod
name
(asset: pyteal.Expr) → pyteal.MaybeValue¶ Get the name of an asset.
Parameters: asset – An index into Txn.ForeignAssets that corresponds to the asset to check, must be evaluated to uint64 (or since v4, an asset ID that appears in Txn.ForeignAssets).
-
classmethod
reserve
(asset: pyteal.Expr) → pyteal.MaybeValue¶ Get the reserve address for an asset.
Parameters: asset – An index into Txn.ForeignAssets that corresponds to the asset to check, must be evaluated to uint64 (or since v4, an asset ID that appears in Txn.ForeignAssets).
-
classmethod
total
(asset: pyteal.Expr) → pyteal.MaybeValue¶ Get the total number of units of an asset.
Parameters: asset – An index into Txn.ForeignAssets that corresponds to the asset to check, must be evaluated to uint64 (or since v4, an asset ID that appears in Txn.ForeignAssets).
-
classmethod
unitName
(asset: pyteal.Expr) → pyteal.MaybeValue¶ Get the unit name of an asset.
Parameters: asset – An index into Txn.ForeignAssets that corresponds to the asset to check, must be evaluated to uint64 (or since v4, an asset ID that appears in Txn.ForeignAssets).
-
classmethod
url
(asset: pyteal.Expr) → pyteal.MaybeValue¶ Get the URL of an asset.
Parameters: asset – An index into Txn.ForeignAssets that corresponds to the asset to check, must be evaluated to uint64 (or since v4, an asset ID that appears in Txn.ForeignAssets).
-
classmethod
-
class
pyteal.
AccountParam
¶ Bases:
object
-
classmethod
authAddr
(acct: pyteal.Expr) → pyteal.MaybeValue¶ Get the authorizing address for an account. If the account is not rekeyed, the empty addresss is returned.
Parameters: acct – An index into Txn.accounts that corresponds to the application to check or an address available at runtime. May evaluate to uint64 or an address.
-
classmethod
balance
(acct: pyteal.Expr) → pyteal.MaybeValue¶ Get the current balance in microalgos an account.
Parameters: acct – An index into Txn.accounts that corresponds to the application to check or an address available at runtime. May evaluate to uint64 or an address.
-
classmethod
minBalance
(acct: pyteal.Expr) → pyteal.MaybeValue¶ Get the minimum balance in microalgos for an account.
Parameters: acct – An index into Txn.accounts that corresponds to the application to check or an address available at runtime. May evaluate to uint64 or an address.
-
classmethod
-
class
pyteal.
InnerTxnBuilder
¶ Bases:
object
This class represents expressions used to create, modify, and submit inner transactions.
Inner transactions are transactions which applications can dynamically create. Each inner transaction will appear as a transaction inside of the current transaction being executed.
As of TEAL version 5, only the transaction types
TxnType.Payment
,TxnType.AssetTransfer
,TxnType.AssetConfig
, andTxnType.AssetFreeze
are allowed. Additionally, not all fields are allowed to be set. For example, it is not currently allowed to set the rekeyTo field of an inner transaction.-
classmethod
Begin
() → pyteal.Expr¶ Begin preparation of a new inner transaction.
This new inner transaction is initialized with its sender to the application address (
Global.current_application_address
); fee to the minimum allowable, taking into accountMinTxnFee
and credit from overpaying in earlier transactions;FirstValid
/LastValid
to the values in the top-level transaction, and all other fields to zero values.Requires TEAL version 5 or higher. This operation is only permitted in application mode.
-
classmethod
Next
() → pyteal.Expr¶ Begin preparation of a new inner transaction (in the same transaction group).
This new inner transaction is initialized with its sender to the application address (
Global.current_application_address
); fee to the minimum allowable, taking into accountMinTxnFee
and credit from overpaying in earlier transactions;FirstValid
/LastValid
to the values in the top-level transaction, and all other fields to zero values.Requires TEAL version 6 or higher. This operation is only permitted in application mode.
-
classmethod
SetField
(field: pyteal.TxnField, value: Union[pyteal.Expr, List[pyteal.Expr]]) → pyteal.Expr¶ Set a field of the current inner transaction.
InnerTxnBuilder.Begin
must be called before setting any fields on an inner transaction.- Note: For non-array field (e.g., note), setting it twice will overwrite the original value.
- While for array field (e.g., accounts), setting it multiple times will append the values.
Requires TEAL version 5 or higher. This operation is only permitted in application mode.
Parameters: - field – The field to set on the inner transaction.
- value – The value to that the field should take. This must evaluate to a type that is compatible with the field being set.
-
classmethod
SetFields
(fields: Dict[pyteal.TxnField, Union[pyteal.Expr, List[pyteal.Expr]]]) → pyteal.Expr¶ Set multiple fields of the current inner transaction.
InnerTxnBuilder.Begin
must be called before setting any fields on an inner transaction.- Note: For non-array field (e.g., note), setting it twice will overwrite the original value.
- While for array field (e.g., accounts), setting it multiple times will append the values.
Requires TEAL version 5 or higher. This operation is only permitted in application mode.
Parameters: 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.
-
classmethod
Submit
() → pyteal.Expr¶ Execute the current inner transaction.
InnerTxnBuilder.Begin
andInnerTxnBuilder.SetField
must be called before submitting an inner transaction.This will fail if 256 inner transactions have already been executed, or if the inner transaction itself fails. Upon failure, the current program will immediately exit and fail as well.
If the inner transaction is successful, then its effects can be immediately observed by this program with stateful expressions such as
Balance
. Additionally, the fields of the most recently submitted inner transaction can be examined using theInnerTxn
object. If the inner transaction creates an asset, the new asset ID can be found by looking atInnerTxn.created_asset_id()
.Requires TEAL version 5 or higher. This operation is only permitted in application mode.
-
classmethod
-
class
pyteal.
InnerTxnAction
¶ Bases:
enum.Enum
An enumeration.
-
Begin
= <Op.itxn_begin: OpType(value='itxn_begin', mode=<Mode.Application: 2>, min_version=5)>¶
-
Next
= <Op.itxn_next: OpType(value='itxn_next', mode=<Mode.Application: 2>, min_version=6)>¶
-
Submit
= <Op.itxn_submit: OpType(value='itxn_submit', mode=<Mode.Application: 2>, min_version=5)>¶
-
-
class
pyteal.
GitxnExpr
(txnIndex: int, field: pyteal.TxnField)¶ Bases:
pyteal.TxnExpr
An expression that accesses an inner transaction field from an inner transaction in the last inner group.
-
class
pyteal.
GitxnaExpr
(txnIndex: int, field: pyteal.TxnField, index: Union[int, pyteal.Expr])¶ Bases:
pyteal.TxnaExpr
An expression that accesses an inner transaction array field from an inner transaction in the last inner group.
-
class
pyteal.
InnerTxnGroup
¶ Bases:
object
Represents a group of inner transactions.
-
__getitem__
(txnIndex: int) → pyteal.TxnObject¶
-
-
class
pyteal.
Array
¶ Bases:
abc.ABC
Represents a variable length array of objects.
-
__getitem__
(index: int)¶ Get the value at a given index in this array.
-
length
() → pyteal.Expr¶ Get the length of the array.
-
-
class
pyteal.
Tmpl
(op: pyteal.Op, type: pyteal.TealType, name: str)¶ Bases:
pyteal.LeafExpr
Template expression for creating placeholder values.
-
classmethod
Addr
(placeholder: str)¶ Create a new Addr template.
Parameters: placeholder – The name to use for this template variable. Must start with TMPL_ and only consist of uppercase alphanumeric characters and underscores.
-
classmethod
Bytes
(placeholder: str)¶ Create a new Bytes template.
Parameters: placeholder – The name to use for this template variable. Must start with TMPL_ and only consist of uppercase alphanumeric characters and underscores.
-
classmethod
Int
(placeholder: str)¶ Create a new Int template.
Parameters: placeholder – The name to use for this template variable. Must start with TMPL_ and only consist of uppercase alphanumeric characters and underscores.
-
type_of
()¶ Get the return type of this expression.
-
classmethod
-
class
pyteal.
Nonce
(base: str, nonce: str, child: pyteal.Expr)¶ Bases:
pyteal.Expr
A meta expression only used to change the hash of a TEAL program.
-
__init__
(base: str, nonce: str, child: pyteal.Expr) → None¶ Create a new Nonce.
The Nonce expression behaves exactly like the child expression passed into it, except it uses the provided nonce string to alter its structure in a way that does not affect execution.
Parameters: - base – The base of the nonce. Must be one of utf8, base16, base32, or base64.
- nonce – An arbitrary nonce string that conforms to base.
- child – The expression to wrap.
-
has_return
()¶ Check if this expression always returns from the current subroutine or program.
-
type_of
()¶ Get the return type of this expression.
-
-
class
pyteal.
UnaryExpr
(op: pyteal.Op, inputType: pyteal.TealType, outputType: pyteal.TealType, arg: pyteal.Expr)¶ Bases:
pyteal.Expr
An expression with a single argument.
-
has_return
()¶ Check if this expression always returns from the current subroutine or program.
-
type_of
()¶ Get the return type of this expression.
-
-
pyteal.
Btoi
(arg: pyteal.Expr) → pyteal.UnaryExpr¶ Convert a byte string to a uint64.
-
pyteal.
Itob
(arg: pyteal.Expr) → pyteal.UnaryExpr¶ Convert a uint64 string to a byte string.
-
pyteal.
Len
(arg: pyteal.Expr) → pyteal.UnaryExpr¶ Get the length of a byte string.
-
pyteal.
BitLen
(arg: pyteal.Expr) → pyteal.UnaryExpr¶ Get the index of the highest nonzero bit in an integer.
If the argument is 0, 0 will be returned.
If the argument is a byte array, it is interpreted as a big-endian unsigned integer.
Requires TEAL version 4 or higher.
-
pyteal.
Sha256
(arg: pyteal.Expr) → pyteal.UnaryExpr¶ Get the SHA-256 hash of a byte string.
-
pyteal.
Sha512_256
(arg: pyteal.Expr) → pyteal.UnaryExpr¶ Get the SHA-512/256 hash of a byte string.
-
pyteal.
Keccak256
(arg: pyteal.Expr) → pyteal.UnaryExpr¶ Get the KECCAK-256 hash of a byte string.
-
pyteal.
Not
(arg: pyteal.Expr) → pyteal.UnaryExpr¶ Get the logical inverse of a uint64.
If the argument is 0, then this will produce 1. Otherwise this will produce 0.
-
pyteal.
BitwiseNot
(arg: pyteal.Expr) → pyteal.UnaryExpr¶ Get the bitwise inverse of a uint64.
Produces ~arg.
-
pyteal.
Sqrt
(arg: pyteal.Expr) → pyteal.UnaryExpr¶ Get the integer square root of a uint64.
This will return the largest integer X such that X^2 <= arg.
Requires TEAL version 4 or higher.
-
pyteal.
Pop
(arg: pyteal.Expr) → pyteal.UnaryExpr¶ Pop a value from the stack.
-
pyteal.
Balance
(account: pyteal.Expr) → pyteal.UnaryExpr¶ Get the balance of a user in microAlgos.
Argument must be an index into Txn.Accounts that corresponds to the account to read from, must be evaluated to uint64 (or, since v4, an account address that appears in Txn.Accounts or is Txn.Sender).
This operation is only permitted in application mode.
-
pyteal.
MinBalance
(account: pyteal.Expr) → pyteal.UnaryExpr¶ Get the minimum balance of a user in microAlgos.
For more information about minimum balances, see: https://developer.algorand.org/docs/features/accounts/#minimum-balance
Argument must be an index into Txn.Accounts that corresponds to the account to read from, must be evaluated to uint64 (or, since v4, an account address that appears in Txn.Accounts or is Txn.Sender).
Requires TEAL version 3 or higher. This operation is only permitted in application mode.
-
class
pyteal.
BinaryExpr
(op: pyteal.Op, inputType: Union[pyteal.TealType, Tuple[pyteal.TealType, pyteal.TealType]], outputType: pyteal.TealType, argLeft: pyteal.Expr, argRight: pyteal.Expr)¶ Bases:
pyteal.Expr
An expression with two arguments.
-
has_return
()¶ Check if this expression always returns from the current subroutine or program.
-
type_of
()¶ Get the return type of this expression.
-
-
pyteal.
Add
(left: pyteal.Expr, right: pyteal.Expr) → pyteal.BinaryExpr¶ Add two numbers.
Produces left + right.
Parameters: - left – Must evaluate to uint64.
- right – Must evaluate to uint64.
-
pyteal.
Minus
(left: pyteal.Expr, right: pyteal.Expr) → pyteal.BinaryExpr¶ Subtract two numbers.
Produces left - right.
Parameters: - left – Must evaluate to uint64.
- right – Must evaluate to uint64.
-
pyteal.
Mul
(left: pyteal.Expr, right: pyteal.Expr) → pyteal.BinaryExpr¶ Multiply two numbers.
Produces left * right.
Parameters: - left – Must evaluate to uint64.
- right – Must evaluate to uint64.
-
pyteal.
Div
(left: pyteal.Expr, right: pyteal.Expr) → pyteal.BinaryExpr¶ Divide two numbers.
Produces left / right.
Parameters: - left – Must evaluate to uint64.
- right – Must evaluate to uint64.
-
pyteal.
Mod
(left: pyteal.Expr, right: pyteal.Expr) → pyteal.BinaryExpr¶ Modulo expression.
Produces left % right.
Parameters: - left – Must evaluate to uint64.
- right – Must evaluate to uint64.
-
pyteal.
Exp
(a: pyteal.Expr, b: pyteal.Expr) → pyteal.BinaryExpr¶ Exponential expression.
Produces a ** b.
Requires TEAL version 4 or higher.
Parameters: - a – Must evaluate to uint64.
- b – Must evaluate to uint64.
-
pyteal.
Divw
(hi: pyteal.Expr, lo: pyteal.Expr, y: pyteal.Expr) → pyteal.TernaryExpr¶ Performs wide division by interpreting hi and lo as a uint128 value.
Requires TEAL version 6 or higher.
Parameters: - hi – Quotient’s high 64 bits. Must evaluate to uint64.
- lo – Quotient’s low 64 bits. Must evaluate to uint64.
- y – Divisor. Must evaluate to uint64.
-
pyteal.
BitwiseAnd
(left: pyteal.Expr, right: pyteal.Expr) → pyteal.BinaryExpr¶ Bitwise and expression.
Produces left & right.
Parameters: - left – Must evaluate to uint64.
- right – Must evaluate to uint64.
-
pyteal.
BitwiseOr
(left: pyteal.Expr, right: pyteal.Expr) → pyteal.BinaryExpr¶ Bitwise or expression.
Produces left | right.
Parameters: - left – Must evaluate to uint64.
- right – Must evaluate to uint64.
-
pyteal.
BitwiseXor
(left: pyteal.Expr, right: pyteal.Expr) → pyteal.BinaryExpr¶ Bitwise xor expression.
Produces left ^ right.
Parameters: - left – Must evaluate to uint64.
- right – Must evaluate to uint64.
-
pyteal.
ShiftLeft
(a: pyteal.Expr, b: pyteal.Expr) → pyteal.BinaryExpr¶ Bitwise left shift expression.
Produces a << b. This is equivalent to a times 2^b, modulo 2^64.
Requires TEAL version 4 or higher.
Parameters: - a – Must evaluate to uint64.
- b – Must evaluate to uint64.
-
pyteal.
ShiftRight
(a: pyteal.Expr, b: pyteal.Expr) → pyteal.BinaryExpr¶ Bitwise right shift expression.
Produces a >> b. This is equivalent to a divided by 2^b.
Requires TEAL version 4 or higher.
Parameters: - a – Must evaluate to uint64.
- b – Must evaluate to uint64.
-
pyteal.
Eq
(left: pyteal.Expr, right: pyteal.Expr) → pyteal.BinaryExpr¶ Equality expression.
Checks if left == right.
Parameters: - left – A value to check.
- right – The other value to check. Must evaluate to the same type as left.
-
pyteal.
Neq
(left: pyteal.Expr, right: pyteal.Expr) → pyteal.BinaryExpr¶ Difference expression.
Checks if left != right.
Parameters: - left – A value to check.
- right – The other value to check. Must evaluate to the same type as left.
-
pyteal.
Lt
(left: pyteal.Expr, right: pyteal.Expr) → pyteal.BinaryExpr¶ Less than expression.
Checks if left < right.
Parameters: - left – Must evaluate to uint64.
- right – Must evaluate to uint64.
-
pyteal.
Le
(left: pyteal.Expr, right: pyteal.Expr) → pyteal.BinaryExpr¶ Less than or equal to expression.
Checks if left <= right.
Parameters: - left – Must evaluate to uint64.
- right – Must evaluate to uint64.
-
pyteal.
Gt
(left: pyteal.Expr, right: pyteal.Expr) → pyteal.BinaryExpr¶ Greater than expression.
Checks if left > right.
Parameters: - left – Must evaluate to uint64.
- right – Must evaluate to uint64.
-
pyteal.
Ge
(left: pyteal.Expr, right: pyteal.Expr) → pyteal.BinaryExpr¶ Greater than or equal to expression.
Checks if left >= right.
Parameters: - left – Must evaluate to uint64.
- right – Must evaluate to uint64.
-
pyteal.
GetBit
(value: pyteal.Expr, index: pyteal.Expr) → pyteal.BinaryExpr¶ Get the bit value of an expression at a specific index.
The meaning of index differs if value is an integer or a byte string.
- For integers, bit indexing begins with low-order bits. For example,
GetBit(Int(16), Int(4))
yields 1. Any other valid index would yield a bit value of 0. Any integer less than 64 is a valid index. - For byte strings, bit indexing begins at the first byte. For example,
GetBit(Bytes("base16", "0xf0"), Int(0))
yields 1. Any index less than 4 would yield 1, and any valid index 4 or greater would yield 0. Any integer less than 8*Len(value) is a valid index.
Requires TEAL version 3 or higher.
Parameters: - value – The value containing bits. Can evaluate to any type.
- index – The index of the bit to extract. Must evaluate to uint64.
- For integers, bit indexing begins with low-order bits. For example,
-
pyteal.
GetByte
(value: pyteal.Expr, index: pyteal.Expr) → pyteal.BinaryExpr¶ Extract a single byte as an integer from a byte string.
Similar to GetBit, indexing begins at the first byte. For example,
GetByte(Bytes("base16", "0xff0000"), Int(0))
yields 255. Any other valid index would yield 0.Requires TEAL version 3 or higher.
Parameters: - value – The value containing the bytes. Must evaluate to bytes.
- index – The index of the byte to extract. Must evaluate to an integer less than Len(value).
-
pyteal.
Ed25519Verify
(data: pyteal.Expr, sig: pyteal.Expr, key: pyteal.Expr) → pyteal.TernaryExpr¶ Verify the ed25519 signature of the concatenation (“ProgData” + hash_of_current_program + data).
Parameters: - data – The data signed by the public key. Must evalutes to bytes.
- sig – The proposed 64-byte signature of the concatenation (“ProgData” + hash_of_current_program + data). Must evalute to bytes.
- key – The 32 byte public key that produced the signature. Must evaluate to bytes.
-
pyteal.
Substring
(string: pyteal.Expr, start: pyteal.Expr, end: pyteal.Expr) → pyteal.Expr¶ Take a substring of a byte string.
Produces a new byte string consisting of the bytes starting at
start
up to but not includingend
.This expression is similar to
Extract
, except this expression uses start and end indexes, whileExtract
uses a start index and length.Requires TEAL version 2 or higher.
Parameters: - string – The byte string.
- start – The starting index for the substring. Must be an integer less than or equal to
Len(string)
. - end – The ending index for the substring. Must be an integer greater or equal to start, but less than or equal to Len(string).
-
pyteal.
Extract
(string: pyteal.Expr, start: pyteal.Expr, length: pyteal.Expr) → pyteal.Expr¶ Extract a section of a byte string.
Produces a new byte string consisting of the bytes starting at
start
up to but not includingstart + length
.This expression is similar to
Substring
, except this expression uses a start index and length, whileSubstring
uses start and end indexes.Requires TEAL version 5 or higher.
Parameters: - string – The byte string.
- start – The starting index for the extraction. Must be an integer less than or equal to
Len(string)
. - length – The number of bytes to extract. Must be an integer such that
start + length <= Len(string)
.
-
pyteal.
Suffix
(string: pyteal.Expr, start: pyteal.Expr) → pyteal.Expr¶ Take a suffix of a byte string.
Produces a new byte string consisting of the suffix of the byte string starting at
start
This expression is similar to
Substring
andExtract
, except this expression only uses a start index.Requires TEAL version 5 or higher.
Parameters: - string – The byte string.
- start – The starting index for the suffix. Must be an integer less than or equal to
Len(string)
.
-
pyteal.
SetBit
(value: pyteal.Expr, index: pyteal.Expr, newBitValue: pyteal.Expr) → pyteal.TernaryExpr¶ Set the bit value of an expression at a specific index.
The meaning of index differs if value is an integer or a byte string.
- For integers, bit indexing begins with low-order bits. For example,
SetBit(Int(0), Int(4), Int(1))
yields the integer 16 (2^4). Any integer less than 64 is a valid index. - For byte strings, bit indexing begins at the first byte. For example,
SetBit(Bytes("base16", "0x00"), Int(7), Int(1))
yields the byte string 0x01. Any integer less than 8*Len(value) is a valid index.
Requires TEAL version 3 or higher.
Parameters: - value – The value containing bits. Can evaluate to any type.
- index – The index of the bit to set. Must evaluate to uint64.
- newBitValue – The new bit value to set. Must evaluate to the integer 0 or 1.
- For integers, bit indexing begins with low-order bits. For example,
-
pyteal.
SetByte
(value: pyteal.Expr, index: pyteal.Expr, newByteValue: pyteal.Expr) → pyteal.TernaryExpr¶ Set a single byte in a byte string from an integer value.
Similar to SetBit, indexing begins at the first byte. For example,
SetByte(Bytes("base16", "0x000000"), Int(0), Int(255))
yields the byte string 0xff0000.Requires TEAL version 3 or higher.
Parameters: - value – The value containing the bytes. Must evaluate to bytes.
- index – The index of the byte to set. Must evaluate to an integer less than Len(value).
- newByteValue – The new byte value to set. Must evaluate to an integer less than 256.
-
class
pyteal.
NaryExpr
(op: pyteal.Op, inputType: pyteal.TealType, outputType: pyteal.TealType, args: Sequence[pyteal.Expr])¶ Bases:
pyteal.Expr
N-ary expression base class.
This type of expression takes an arbitrary number of arguments.
-
has_return
()¶ Check if this expression always returns from the current subroutine or program.
-
type_of
()¶ Get the return type of this expression.
-
-
pyteal.
And
(*args) → pyteal.NaryExpr¶ Logical and expression.
Produces 1 if all arguments are nonzero. Otherwise produces 0.
All arguments must be PyTeal expressions that evaluate to uint64, and there must be at least one argument.
Example
And(Txn.amount() == Int(500), Txn.fee() <= Int(10))
-
pyteal.
Or
(*args) → pyteal.NaryExpr¶ Logical or expression.
Produces 1 if any argument is nonzero. Otherwise produces 0.
All arguments must be PyTeal expressions that evaluate to uint64, and there must be at least one argument.
-
pyteal.
Concat
(*args) → pyteal.NaryExpr¶ Concatenate byte strings.
Produces a new byte string consisting of the contents of each of the passed in byte strings joined together.
All arguments must be PyTeal expressions that evaluate to bytes, and there must be at least one argument.
Example
Concat(Bytes("hello"), Bytes(" "), Bytes("world"))
-
class
pyteal.
WideRatio
(numeratorFactors: List[pyteal.Expr], denominatorFactors: List[pyteal.Expr])¶ Bases:
pyteal.Expr
A class used to calculate expressions of the form
(N_1 * N_2 * N_3 * ...) / (D_1 * D_2 * D_3 * ...)
Use this class if all inputs to the expression are uint64s, the output fits in a uint64, and all intermediate values fit in a uint128.
-
__init__
(numeratorFactors: List[pyteal.Expr], denominatorFactors: List[pyteal.Expr]) → None¶ Create a new WideRatio expression with the given numerator and denominator factors.
This will calculate
(N_1 * N_2 * N_3 * ...) / (D_1 * D_2 * D_3 * ...)
, where eachN_i
represents an element innumeratorFactors
and eachD_i
represents an element indenominatorFactors
.Requires TEAL version 5 or higher.
Parameters: - numeratorFactors – The factors in the numerator of the ratio. This list must have at least 1 element. If this list has exactly 1 element, then denominatorFactors must have more than 1 element (otherwise basic division should be used).
- denominatorFactors – The factors in the denominator of the ratio. This list must have at least 1 element.
-
has_return
()¶ Check if this expression always returns from the current subroutine or program.
-
type_of
()¶ Get the return type of this expression.
-
-
class
pyteal.
If
(cond: pyteal.Expr, thenBranch: pyteal.Expr = None, elseBranch: pyteal.Expr = None)¶ Bases:
pyteal.Expr
Simple two-way conditional expression.
-
Else
(elseBranch: pyteal.Expr)¶
-
ElseIf
(cond)¶
-
Then
(thenBranch: pyteal.Expr)¶
-
__init__
(cond: pyteal.Expr, thenBranch: pyteal.Expr = None, elseBranch: pyteal.Expr = None) → None¶ Create a new If expression.
When this If expression is executed, the condition will be evaluated, and if it produces a true value, thenBranch will be executed and used as the return value for this expression. Otherwise, elseBranch will be executed and used as the return value, if it is provided.
Parameters: - cond – The condition to check. Must evaluate to uint64.
- thenBranch – Expression to evaluate if the condition is true.
- elseBranch (optional) – Expression to evaluate if the condition is false. Must evaluate to the same type as thenBranch, if provided. Defaults to None.
-
has_return
()¶ Check if this expression always returns from the current subroutine or program.
-
type_of
()¶ Get the return type of this expression.
-
-
class
pyteal.
Cond
(*argv)¶ Bases:
pyteal.Expr
A chainable branching expression that supports an arbitrary number of conditions.
-
__init__
(*argv)¶ Create a new Cond expression.
At least one argument must be provided, and each argument must be a list with two elements. The first element is a condition which evalutes to uint64, and the second is the body of the condition, which will execute if that condition is true. All condition bodies must have the same return type. During execution, each condition is tested in order, and the first condition to evaluate to a true value will cause its associated body to execute and become the value for this Cond expression. If no condition evalutes to a true value, the Cond expression produces an error and the TEAL program terminates.
Example
Cond([Global.group_size() == Int(5), bid], [Global.group_size() == Int(4), redeem], [Global.group_size() == Int(1), wrapup])
-
has_return
()¶ Check if this expression always returns from the current subroutine or program.
-
type_of
()¶ Get the return type of this expression.
-
-
class
pyteal.
Seq
(*exprs)¶ Bases:
pyteal.Expr
A control flow expression to represent a sequence of expressions.
-
__init__
(*exprs)¶ Create a new Seq expression.
The new Seq expression will take on the return value of the final expression in the sequence.
Parameters: exprs – The expressions to include in this sequence. All expressions that are not the final one in this list must not return any values. Example
Seq([ App.localPut(Bytes("key"), Bytes("value")), Int(1) ])
-
has_return
()¶ Check if this expression always returns from the current subroutine or program.
-
type_of
()¶ Get the return type of this expression.
-
-
class
pyteal.
Assert
(cond: pyteal.Expr)¶ Bases:
pyteal.Expr
A control flow expression to verify that a condition is true.
-
__init__
(cond: pyteal.Expr) → None¶ Create an assert statement that raises an error if the condition is false.
Parameters: cond – The condition to check. Must evaluate to a uint64.
-
has_return
()¶ Check if this expression always returns from the current subroutine or program.
-
type_of
()¶ Get the return type of this expression.
-
-
class
pyteal.
Err
¶ Bases:
pyteal.Expr
Expression that causes the program to immediately fail when executed.
-
has_return
()¶ Check if this expression always returns from the current subroutine or program.
-
type_of
()¶ Get the return type of this expression.
-
-
class
pyteal.
Return
(value: pyteal.Expr = None)¶ Bases:
pyteal.Expr
Return a value from the current execution context.
-
__init__
(value: pyteal.Expr = None) → None¶ Create a new Return expression.
If called from the main program, this will immediately exit the program and the value returned will be the program’s success value (must be a uint64, 0 indicates failure, 1 or greater indicates success).
If called from within a subroutine, this will return from the current subroutine with either no value if the subroutine does not produce a return value, or the given return value if it does produce a return value.
-
has_return
()¶ Check if this expression always returns from the current subroutine or program.
-
type_of
()¶ Get the return type of this expression.
-
-
pyteal.
Approve
() → pyteal.Expr¶ Immediately exit the program and mark the execution as successful.
-
pyteal.
Reject
() → pyteal.Expr¶ Immediately exit the program and mark the execution as unsuccessful.
-
class
pyteal.
Subroutine
(returnType: pyteal.TealType, name: str = None)¶ Bases:
object
Used to create a PyTeal subroutine from a Python function.
This class is meant to be used as a function decorator. For example:
@Subroutine(TealType.uint64) def mySubroutine(a: Expr, b: Expr) -> Expr: return a + b program = Seq([ App.globalPut(Bytes("key"), mySubroutine(Int(1), Int(2))), Approve(), ])
-
__init__
(returnType: pyteal.TealType, name: str = None) → None¶ Define a new subroutine with the given return type.
Parameters: returnType – The type that the return value of this subroutine must conform to. TealType.none indicates that this subroutine does not return any value.
-
-
class
pyteal.
SubroutineDefinition
(implementation: Callable[[...], pyteal.Expr], returnType: pyteal.TealType, nameStr: str = None)¶ Bases:
object
-
argumentCount
() → int¶
-
getDeclaration
() → pyteal.SubroutineDeclaration¶
-
invoke
(args: List[pyteal.Expr]) → pyteal.SubroutineCall¶
-
name
() → str¶
-
nextSubroutineId
= 0¶
-
-
class
pyteal.
SubroutineDeclaration
(subroutine: pyteal.SubroutineDefinition, body: pyteal.Expr)¶ Bases:
pyteal.Expr
-
has_return
()¶ Check if this expression always returns from the current subroutine or program.
-
type_of
()¶ Get the return type of this expression.
-
-
class
pyteal.
SubroutineCall
(subroutine: pyteal.SubroutineDefinition, args: List[pyteal.Expr])¶ Bases:
pyteal.Expr
-
has_return
()¶ Check if this expression always returns from the current subroutine or program.
-
type_of
()¶ Get the return type of this expression.
-
-
class
pyteal.
SubroutineFnWrapper
(fnImplementation: Callable[[...], pyteal.Expr], returnType: pyteal.TealType, name: str = None)¶ Bases:
object
-
has_return
()¶
-
name
() → str¶
-
type_of
()¶
-
-
class
pyteal.
ScratchSlot
(requestedSlotId: int = None)¶ Bases:
object
Represents the allocation of a scratch space slot.
-
__init__
(requestedSlotId: int = None)¶ Initializes a scratch slot with a particular id
Parameters: - requestedSlotId (optional) – A scratch slot id that the compiler must store the value.
- id may be a Python int in the range [0-256) (This) –
-
load
(type: pyteal.TealType = <TealType.anytype: 2>) → pyteal.ScratchLoad¶ Get an expression to load a value from this slot.
Parameters: type (optional) – The type being loaded from this slot, if known. Defaults to TealType.anytype.
-
nextSlotId
= 256¶
-
store
(value: pyteal.Expr = None) → pyteal.Expr¶ Get an expression to store a value in this slot.
Parameters: - value (optional) – The value to store in this slot. If not included, the last value on
- stack will be stored. NOTE (the) – storing the last value on the stack breaks the typical
- of PyTeal, only use if you know what you're doing. (semantics) –
-
-
class
pyteal.
ScratchLoad
(slot: pyteal.ScratchSlot, type: pyteal.TealType = <TealType.anytype: 2>)¶ Bases:
pyteal.Expr
Expression to load a value from scratch space.
-
__init__
(slot: pyteal.ScratchSlot, type: pyteal.TealType = <TealType.anytype: 2>)¶ Create a new ScratchLoad expression.
Parameters: - slot – The slot to load the value from.
- type (optional) – The type being loaded from this slot, if known. Defaults to TealType.anytype.
-
has_return
()¶ Check if this expression always returns from the current subroutine or program.
-
type_of
()¶ Get the return type of this expression.
-
-
class
pyteal.
ScratchStore
(slot: pyteal.ScratchSlot, value: pyteal.Expr)¶ Bases:
pyteal.Expr
Expression to store a value in scratch space.
-
__init__
(slot: pyteal.ScratchSlot, value: pyteal.Expr)¶ Create a new ScratchStore expression.
Parameters: - slot – The slot to store the value in.
- value – The value to store.
-
has_return
()¶ Check if this expression always returns from the current subroutine or program.
-
type_of
()¶ Get the return type of this expression.
-
-
class
pyteal.
ScratchStackStore
(slot: pyteal.ScratchSlot)¶ Bases:
pyteal.Expr
Expression to store a value from the stack in scratch space.
NOTE: This expression breaks the typical semantics of PyTeal, only use if you know what you’re doing.
-
__init__
(slot: pyteal.ScratchSlot)¶ Create a new ScratchStackStore expression.
Parameters: slot – The slot to store the value in.
-
has_return
()¶ Check if this expression always returns from the current subroutine or program.
-
type_of
()¶ Get the return type of this expression.
-
-
class
pyteal.
ScratchVar
(type: pyteal.TealType = <TealType.anytype: 2>, slotId: int = None)¶ Bases:
object
Interface around Scratch space, similar to get/put local/global state
Example
myvar = ScratchVar(TealType.uint64) Seq([ myvar.store(Int(5)), Assert(myvar.load() == Int(5)) ])
-
__init__
(type: pyteal.TealType = <TealType.anytype: 2>, slotId: int = None)¶ Create a new ScratchVar with an optional type.
Parameters: - type (optional) – The type that this variable can hold. An error will be thrown if an expression with an incompatible type is stored in this variable. Defaults to TealType.anytype.
- slotId (optional) – A scratch slot id that the compiler must store the value. This id may be a Python int in the range [0-256).
-
load
() → pyteal.ScratchLoad¶ Load value from Scratch Space
-
storage_type
() → pyteal.TealType¶ Get the type of expressions that can be stored in this ScratchVar.
-
store
(value: pyteal.Expr) → pyteal.Expr¶ Store value in Scratch Space
Parameters: value – The value to store. Must conform to this ScratchVar’s type.
-
-
class
pyteal.
MaybeValue
(op: pyteal.Op, type: pyteal.TealType, *, immediate_args: List[Union[str, int]] = None, args: List[pyteal.Expr] = None)¶ Bases:
pyteal.MultiValue
Represents a get operation returning a value that may not exist.
-
__init__
(op: pyteal.Op, type: pyteal.TealType, *, immediate_args: List[Union[str, int]] = None, args: List[pyteal.Expr] = None)¶ Create a new MaybeValue.
Parameters: - op – The operation that returns values.
- type – The type of the returned value.
- immediate_args (optional) – Immediate arguments for the op. Defaults to None.
- args (optional) – Stack arguments for the op. Defaults to None.
-
hasValue
() → pyteal.ScratchLoad¶ Check if the value exists.
This will return 1 if the value exists, otherwise 0.
-
slotOk
¶ Get the scratch slot that stores hasValue.
Note: This is mainly added for backwards compatability and normally shouldn’t be used directly in pyteal code.
-
slotValue
¶ Get the scratch slot that stores the value or the zero value for the type if the value doesn’t exist.
Note: This is mainly added for backwards compatability and normally shouldn’t be used directly in pyteal code.
-
value
() → pyteal.ScratchLoad¶ Get the value.
If the value exists, it will be returned. Otherwise, the zero value for this type will be returned (i.e. either 0 or an empty byte string, depending on the type).
-
-
class
pyteal.
MultiValue
(op: pyteal.Op, types: List[pyteal.TealType], *, immediate_args: List[Union[str, int]] = None, args: List[pyteal.Expr] = None)¶ Bases:
pyteal.LeafExpr
Represents an operation that returns more than one value
-
__init__
(op: pyteal.Op, types: List[pyteal.TealType], *, immediate_args: List[Union[str, int]] = None, args: List[pyteal.Expr] = None)¶ Create a new MultiValue.
Parameters: - op – The operation that returns values.
- types – The types of the returned values.
- immediate_args (optional) – Immediate arguments for the op. Defaults to None.
- args (optional) – Stack arguments for the op. Defaults to None.
-
outputReducer
(reducer: Callable[[...], pyteal.Expr]) → pyteal.Expr¶
-
type_of
()¶ Get the return type of this expression.
-
-
pyteal.
BytesAdd
(left: pyteal.Expr, right: pyteal.Expr) → pyteal.BinaryExpr¶ Add two numbers as bytes.
Produces left + right, where left and right are interpreted as big-endian unsigned integers. Arguments must not exceed 64 bytes.
Requires TEAL version 4 or higher.
Parameters: - left – Must evaluate to bytes.
- right – Must evaluate to bytes.
-
pyteal.
BytesMinus
(left: pyteal.Expr, right: pyteal.Expr) → pyteal.BinaryExpr¶ Subtract two numbers as bytes.
Produces left - right, where left and right are interpreted as big-endian unsigned integers. Arguments must not exceed 64 bytes.
Requires TEAL version 4 or higher.
Parameters: - left – Must evaluate to bytes.
- right – Must evaluate to bytes.
-
pyteal.
BytesDiv
(left: pyteal.Expr, right: pyteal.Expr) → pyteal.BinaryExpr¶ Divide two numbers as bytes.
Produces left / right, where left and right are interpreted as big-endian unsigned integers. Arguments must not exceed 64 bytes.
Panics if right is 0.
Requires TEAL version 4 or higher.
Parameters: - left – Must evaluate to bytes.
- right – Must evaluate to bytes.
-
pyteal.
BytesMul
(left: pyteal.Expr, right: pyteal.Expr) → pyteal.BinaryExpr¶ Multiply two numbers as bytes.
Produces left * right, where left and right are interpreted as big-endian unsigned integers. Arguments must not exceed 64 bytes.
Requires TEAL version 4 or higher.
Parameters: - left – Must evaluate to bytes.
- right – Must evaluate to bytes.
-
pyteal.
BytesMod
(left: pyteal.Expr, right: pyteal.Expr) → pyteal.BinaryExpr¶ Modulo expression with bytes as arguments.
Produces left % right, where left and right are interpreted as big-endian unsigned integers. Arguments must not exceed 64 bytes.
Panics if right is 0.
Requires TEAL version 4 or higher.
Parameters: - left – Must evaluate to bytes.
- right – Must evaluate to bytes.
-
pyteal.
BytesAnd
(left: pyteal.Expr, right: pyteal.Expr) → pyteal.BinaryExpr¶ Bitwise and expression with bytes as arguments.
Produces left & right. Left and right are zero-left extended to the greater of their lengths. Arguments must not exceed 64 bytes.
Requires TEAL version 4 or higher.
Parameters: - left – Must evaluate to bytes.
- right – Must evaluate to bytes.
-
pyteal.
BytesOr
(left: pyteal.Expr, right: pyteal.Expr) → pyteal.BinaryExpr¶ Bitwise or expression with bytes as arguments.
Produces left | right. Left and right are zero-left extended to the greater of their lengths. Arguments must not exceed 64 bytes.
Requires TEAL version 4 or higher.
Parameters: - left – Must evaluate to bytes.
- right – Must evaluate to bytes.
-
pyteal.
BytesXor
(left: pyteal.Expr, right: pyteal.Expr) → pyteal.BinaryExpr¶ Bitwise xor expression with bytes as arguments.
Produces left ^ right. Left and right are zero-left extended to the greater of their lengths. Arguments must not exceed 64 bytes.
Requires TEAL version 4 or higher.
Parameters: - left – Must evaluate to bytes.
- right – Must evaluate to bytes.
-
pyteal.
BytesEq
(left: pyteal.Expr, right: pyteal.Expr) → pyteal.BinaryExpr¶ Equality expression with bytes as arguments.
Checks if left == right, where left and right are interpreted as big-endian unsigned integers. Arguments must not exceed 64 bytes.
Requires TEAL version 4 or higher.
Parameters: - left – Must evaluate to bytes.
- right – Must evaluate to bytes.
-
pyteal.
BytesNeq
(left: pyteal.Expr, right: pyteal.Expr) → pyteal.BinaryExpr¶ Difference expression with bytes as arguments.
Checks if left != right, where left and right are interpreted as big-endian unsigned integers. Arguments must not exceed 64 bytes.
Requires TEAL version 4 or higher.
Parameters: - left – Must evaluate to bytes.
- right – Must evaluate to bytes.
-
pyteal.
BytesLt
(left: pyteal.Expr, right: pyteal.Expr) → pyteal.BinaryExpr¶ Less than expression with bytes as arguments.
Checks if left < right, where left and right are interpreted as big-endian unsigned integers. Arguments must not exceed 64 bytes.
Requires TEAL version 4 or higher.
Parameters: - left – Must evaluate to bytes.
- right – Must evaluate to bytes.
-
pyteal.
BytesLe
(left: pyteal.Expr, right: pyteal.Expr) → pyteal.BinaryExpr¶ Less than or equal to expression with bytes as arguments.
Checks if left <= right, where left and right are interpreted as big-endian unsigned integers. Arguments must not exceed 64 bytes.
Requires TEAL version 4 or higher.
Parameters: - left – Must evaluate to bytes.
- right – Must evaluate to bytes.
-
pyteal.
BytesGt
(left: pyteal.Expr, right: pyteal.Expr) → pyteal.BinaryExpr¶ Greater than expression with bytes as arguments.
Checks if left > right, where left and right are interpreted as big-endian unsigned integers. Arguments must not exceed 64 bytes.
Requires TEAL version 4 or higher.
Parameters: - left – Must evaluate to bytes.
- right – Must evaluate to bytes.
-
pyteal.
BytesGe
(left: pyteal.Expr, right: pyteal.Expr) → pyteal.BinaryExpr¶ Greater than or equal to expression with bytes as arguments.
Checks if left >= right, where left and right are interpreted as big-endian unsigned integers. Arguments must not exceed 64 bytes.
Requires TEAL version 4 or higher.
Parameters: - left – Must evaluate to bytes.
- right – Must evaluate to bytes.
-
pyteal.
BytesNot
(arg: pyteal.Expr) → pyteal.UnaryExpr¶ Get the bitwise inverse of bytes.
Produces ~arg. Argument must not exceed 64 bytes.
Requires TEAL version 4 or higher.
-
pyteal.
BytesSqrt
(arg: pyteal.Expr) → pyteal.UnaryExpr¶ Get the bytes square root of bytes.
This will return the largest integer X such that X^2 <= arg.
Requires TEAL version 6 or higher.
-
pyteal.
BytesZero
(arg: pyteal.Expr) → pyteal.UnaryExpr¶ Get a byte-array of a specified length, containing all zero bytes.
Argument must evaluate to uint64.
Requires TEAL version 4 or higher.
-
pyteal.
ExtractUint16
(string: pyteal.Expr, offset: pyteal.Expr) → pyteal.BinaryExpr¶ Extract 2 bytes (16 bits) and convert them to an integer.
The bytes starting at
offset
up to but not includingoffset + 2
will be interpreted as a big-endian unsigned integer.If
offset + 2
exceedsLen(string)
, the program fails.Requires TEAL version 5 or higher.
Parameters: - string – The bytestring to extract from. Must evaluate to bytes.
- offset – The offset in the bytestring to start extracing. Must evaluate to uint64.
-
pyteal.
ExtractUint32
(string: pyteal.Expr, offset: pyteal.Expr) → pyteal.BinaryExpr¶ Extract 4 bytes (32 bits) and convert them to an integer.
The bytes starting at
offset
up to but not includingoffset + 4
will be interpreted as a big-endian unsigned integer.If
offset + 4
exceedsLen(string)
, the program fails.Requires TEAL version 5 or higher.
Parameters: - string – The bytestring to extract from. Must evaluate to bytes.
- offset – The offset in the bytestring to start extracing. Must evaluate to uint64.
-
pyteal.
ExtractUint64
(string: pyteal.Expr, offset: pyteal.Expr) → pyteal.BinaryExpr¶ Extract 8 bytes (64 bits) and convert them to an integer.
The bytes starting at
offset
up to but not includingoffset + 8
will be interpreted as a big-endian unsigned integer.If
offset + 8
exceedsLen(string)
, the program fails.Requires TEAL version 5 or higher.
Parameters: - string – The bytestring to extract from. Must evaluate to bytes.
- offset – The offset in the bytestring to start extracing. Must evaluate to uint64.
-
pyteal.
Log
(message: pyteal.Expr) → pyteal.UnaryExpr¶ Write a message to log state of the current application.
This will fail if called more than
MaxLogCalls
times in a program (32 as of TEAL v5), or if the sum of the lengths of all logged messages in a program exceeds 1024 bytes.Parameters: message – The message to write. Must evaluate to bytes. Requires TEAL version 5 or higher.
-
class
pyteal.
While
(cond: pyteal.Expr)¶ Bases:
pyteal.Expr
While expression.
-
Do
(doBlock: pyteal.Expr)¶
-
__init__
(cond: pyteal.Expr) → None¶ Create a new While expression.
When this While expression is executed, the condition will be evaluated, and if it produces a true value, doBlock will be executed and return to the start of the expression execution. Otherwise, no branch will be executed.
Parameters: cond – The condition to check. Must evaluate to uint64.
-
has_return
()¶ Check if this expression always returns from the current subroutine or program.
-
type_of
()¶ Get the return type of this expression.
-
-
class
pyteal.
For
(start: pyteal.Expr, cond: pyteal.Expr, step: pyteal.Expr)¶ Bases:
pyteal.Expr
For expression.
-
Do
(doBlock: pyteal.Expr)¶
-
__init__
(start: pyteal.Expr, cond: pyteal.Expr, step: pyteal.Expr) → None¶ Create a new For expression.
When this For expression is executed, the condition will be evaluated, and if it produces a true value, doBlock will be executed and return to the start of the expression execution. Otherwise, no branch will be executed.
Parameters: - start – Expression setting the variable’s initial value
- cond – The condition to check. Must evaluate to uint64.
- step – Expression to update the variable’s value.
-
has_return
()¶ Check if this expression always returns from the current subroutine or program.
-
type_of
()¶ Get the return type of this expression.
-
-
class
pyteal.
Break
¶ Bases:
pyteal.Expr
A break expression
-
__init__
() → None¶ Create a new break expression.
This operation is only permitted in a loop.
-
has_return
()¶ Check if this expression always returns from the current subroutine or program.
-
type_of
()¶ Get the return type of this expression.
-
-
class
pyteal.
Continue
¶ Bases:
pyteal.Expr
A continue expression
-
__init__
() → None¶ Create a new continue expression.
This operation is only permitted in a loop.
-
has_return
()¶ Check if this expression always returns from the current subroutine or program.
-
type_of
()¶ Get the return type of this expression.
-
-
class
pyteal.
Op
¶ Bases:
enum.Enum
Enum of program opcodes.
-
acct_params_get
= OpType(value='acct_params_get', mode=<Mode.Application: 2>, min_version=6)¶
-
add
= OpType(value='+', mode=<Mode.Application|Signature: 3>, min_version=2)¶
-
addr
= OpType(value='addr', mode=<Mode.Application|Signature: 3>, min_version=2)¶
-
addw
= OpType(value='addw', mode=<Mode.Application|Signature: 3>, min_version=2)¶
-
app_global_del
= OpType(value='app_global_del', mode=<Mode.Application: 2>, min_version=2)¶
-
app_global_get
= OpType(value='app_global_get', mode=<Mode.Application: 2>, min_version=2)¶
-
app_global_get_ex
= OpType(value='app_global_get_ex', mode=<Mode.Application: 2>, min_version=2)¶
-
app_global_put
= OpType(value='app_global_put', mode=<Mode.Application: 2>, min_version=2)¶
-
app_local_del
= OpType(value='app_local_del', mode=<Mode.Application: 2>, min_version=2)¶
-
app_local_get
= OpType(value='app_local_get', mode=<Mode.Application: 2>, min_version=2)¶
-
app_local_get_ex
= OpType(value='app_local_get_ex', mode=<Mode.Application: 2>, min_version=2)¶
-
app_local_put
= OpType(value='app_local_put', mode=<Mode.Application: 2>, min_version=2)¶
-
app_opted_in
= OpType(value='app_opted_in', mode=<Mode.Application: 2>, min_version=2)¶
-
app_params_get
= OpType(value='app_params_get', mode=<Mode.Application: 2>, min_version=5)¶
-
arg
= OpType(value='arg', mode=<Mode.Signature: 1>, min_version=2)¶
-
args
= OpType(value='args', mode=<Mode.Signature: 1>, min_version=5)¶
-
assert_
= OpType(value='assert', mode=<Mode.Application|Signature: 3>, min_version=3)¶
-
asset_holding_get
= OpType(value='asset_holding_get', mode=<Mode.Application: 2>, min_version=2)¶
-
asset_params_get
= OpType(value='asset_params_get', mode=<Mode.Application: 2>, min_version=2)¶
-
b
= OpType(value='b', mode=<Mode.Application|Signature: 3>, min_version=2)¶
-
b_add
= OpType(value='b+', mode=<Mode.Application|Signature: 3>, min_version=4)¶
-
b_and
= OpType(value='b&', mode=<Mode.Application|Signature: 3>, min_version=4)¶
-
b_div
= OpType(value='b/', mode=<Mode.Application|Signature: 3>, min_version=4)¶
-
b_eq
= OpType(value='b==', mode=<Mode.Application|Signature: 3>, min_version=4)¶
-
b_ge
= OpType(value='b>=', mode=<Mode.Application|Signature: 3>, min_version=4)¶
-
b_gt
= OpType(value='b>', mode=<Mode.Application|Signature: 3>, min_version=4)¶
-
b_le
= OpType(value='b<=', mode=<Mode.Application|Signature: 3>, min_version=4)¶
-
b_lt
= OpType(value='b<', mode=<Mode.Application|Signature: 3>, min_version=4)¶
-
b_minus
= OpType(value='b-', mode=<Mode.Application|Signature: 3>, min_version=4)¶
-
b_mod
= OpType(value='b%', mode=<Mode.Application|Signature: 3>, min_version=4)¶
-
b_mul
= OpType(value='b*', mode=<Mode.Application|Signature: 3>, min_version=4)¶
-
b_neq
= OpType(value='b!=', mode=<Mode.Application|Signature: 3>, min_version=4)¶
-
b_not
= OpType(value='b~', mode=<Mode.Application|Signature: 3>, min_version=4)¶
-
b_or
= OpType(value='b|', mode=<Mode.Application|Signature: 3>, min_version=4)¶
-
b_xor
= OpType(value='b^', mode=<Mode.Application|Signature: 3>, min_version=4)¶
-
balance
= OpType(value='balance', mode=<Mode.Application: 2>, min_version=2)¶
-
bitlen
= OpType(value='bitlen', mode=<Mode.Application|Signature: 3>, min_version=4)¶
-
bitwise_and
= OpType(value='&', mode=<Mode.Application|Signature: 3>, min_version=2)¶
-
bitwise_not
= OpType(value='~', mode=<Mode.Application|Signature: 3>, min_version=2)¶
-
bitwise_or
= OpType(value='|', mode=<Mode.Application|Signature: 3>, min_version=2)¶
-
bitwise_xor
= OpType(value='^', mode=<Mode.Application|Signature: 3>, min_version=2)¶
-
bnz
= OpType(value='bnz', mode=<Mode.Application|Signature: 3>, min_version=2)¶
-
bsqrt
= OpType(value='bsqrt', mode=<Mode.Application|Signature: 3>, min_version=6)¶
-
btoi
= OpType(value='btoi', mode=<Mode.Application|Signature: 3>, min_version=2)¶
-
byte
= OpType(value='byte', mode=<Mode.Application|Signature: 3>, min_version=2)¶
-
bytec
= OpType(value='bytec', mode=<Mode.Application|Signature: 3>, min_version=2)¶
-
bytec_0
= OpType(value='bytec_0', mode=<Mode.Application|Signature: 3>, min_version=2)¶
-
bytec_1
= OpType(value='bytec_1', mode=<Mode.Application|Signature: 3>, min_version=2)¶
-
bytec_2
= OpType(value='bytec_2', mode=<Mode.Application|Signature: 3>, min_version=2)¶
-
bytec_3
= OpType(value='bytec_3', mode=<Mode.Application|Signature: 3>, min_version=2)¶
-
bytecblock
= OpType(value='bytecblock', mode=<Mode.Application|Signature: 3>, min_version=2)¶
-
bz
= OpType(value='bz', mode=<Mode.Application|Signature: 3>, min_version=2)¶
-
bzero
= OpType(value='bzero', mode=<Mode.Application|Signature: 3>, min_version=4)¶
-
callsub
= OpType(value='callsub', mode=<Mode.Application|Signature: 3>, min_version=4)¶
-
concat
= OpType(value='concat', mode=<Mode.Application|Signature: 3>, min_version=2)¶
-
cover
= OpType(value='cover', mode=<Mode.Application|Signature: 3>, min_version=5)¶
-
dig
= OpType(value='dig', mode=<Mode.Application|Signature: 3>, min_version=3)¶
-
div
= OpType(value='/', mode=<Mode.Application|Signature: 3>, min_version=2)¶
-
divmodw
= OpType(value='divmodw', mode=<Mode.Application|Signature: 3>, min_version=4)¶
-
divw
= OpType(value='divw', mode=<Mode.Application|Signature: 3>, min_version=6)¶
-
dup
= OpType(value='dup', mode=<Mode.Application|Signature: 3>, min_version=2)¶
-
dup2
= OpType(value='dup2', mode=<Mode.Application|Signature: 3>, min_version=2)¶
-
ecdsa_pk_decompress
= OpType(value='ecdsa_pk_decompress', mode=<Mode.Application|Signature: 3>, min_version=5)¶
-
ecdsa_pk_recover
= OpType(value='ecdsa_pk_recover', mode=<Mode.Application|Signature: 3>, min_version=5)¶
-
ecdsa_verify
= OpType(value='ecdsa_verify', mode=<Mode.Application|Signature: 3>, min_version=5)¶
-
ed25519verify
= OpType(value='ed25519verify', mode=<Mode.Application|Signature: 3>, min_version=2)¶
-
eq
= OpType(value='==', mode=<Mode.Application|Signature: 3>, min_version=2)¶
-
err
= OpType(value='err', mode=<Mode.Application|Signature: 3>, min_version=2)¶
-
exp
= OpType(value='exp', mode=<Mode.Application|Signature: 3>, min_version=4)¶
-
expw
= OpType(value='expw', mode=<Mode.Application|Signature: 3>, min_version=4)¶
-
extract
= OpType(value='extract', mode=<Mode.Application|Signature: 3>, min_version=5)¶
-
extract3
= OpType(value='extract3', mode=<Mode.Application|Signature: 3>, min_version=5)¶
-
extract_uint16
= OpType(value='extract_uint16', mode=<Mode.Application|Signature: 3>, min_version=5)¶
-
extract_uint32
= OpType(value='extract_uint32', mode=<Mode.Application|Signature: 3>, min_version=5)¶
-
extract_uint64
= OpType(value='extract_uint64', mode=<Mode.Application|Signature: 3>, min_version=5)¶
-
gaid
= OpType(value='gaid', mode=<Mode.Application: 2>, min_version=4)¶
-
gaids
= OpType(value='gaids', mode=<Mode.Application: 2>, min_version=4)¶
-
ge
= OpType(value='>=', mode=<Mode.Application|Signature: 3>, min_version=2)¶
-
getbit
= OpType(value='getbit', mode=<Mode.Application|Signature: 3>, min_version=3)¶
-
getbyte
= OpType(value='getbyte', mode=<Mode.Application|Signature: 3>, min_version=3)¶
-
gitxn
= OpType(value='gitxn', mode=<Mode.Application: 2>, min_version=6)¶
-
gitxna
= OpType(value='gitxna', mode=<Mode.Application: 2>, min_version=6)¶
-
gitxnas
= OpType(value='gitxnas', mode=<Mode.Application: 2>, min_version=6)¶
-
gload
= OpType(value='gload', mode=<Mode.Application: 2>, min_version=4)¶
-
gloads
= OpType(value='gloads', mode=<Mode.Application: 2>, min_version=4)¶
-
gloadss
= OpType(value='gloadss', mode=<Mode.Application: 2>, min_version=6)¶
-
global_
= OpType(value='global', mode=<Mode.Application|Signature: 3>, min_version=2)¶
-
gt
= OpType(value='>', mode=<Mode.Application|Signature: 3>, min_version=2)¶
-
gtxn
= OpType(value='gtxn', mode=<Mode.Application|Signature: 3>, min_version=2)¶
-
gtxna
= OpType(value='gtxna', mode=<Mode.Application|Signature: 3>, min_version=2)¶
-
gtxnas
= OpType(value='gtxnas', mode=<Mode.Application|Signature: 3>, min_version=5)¶
-
gtxns
= OpType(value='gtxns', mode=<Mode.Application|Signature: 3>, min_version=3)¶
-
gtxnsa
= OpType(value='gtxnsa', mode=<Mode.Application|Signature: 3>, min_version=3)¶
-
gtxnsas
= OpType(value='gtxnsas', mode=<Mode.Application|Signature: 3>, min_version=5)¶
-
int
= OpType(value='int', mode=<Mode.Application|Signature: 3>, min_version=2)¶
-
intc
= OpType(value='intc', mode=<Mode.Application|Signature: 3>, min_version=2)¶
-
intc_0
= OpType(value='intc_0', mode=<Mode.Application|Signature: 3>, min_version=2)¶
-
intc_1
= OpType(value='intc_1', mode=<Mode.Application|Signature: 3>, min_version=2)¶
-
intc_2
= OpType(value='intc_2', mode=<Mode.Application|Signature: 3>, min_version=2)¶
-
intc_3
= OpType(value='intc_3', mode=<Mode.Application|Signature: 3>, min_version=2)¶
-
intcblock
= OpType(value='intcblock', mode=<Mode.Application|Signature: 3>, min_version=2)¶
-
itob
= OpType(value='itob', mode=<Mode.Application|Signature: 3>, min_version=2)¶
-
itxn
= OpType(value='itxn', mode=<Mode.Application: 2>, min_version=5)¶
-
itxn_begin
= OpType(value='itxn_begin', mode=<Mode.Application: 2>, min_version=5)¶
-
itxn_field
= OpType(value='itxn_field', mode=<Mode.Application: 2>, min_version=5)¶
-
itxn_next
= OpType(value='itxn_next', mode=<Mode.Application: 2>, min_version=6)¶
-
itxn_submit
= OpType(value='itxn_submit', mode=<Mode.Application: 2>, min_version=5)¶
-
itxna
= OpType(value='itxna', mode=<Mode.Application: 2>, min_version=5)¶
-
itxnas
= OpType(value='itxnas', mode=<Mode.Application: 2>, min_version=6)¶
-
keccak256
= OpType(value='keccak256', mode=<Mode.Application|Signature: 3>, min_version=2)¶
-
le
= OpType(value='<=', mode=<Mode.Application|Signature: 3>, min_version=2)¶
-
len
= OpType(value='len', mode=<Mode.Application|Signature: 3>, min_version=2)¶
-
load
= OpType(value='load', mode=<Mode.Application|Signature: 3>, min_version=2)¶
-
loads
= OpType(value='loads', mode=<Mode.Application|Signature: 3>, min_version=5)¶
-
log
= OpType(value='log', mode=<Mode.Application: 2>, min_version=5)¶
-
logic_and
= OpType(value='&&', mode=<Mode.Application|Signature: 3>, min_version=2)¶
-
logic_not
= OpType(value='!', mode=<Mode.Application|Signature: 3>, min_version=2)¶
-
logic_or
= OpType(value='||', mode=<Mode.Application|Signature: 3>, min_version=2)¶
-
lt
= OpType(value='<', mode=<Mode.Application|Signature: 3>, min_version=2)¶
-
method_signature
= OpType(value='method', mode=<Mode.Application|Signature: 3>, min_version=2)¶
-
min_balance
= OpType(value='min_balance', mode=<Mode.Application: 2>, min_version=3)¶
-
min_version
¶ Get the minimum version where this op is available.
-
minus
= OpType(value='-', mode=<Mode.Application|Signature: 3>, min_version=2)¶
-
mod
= OpType(value='%', mode=<Mode.Application|Signature: 3>, min_version=2)¶
-
mode
¶ Get the modes where this op is available.
-
mul
= OpType(value='*', mode=<Mode.Application|Signature: 3>, min_version=2)¶
-
mulw
= OpType(value='mulw', mode=<Mode.Application|Signature: 3>, min_version=2)¶
-
neq
= OpType(value='!=', mode=<Mode.Application|Signature: 3>, min_version=2)¶
-
pop
= OpType(value='pop', mode=<Mode.Application|Signature: 3>, min_version=2)¶
-
pushbytes
= OpType(value='pushbytes', mode=<Mode.Application|Signature: 3>, min_version=3)¶
-
pushint
= OpType(value='pushint', mode=<Mode.Application|Signature: 3>, min_version=3)¶
-
retsub
= OpType(value='retsub', mode=<Mode.Application|Signature: 3>, min_version=4)¶
-
return_
= OpType(value='return', mode=<Mode.Application|Signature: 3>, min_version=2)¶
-
select
= OpType(value='select', mode=<Mode.Application|Signature: 3>, min_version=3)¶
-
setbit
= OpType(value='setbit', mode=<Mode.Application|Signature: 3>, min_version=3)¶
-
setbyte
= OpType(value='setbyte', mode=<Mode.Application|Signature: 3>, min_version=3)¶
-
sha256
= OpType(value='sha256', mode=<Mode.Application|Signature: 3>, min_version=2)¶
-
sha512_256
= OpType(value='sha512_256', mode=<Mode.Application|Signature: 3>, min_version=2)¶
-
shl
= OpType(value='shl', mode=<Mode.Application|Signature: 3>, min_version=4)¶
-
shr
= OpType(value='shr', mode=<Mode.Application|Signature: 3>, min_version=4)¶
-
sqrt
= OpType(value='sqrt', mode=<Mode.Application|Signature: 3>, min_version=4)¶
-
store
= OpType(value='store', mode=<Mode.Application|Signature: 3>, min_version=2)¶
-
stores
= OpType(value='stores', mode=<Mode.Application|Signature: 3>, min_version=5)¶
-
substring
= OpType(value='substring', mode=<Mode.Application|Signature: 3>, min_version=2)¶
-
substring3
= OpType(value='substring3', mode=<Mode.Application|Signature: 3>, min_version=2)¶
-
swap
= OpType(value='swap', mode=<Mode.Application|Signature: 3>, min_version=3)¶
-
txn
= OpType(value='txn', mode=<Mode.Application|Signature: 3>, min_version=2)¶
-
txna
= OpType(value='txna', mode=<Mode.Application|Signature: 3>, min_version=2)¶
-
txnas
= OpType(value='txnas', mode=<Mode.Application|Signature: 3>, min_version=5)¶
-
uncover
= OpType(value='uncover', mode=<Mode.Application|Signature: 3>, min_version=5)¶
-
-
class
pyteal.
TealComponent
(expr: Optional[Expr])¶ Bases:
abc.ABC
-
class
Context
¶ Bases:
object
-
class
EqualityContext
¶ Bases:
contextlib.AbstractContextManager
-
checkExpr
= True¶
-
classmethod
ignoreExprEquality
()¶
-
class
-
assemble
() → str¶
-
assignSlot
(slot: ScratchSlot, location: int) → None¶
-
getSlots
() → List[ScratchSlot]¶
-
getSubroutines
() → List[SubroutineDefinition]¶
-
resolveSubroutine
(subroutine: SubroutineDefinition, label: str) → None¶
-
class
-
class
pyteal.
TealOp
(expr: Optional[Expr], op: pyteal.Op, *args)¶ Bases:
pyteal.TealComponent
-
assemble
() → str¶
-
assignSlot
(slot: ScratchSlot, location: int) → None¶
-
getOp
() → pyteal.Op¶
-
getSlots
() → List[ScratchSlot]¶
-
getSubroutines
() → List[SubroutineDefinition]¶
-
resolveSubroutine
(subroutine: SubroutineDefinition, label: str) → None¶
-
-
class
pyteal.
TealLabel
(expr: Optional[Expr], label: pyteal.ir.labelref.LabelReference, comment: str = None)¶ Bases:
pyteal.TealComponent
-
assemble
() → str¶
-
getLabelRef
() → pyteal.ir.labelref.LabelReference¶
-
-
class
pyteal.
TealBlock
(ops: List[pyteal.TealOp])¶ Bases:
abc.ABC
Represents a basic block of TealComponents in a graph.
-
classmethod
FromOp
(options: CompileOptions, op: pyteal.TealOp, *args) → Tuple[TealBlock, TealSimpleBlock]¶ Create a path of blocks from a TealOp and its arguments.
Returns: The starting and ending block of the path that encodes the given TealOp and arguments.
-
classmethod
Iterate
(start: pyteal.TealBlock) → Iterator[pyteal.TealBlock]¶ Perform a depth-first search of the graph of blocks starting with start.
-
classmethod
NormalizeBlocks
(start: pyteal.TealBlock) → pyteal.TealBlock¶ Minimize the number of blocks in the graph of blocks starting with start by combining sequential blocks. This operation does not alter the operations of the graph or the functionality of its underlying program, however it does mutate the input graph.
Returns: The new starting point of the altered graph. May be the same or differant than start.
-
addIncoming
(parent: Optional[pyteal.TealBlock] = None, visited: List[TealBlock] = None) → None¶ Calculate the parent blocks for this block and its children.
Parameters: - parent (optional) – The parent block to this one, if it has one. Defaults to None.
- visited (optional) – Used internally to remember blocks that have been visited. Set to None.
-
getOutgoing
() → List[pyteal.TealBlock]¶ Get this block’s children blocks, if any.
-
isTerminal
() → bool¶ Check if this block ends the program.
-
replaceOutgoing
(oldBlock: pyteal.TealBlock, newBlock: pyteal.TealBlock) → None¶ Replace one of this block’s child blocks.
-
validateSlots
(slotsInUse: Set[ScratchSlot] = None, visited: Set[Tuple[int, ...]] = None) → List[pyteal.TealCompileError]¶
-
validateTree
(parent: Optional[pyteal.TealBlock] = None, visited: List[TealBlock] = None) → None¶ Check that this block and its children have valid parent pointers.
Parameters: - parent (optional) – The parent block to this one, if it has one. Defaults to None.
- visited (optional) – Used internally to remember blocks that have been visited. Set to None.
-
classmethod
-
class
pyteal.
TealSimpleBlock
(ops: List[pyteal.TealOp])¶ Bases:
pyteal.TealBlock
Represents a basic block of TealComponents in a graph that does not contain a branch condition.
-
getOutgoing
() → List[pyteal.TealBlock]¶ Get this block’s children blocks, if any.
-
replaceOutgoing
(oldBlock: pyteal.TealBlock, newBlock: pyteal.TealBlock) → None¶ Replace one of this block’s child blocks.
-
setNextBlock
(block: pyteal.TealBlock) → None¶ Set the block that follows this one.
-
-
class
pyteal.
TealConditionalBlock
(ops: List[pyteal.TealOp])¶ Bases:
pyteal.TealBlock
Represents a basic block of TealComponents in a graph ending with a branch condition.
-
getOutgoing
() → List[pyteal.TealBlock]¶ Get this block’s children blocks, if any.
-
replaceOutgoing
(oldBlock: pyteal.TealBlock, newBlock: pyteal.TealBlock) → None¶ Replace one of this block’s child blocks.
-
setFalseBlock
(block: pyteal.TealBlock) → None¶ Set the block that this one should branch to if its condition is false.
-
setTrueBlock
(block: pyteal.TealBlock) → None¶ Set the block that this one should branch to if its condition is true.
-
-
class
pyteal.
LabelReference
(label: str)¶ Bases:
object
-
addPrefix
(prefix: str) → None¶
-
getLabel
() → str¶
-
-
class
pyteal.
CompileOptions
(*, mode: pyteal.Mode = <Mode.Signature: 1>, version: int = 2)¶ Bases:
object
-
addLoopBreakBlock
(block: pyteal.TealSimpleBlock) → None¶
-
addLoopContinueBlock
(block: pyteal.TealSimpleBlock) → None¶
-
enterLoop
() → None¶
-
exitLoop
() → Tuple[List[pyteal.TealSimpleBlock], List[pyteal.TealSimpleBlock]]¶
-
isInLoop
() → bool¶
-
setSubroutine
(subroutine: Optional[pyteal.SubroutineDefinition]) → None¶
-
-
pyteal.
compileTeal
(ast: pyteal.Expr, mode: pyteal.Mode, *, version: int = 2, assembleConstants: bool = False) → str¶ Compile a PyTeal expression into TEAL assembly.
Parameters: - ast – The PyTeal expression to assemble.
- mode – The mode of the program to assemble. Must be Signature or Application.
- version (optional) – The TEAL version used to assemble the program. This will determine which expressions and fields are able to be used in the program and how expressions compile to TEAL opcodes. Defaults to 2 if not included.
- assembleConstants (optional) – When true, the compiler will produce a program with fully assembled constants, rather than using the pseudo-ops int, byte, and addr. These constants will be assembled in the most space-efficient way, so enabling this may reduce the compiled program’s size. Enabling this option requires a minimum TEAL version of 3. Defaults to false.
Returns: A TEAL assembly program compiled from the input expression.
Raises: TealInputError
– if an operation in ast is not supported by the supplied mode and version.TealInternalError
– if an internal error is encounter during compilation.
-
class
pyteal.
TealType
¶ Bases:
enum.Enum
Teal type enum.
-
anytype
= 2¶
-
bytes
= 1¶
-
none
= 3¶
-
uint64
= 0¶
-
-
exception
pyteal.
TealInternalError
(message: str)¶ Bases:
Exception
-
exception
pyteal.
TealTypeError
(actual, expected)¶ Bases:
Exception
-
exception
pyteal.
TealInputError
(msg: str)¶ Bases:
Exception
-
exception
pyteal.
TealCompileError
(msg: str, sourceExpr: Optional[Expr])¶ Bases:
Exception