algopy
Package Contents
Section titled “Package Contents”Classes
Section titled “Classes”ARC4Contract | A contract that conforms to the ARC-4 ABI specification, functions decorated with@abimethod or @baremethod will form the public interface of the contract |
|---|---|
Account | An Account on the Algorand network. |
Application | An Application on the Algorand network. |
Array | A dynamically sized Array of the specified type |
Asset | An Asset on the Algorand network. |
BigUInt | A variable length (max 512-bit) unsigned integer |
Box | Box abstracts the reading and writing of a single value to a single box. The box size will be reconfigured dynamically to fit the size of the value being assigned to it. |
BoxMap | BoxMap abstracts the reading and writing of a set of boxes using a common key and content type. Each composite key (prefix + key) still needs to be made available to the application via the boxes property of the Transaction. |
BoxRef | BoxRef abstracts the reading and writing of boxes containing raw binary data. The size is configured manually, and can be set to values larger than what the AVM can handle in a single value. |
Bytes | A byte sequence, with a maximum length of 4096 bytes, one of the primary data types on the AVM |
BytesBacked | Represents a type that is a single bytes value |
CompiledContract | Provides compiled programs and state allocation values for a Contract. Create by calling compile_contract. |
CompiledLogicSig | Provides account for a Logic Signature. Create by calling compile_logicsig. |
Contract | Base class for an Algorand Smart Contract |
FixedArray | A fixed length Array of the specified type and length |
Global | Get Global values Native TEAL op: global |
GlobalState | Global state associated with the application, the key will be the name of the member, this is assigned to |
ImmutableArray | An immutable array that supports fixed and dynamically sized immutable elements. Modifications are done by returning a new copy of the array with the modifications applied. |
ImmutableFixedArray | An immutable fixed length Array of the specified type and length |
LocalState | Local state associated with the application and an account |
LogicSig | A logic signature |
OnCompleteAction | On Completion actions available in an application call transaction |
OpUpFeeSource | Defines the source of fees for the OpUp utility. |
ReferenceArray | A mutable array that supports fixed sized immutable elements. All references to this array will see any updates made to it. |
StateTotals | Options class to manually define the total amount of global and local state contract will use, used by Contract.__init_subclass__. |
String | A UTF-8 encoded string. |
Struct | Base class for Struct types |
TransactionType | The different transaction types available in a transaction |
Txn | Get values for the current executing transaction Native TEAL ops: txn, txnas |
UInt64 | A 64-bit unsigned integer, one of the primary data types on the AVM |
uenumerate | Yields pairs containing a count (from zero) and a value yielded by the iterable argument. |
urange | Produces a sequence of UInt64 from start (inclusive) to stop (exclusive) by step. |
Functions
Section titled “Functions”compile_contract | Returns the compiled data for the specified contract |
|---|---|
compile_logicsig | Returns the Account for the specified logic signature |
ensure_budget | Ensure the available op code budget is greater than or equal to required_budget |
log | Concatenates and logs supplied args as a single bytes value. |
logicsig | Decorator to indicate a function is a logic signature |
size_of | Returns the number of bytes required to store the provided type object or the type of provided expression |
subroutine | Decorator to indicate functions or methods that can be called by a Smart Contract |
zero_bytes | Initializes a new value of the specified type, based on it’s zero bytes representation. |
TemplateVar | Template variables can be used to represent a placeholder for a deploy-time provided value. |
|---|
class algopy.ARC4Contract
Section titled “class algopy.ARC4Contract”A contract that conforms to the ARC-4 ABI specification, functions decorated with
@abimethod or @baremethod will form the public interface of the contract
The approval_program will be implemented by the compiler, and route application args according to the ARC-4 ABI specification
The clear_state_program will by default return True, but can be overridden
classmethod __initsubclass_
Section titled “classmethod __initsubclass_”*classmethod __initsubclass_(*, name: str = …, scratch_slots: algopy.urange | tuple[int | algopy.urange, …] | list[int | algopy.urange] = …, state_totals: algopy.StateTotals = …, avm_version: int = …)*
When declaring a Contract subclass, options and configuration are passed in the base class list:
class MyContract(algopy.Contract, name="CustomName"): ...-
Parameters:
-
name –
Will affect the output TEAL file name if there are multiple non-abstract contracts in the same file.
If the contract is a subclass of algopy.ARC4Contract,
namewill also be used as the contract name in the ARC-32 application.json, instead of the class name. -
scratch_slots –
Allows you to mark a slot ID or range of slot IDs as “off limits” to Puya. These slot ID(s) will never be written to or otherwise manipulating by the compiler itself. This is particularly useful in combination with
algopy.op.gload_bytes/algopy.op.gload_uint64which lets a contract in a group transaction read from the scratch slots of another contract that occurs earlier in the transaction group.In the case of inheritance, scratch slots reserved become cumulative. It is not an error to have overlapping ranges or values either, so if a base class contract reserves slots 0-5 inclusive and the derived contract reserves 5-10 inclusive, then within the derived contract all slots 0-10 will be marked as reserved.
-
state_totals –
Allows defining what values should be used for global and local uint and bytes storage values when creating a contract. Used when outputting ARC-32 application.json schemas.
If let unspecified, the totals will be determined by the compiler based on state variables assigned to
self.This setting is not inherited, and only applies to the exact
Contractit is specified on. If a base class does specify this setting, and a derived class does not, a warning will be emitted for the derived class. To resolve this warning,state_totalsmust be specified. Note that it is valid to not provide any arguments to theStateTotalsconstructor, like sostate_totals=StateTotals(), in which case all values will be automatically calculated. -
avm_version – Determines which AVM version to use, this affects what operations are supported. Defaults to value provided supplied on command line (which defaults to current mainnet version)
-
approval_program
Section titled “approval_program”approval_program() → bool
Represents the program called for all transactions
where OnCompletion != ClearState
clear_state_program
Section titled “clear_state_program”clear_state_program() → algopy.UInt64 | bool
Represents the program called when OnCompletion == ClearState
class algopy.Account
Section titled “class algopy.Account”*class algopy.Account(value: str | algopy.Bytes = …, /)*
An Account on the Algorand network.
Note: must be an available resource to access properties other than bytes
Initialization
Section titled “Initialization”If value is a string, it should be a 58 character base32 string,
ie a base32 string-encoded 32 bytes public key + 4 bytes checksum.
If value is a Bytes, it’s length checked to be 32 bytes - to avoid this
check, use Address.from_bytes(...) instead.
Defaults to the zero-address.
__bool__
Section titled “__bool__”__bool__() → bool
Returns True if not equal to the zero-address
__eq__
Section titled “__eq__”__eq__(other: algopy.Account | str) → bool
Account equality is determined by the address of another Account or str
__ne__
Section titled “__ne__”__ne__(other: algopy.Account | str) → bool
Account equality is determined by the address of another Account or str
property auth_address *: [algopy.Account]
Section titled “property auth_address *: [algopy.Account]”property auth_address : algopy.Account
Address the account is rekeyed to
Account must be an available resource
property balance *: [algopy.UInt64]
Section titled “property balance *: [algopy.UInt64]”property balance : algopy.UInt64
Account balance in microalgos
Account must be an available resource
property bytes *: [algopy.Bytes]
Section titled “property bytes *: [algopy.Bytes]”property bytes : algopy.Bytes
Get the underlying Bytes
classmethod from_bytes
Section titled “classmethod from_bytes”*classmethod from_bytes(value: algopy.Bytes | bytes, /) → Self*
Construct an instance from the underlying bytes (no validation)
is_opted_in
Section titled “is_opted_in”is_opted_in(asset_or_app: algopy.Asset | algopy.Application, /) → bool
Returns true if this account is opted in to the specified Asset or Application.
Account and Asset/Application must be an available resource
property min_balance *: [algopy.UInt64]
Section titled “property min_balance *: [algopy.UInt64]”property min_balance : algopy.UInt64
Minimum required balance for account, in microalgos
Account must be an available resource
property total_apps_created *: [algopy.UInt64]
Section titled “property total_apps_created *: [algopy.UInt64]”property total_apps_created : algopy.UInt64
The number of existing apps created by this account.
Account must be an available resource
property total_apps_opted_in *: [algopy.UInt64]
Section titled “property total_apps_opted_in *: [algopy.UInt64]”property total_apps_opted_in : algopy.UInt64
The number of apps this account is opted into.
Account must be an available resource
property total_assets *: [algopy.UInt64]
Section titled “property total_assets *: [algopy.UInt64]”property total_assets : algopy.UInt64
The numbers of ASAs held by this account (including ASAs this account created).
Account must be an available resource
property total_assets_created *: [algopy.UInt64]
Section titled “property total_assets_created *: [algopy.UInt64]”property total_assets_created : algopy.UInt64
The number of existing ASAs created by this account.
Account must be an available resource
property total_box_bytes *: [algopy.UInt64]
Section titled “property total_box_bytes *: [algopy.UInt64]”property total_box_bytes : algopy.UInt64
The total number of bytes used by this account’s app’s box keys and values.
Account must be an available resource
property total_boxes *: [algopy.UInt64]
Section titled “property total_boxes *: [algopy.UInt64]”property total_boxes : algopy.UInt64
The number of existing boxes created by this account’s app.
Account must be an available resource
property total_extra_app_pages *: [algopy.UInt64]
Section titled “property total_extra_app_pages *: [algopy.UInt64]”property total_extra_app_pages : algopy.UInt64
The number of extra app code pages used by this account.
Account must be an available resource
property total_num_byte_slice *: [algopy.UInt64]
Section titled “property total_num_byte_slice *: [algopy.UInt64]”property total_num_byte_slice : algopy.UInt64
The total number of byte array values allocated by this account in Global and Local States.
Account must be an available resource
property total_num_uint *: [algopy.UInt64]
Section titled “property total_num_uint *: [algopy.UInt64]”property total_num_uint : algopy.UInt64
The total number of uint64 values allocated by this account in Global and Local States.
Account must be an available resource
validate
Section titled “validate”validate() → None
Performs validation to ensure the value is well-formed, errors if it is not
class algopy.Application
Section titled “class algopy.Application”*class algopy.Application(application_id: algopy.UInt64 | int = 0, /)*
An Application on the Algorand network.
Initialization
Section titled “Initialization”Initialized with the id of an application. Defaults to zero (an invalid ID).
__bool__
Section titled “__bool__”__bool__() → bool
Returns True if application_id is not 0
__eq__
Section titled “__eq__”__eq__(other: algopy.Application) → bool
Application equality is determined by the equality of an Application’s id
__ne__
Section titled “__ne__”__ne__(other: algopy.Application) → bool
Application equality is determined by the equality of an Application’s id
property address *: [algopy.Account]
Section titled “property address *: [algopy.Account]”property address : algopy.Account
Address for which this application has authority
Application must be an available resource
property approval_program *: [algopy.Bytes]
Section titled “property approval_program *: [algopy.Bytes]”property approval_program : algopy.Bytes
Bytecode of Approval Program
Application must be an available resource
property clear_state_program *: [algopy.Bytes]
Section titled “property clear_state_program *: [algopy.Bytes]”property clear_state_program : algopy.Bytes
Bytecode of Clear State Program
Application must be an available resource
property creator *: [algopy.Account]
Section titled “property creator *: [algopy.Account]”property creator : algopy.Account
Creator address
Application must be an available resource
property extra_program_pages *: [algopy.UInt64]
Section titled “property extra_program_pages *: [algopy.UInt64]”property extra_program_pages : algopy.UInt64
Number of Extra Program Pages of code space
Application must be an available resource
property global_num_bytes *: [algopy.UInt64]
Section titled “property global_num_bytes *: [algopy.UInt64]”property global_num_bytes : algopy.UInt64
Number of byte array values allowed in Global State
Application must be an available resource
property global_num_uint *: [algopy.UInt64]
Section titled “property global_num_uint *: [algopy.UInt64]”property global_num_uint : algopy.UInt64
Number of uint64 values allowed in Global State
Application must be an available resource
property id *: [algopy.UInt64]
Section titled “property id *: [algopy.UInt64]”property id : algopy.UInt64
Returns the id of the application
property local_num_bytes *: [algopy.UInt64]
Section titled “property local_num_bytes *: [algopy.UInt64]”property local_num_bytes : algopy.UInt64
Number of byte array values allowed in Local State
Application must be an available resource
property local_num_uint *: [algopy.UInt64]
Section titled “property local_num_uint *: [algopy.UInt64]”property local_num_uint : algopy.UInt64
Number of uint64 values allowed in Local State
Application must be an available resource
property version *: [algopy.UInt64]
Section titled “property version *: [algopy.UInt64]”property version : algopy.UInt64
Version of the app, incremented each time the approval or clear program changes
Application must be an available resource
class algopy.Array
Section titled “class algopy.Array”A dynamically sized Array of the specified type
__add__
Section titled “__add__”___add__(other: collections.abc.Iterable[algopy._TArrayItem]) → algopy.Array[algopy.TArrayItem]
Concat two arrays together, returning a new array
__bool__
Section titled “__bool__”__bool__() → bool
Returns True if not an empty array
__getitem__
Section titled “__getitem__”__getitem__(index: algopy.UInt64 | int) → algopy._TArrayItem
Gets the item of the array at provided index
__reversed__
Section titled “__reversed__”___reversed__() → Iterator[algopy.TArrayItem]
Returns an iterator for the items in the array, in reverse order
__setitem__
Section titled “__setitem__”__setitem__(index: algopy.UInt64 | int, value: algopy._TArrayItem) → algopy._TArrayItem
Sets the item of the array at specified index to provided value
append
Section titled “append”append(item: algopy._TArrayItem, /) → None
Append an item to this array
copy() → Self
Create a copy of this array
extend
Section titled “extend”_extend(other: collections.abc.Iterable[algopy.TArrayItem], /) → None
Extend this array with the contents of another array
freeze
Section titled “freeze”_freeze() → algopy.ImmutableArray[algopy.TArrayItem]
Returns an immutable copy of this array
property length *: [algopy.UInt64]
Section titled “property length *: [algopy.UInt64]”property length : algopy.UInt64
Returns the current length of the array
pop() → algopy._TArrayItem
Remove and return the last item of this array
validate
Section titled “validate”validate() → None
Performs validation to ensure the value is well-formed, errors if it is not
class algopy.Asset
Section titled “class algopy.Asset”*class algopy.Asset(asset_id: algopy.UInt64 | int = 0, /)*
An Asset on the Algorand network.
Initialization
Section titled “Initialization”Initialized with the id of an asset. Defaults to zero (an invalid ID).
__bool__
Section titled “__bool__”__bool__() → bool
Returns True if asset_id is not 0
__eq__
Section titled “__eq__”__eq__(other: algopy.Asset) → bool
Asset equality is determined by the equality of an Asset’s id
__ne__
Section titled “__ne__”__ne__(other: algopy.Asset) → bool
Asset equality is determined by the equality of an Asset’s id
balance
Section titled “balance”balance(account: algopy.Account, /) → algopy.UInt64
Amount of the asset unit held by this account. Fails if the account has not opted in to the asset.
Asset and supplied Account must be an available resource
property clawback *: [algopy.Account]
Section titled “property clawback *: [algopy.Account]”property clawback : algopy.Account
Clawback address
Asset must be an available resource
property creator *: [algopy.Account]
Section titled “property creator *: [algopy.Account]”property creator : algopy.Account
Creator address
Asset must be an available resource
property decimals *: [algopy.UInt64]
Section titled “property decimals *: [algopy.UInt64]”property decimals : algopy.UInt64
See AssetParams.Decimals
Asset must be an available resource
property default_frozen *: [bool]
Section titled “property default_frozen *: [bool]”property default_frozen : bool
Frozen by default or not
Asset must be an available resource
property freeze *: [algopy.Account]
Section titled “property freeze *: [algopy.Account]”property freeze : algopy.Account
Freeze address
Asset must be an available resource
frozen
Section titled “frozen”frozen(account: algopy.Account, /) → bool
Is the asset frozen or not. Fails if the account has not opted in to the asset.
Asset and supplied Account must be an available resource
property id *: [algopy.UInt64]
Section titled “property id *: [algopy.UInt64]”property id : algopy.UInt64
Returns the id of the Asset
property manager *: [algopy.Account]
Section titled “property manager *: [algopy.Account]”property manager : algopy.Account
Manager address
Asset must be an available resource
property metadata_hash *: [algopy.Bytes]
Section titled “property metadata_hash *: [algopy.Bytes]”property metadata_hash : algopy.Bytes
Arbitrary commitment
Asset must be an available resource
property name *: [algopy.Bytes]
Section titled “property name *: [algopy.Bytes]”property name : algopy.Bytes
Asset name
Asset must be an available resource
property reserve *: [algopy.Account]
Section titled “property reserve *: [algopy.Account]”property reserve : algopy.Account
Reserve address
Asset must be an available resource
property total *: [algopy.UInt64]
Section titled “property total *: [algopy.UInt64]”property total : algopy.UInt64
Total number of units of this asset
Asset must be an available resource
property unit_name *: [algopy.Bytes]
Section titled “property unit_name *: [algopy.Bytes]”property unit_name : algopy.Bytes
Asset unit name
Asset must be an available resource
property url *: [algopy.Bytes]
Section titled “property url *: [algopy.Bytes]”property url : algopy.Bytes
URL with additional info about the asset
Asset must be an available resource
class algopy.BigUInt
Section titled “class algopy.BigUInt”*class algopy.BigUInt(value: algopy.UInt64 | int = 0, /)*
A variable length (max 512-bit) unsigned integer
Initialization
Section titled “Initialization”A BigUInt can be initialized with a UInt64, a Python int literal, or an int variable declared at the module level
__add__
Section titled “__add__”__add__(other: algopy.BigUInt | algopy.UInt64 | int) → algopy.BigUInt
A BigUInt can be added with another BigUInt, UInt64 or int e.g. BigUInt(4) + 2.
__and__
Section titled “__and__”__and__(other: algopy.BigUInt | algopy.UInt64 | int) → algopy.BigUInt
A BigUInt can bitwise and with another BigUInt, UInt64 or int e.g. BigUInt(4) & 2
__bool__
Section titled “__bool__”__bool__() → bool
A BigUInt will evaluate to False if zero, and True otherwise
__eq__
Section titled “__eq__”__eq__(other: algopy.BigUInt | algopy.UInt64 | int) → bool
A BigUInt can use the == operator with another BigUInt, UInt64 or int
__floordiv__
Section titled “__floordiv__”__floordiv__(other: algopy.BigUInt | algopy.UInt64 | int) → algopy.BigUInt
A BigUInt can be floor divided with another BigUInt, UInt64 or int e.g. BigUInt(4) // 2.
This will error on divide by zero
__ge__
Section titled “__ge__”__ge__(other: algopy.BigUInt | algopy.UInt64 | int) → bool
A BigUInt can use the >= operator with another BigUInt, UInt64 or int
__gt__
Section titled “__gt__”__gt__(other: algopy.BigUInt | algopy.UInt64 | int) → bool
A BigUInt can use the > operator with another BigUInt, UInt64 or int
__iadd__
Section titled “__iadd__”__iadd__(other: algopy.BigUInt | algopy.UInt64 | int) → algopy.BigUInt
A BigUInt can be incremented with another BigUInt, UInt64 or int e.g. a += BigUInt(2).
__iand__
Section titled “__iand__”__iand__(other: algopy.BigUInt | algopy.UInt64 | int) → algopy.BigUInt
A BigUInt can bitwise and with another BigUInt, UInt64 or int e.g. a &= BigUInt(2)
__ifloordiv__
Section titled “__ifloordiv__”__ifloordiv__(other: algopy.BigUInt | algopy.UInt64 | int) → algopy.BigUInt
A BigUInt can be floor divided with another BigUInt, UInt64 or int e.g. a //= BigUInt(2).
This will error on divide by zero
__imod__
Section titled “__imod__”__imod__(other: algopy.BigUInt | algopy.UInt64 | int) → algopy.BigUInt
A BigUInt can be modded with another BigUInt, UInt64 or int e.g. a %= BigUInt(2).
This will error on mod by zero
__imul__
Section titled “__imul__”__imul__(other: algopy.BigUInt | algopy.UInt64 | int) → algopy.BigUInt
A BigUInt can be multiplied with another BigUInt, UInt64 or int e.g. a*= BigUInt(2).
__ior__
Section titled “__ior__”__ior__(other: algopy.BigUInt | algopy.UInt64 | int) → algopy.BigUInt
A BigUInt can bitwise or with another BigUInt, UInt64 or int e.g. a |= BigUInt(2)
__isub__
Section titled “__isub__”__isub__(other: algopy.BigUInt | algopy.UInt64 | int) → algopy.BigUInt
A BigUInt can be subtracted with another BigUInt, UInt64 or int e.g. a -= BigUInt(2).
This will error on underflow
__ixor__
Section titled “__ixor__”__ixor__(other: algopy.BigUInt | algopy.UInt64 | int) → algopy.BigUInt
A BigUInt can bitwise xor with another BigUInt, UInt64 or int e.g. a ^= BigUInt(2)
__le__
Section titled “__le__”__le__(other: algopy.BigUInt | algopy.UInt64 | int) → bool
A BigUInt can use the <= operator with another BigUInt, UInt64 or int
__lt__
Section titled “__lt__”__lt__(other: algopy.BigUInt | algopy.UInt64 | int) → bool
A BigUInt can use the < operator with another BigUInt, UInt64 or int
__mod__
Section titled “__mod__”__mod__(other: algopy.BigUInt | algopy.UInt64 | int) → algopy.BigUInt
A BigUInt can be modded with another BigUInt, UInt64 or int e.g. BigUInt(4) % 2.
This will error on mod by zero
__mul__
Section titled “__mul__”__mul__(other: algopy.BigUInt | algopy.UInt64 | int) → algopy.BigUInt
A BigUInt can be multiplied with another BigUInt, UInt64 or int e.g. 4 + BigUInt(2).
__ne__
Section titled “__ne__”__ne__(other: algopy.BigUInt | algopy.UInt64 | int) → bool
A BigUInt can use the != operator with another BigUInt, UInt64 or int
__or__
Section titled “__or__”__or__(other: algopy.BigUInt | algopy.UInt64 | int) → algopy.BigUInt
A BigUInt can bitwise or with another BigUInt, UInt64 or int e.g. BigUInt(4) | 2
__pos__
Section titled “__pos__”__pos__() → algopy.BigUInt
Supports unary + operator. Redundant given the type is unsigned
__radd__
Section titled “__radd__”__radd__(other: algopy.BigUInt | algopy.UInt64 | int) → algopy.BigUInt
A BigUInt can be added with another BigUInt, UInt64 or int e.g. 4 + BigUInt(2).
__rand__
Section titled “__rand__”__rand__(other: algopy.BigUInt | algopy.UInt64 | int) → algopy.BigUInt
A BigUInt can bitwise and with another BigUInt, UInt64 or int e.g. 4 & BigUInt(2)
__rfloordiv__
Section titled “__rfloordiv__”__rfloordiv__(other: algopy.BigUInt | algopy.UInt64 | int) → algopy.BigUInt
A BigUInt can be floor divided with another BigUInt, UInt64 or int e.g. 4 // BigUInt(2).
This will error on divide by zero
__rmod__
Section titled “__rmod__”__rmod__(other: algopy.BigUInt | algopy.UInt64 | int) → algopy.BigUInt
A BigUInt can be modded with another BigUInt, UInt64 or int e.g. 4 % BigUInt(2).
This will error on mod by zero
__rmul__
Section titled “__rmul__”__rmul__(other: algopy.BigUInt | algopy.UInt64 | int) → algopy.BigUInt
A BigUInt can be multiplied with another BigUInt, UInt64 or int e.g. BigUInt(4) + 2.
__ror__
Section titled “__ror__”__ror__(other: algopy.BigUInt | algopy.UInt64 | int) → algopy.BigUInt
A BigUInt can bitwise or with another BigUInt, UInt64 or int e.g. 4 | BigUInt(2)
__rsub__
Section titled “__rsub__”__rsub__(other: algopy.BigUInt | algopy.UInt64 | int) → algopy.BigUInt
A BigUInt can be subtracted with another BigUInt, UInt64 or int e.g. 4 - BigUInt(2).
This will error on underflow
__rxor__
Section titled “__rxor__”__rxor__(other: algopy.BigUInt | algopy.UInt64 | int) → algopy.BigUInt
A BigUInt can bitwise xor with another BigUInt, UInt64 or int e.g. 4 ^ BigUInt(2)
__sub__
Section titled “__sub__”__sub__(other: algopy.BigUInt | algopy.UInt64 | int) → algopy.BigUInt
A BigUInt can be subtracted with another BigUInt, UInt64 or int e.g. BigUInt(4) - 2.
This will error on underflow
__xor__
Section titled “__xor__”__xor__(other: algopy.BigUInt | algopy.UInt64 | int) → algopy.BigUInt
A BigUInt can bitwise xor with another BigUInt, UInt64 or int e.g. BigUInt(4) ^ 2
property bytes *: [algopy.Bytes]
Section titled “property bytes *: [algopy.Bytes]”property bytes : algopy.Bytes
Get the underlying Bytes
classmethod from_bytes
Section titled “classmethod from_bytes”*classmethod from_bytes(value: algopy.Bytes | bytes, /) → Self*
Construct an instance from the underlying bytes (no validation)
class algopy.Box
Section titled “class algopy.Box”*class algopy.Box(type_: type[algopy._TValue], /, *, key: bytes | str | algopy.Bytes | algopy.String = …)*
Box abstracts the reading and writing of a single value to a single box. The box size will be reconfigured dynamically to fit the size of the value being assigned to it.
Initialization
Section titled “Initialization”__bool__
Section titled “__bool__”__bool__() → bool
Returns True if the box exists, regardless of the truthiness of the contents of the box
create
Section titled “create”create(*, size: algopy.UInt64 | int = …) → bool
Creates the box with the specified size setting all bits to zero. If size is not specified and the type is a fixed size, then the storage size of the type will be used. Fails if the box already exists with a different size. Fails if the specified size is greater than the max box size (32,768) Fails if size is omitted and the type is not fixed size.
Returns True if the box was created, False if the box already existed
extract
Section titled “extract”extract(start_index: algopy.UInt64 | int, length: algopy.UInt64 | int) → algopy.Bytes
Extract a slice of bytes from the box.
Fails if the box does not exist, or if start_index + length > len(box)
- Parameters:
- start_index – The offset to start extracting bytes from
- length – The number of bytes to extract
get(*, default: algopy._TValue) → algopy._TValue
Retrieve the contents of the box, or return the default value if the box has not been created.
- Parameters: default – The default value to return if the box has not been created
property key *: [algopy.Bytes]
Section titled “property key *: [algopy.Bytes]”property key : algopy.Bytes
Provides access to the raw storage key
property length *: [algopy.UInt64]
Section titled “property length *: [algopy.UInt64]”property length : algopy.UInt64
Get the length of this Box. Fails if the box does not exist
maybe() → tuple[algopy._TValue, bool]
Retrieve the contents of the box if it exists, and return a boolean indicating if the box exists.
property ref *: [algopy.BoxRef]
Section titled “property ref *: [algopy.BoxRef]”property ref : algopy.BoxRef
Provides a BoxRef for this box
replace
Section titled “replace”replace(start_index: algopy.UInt64 | int, value: algopy.Bytes | bytes) → None
Write value to the box starting at start_index. Fails if the box does not exist,
or if start_index + len(value) > len(box)
- Parameters:
- start_index – The offset to start writing bytes from
- value – The bytes to be written
resize
Section titled “resize”resize(new_size: algopy.UInt64 | int) → None
Resizes the box the specified new_size. Truncating existing data if the new value is
shorter or padding with zero bytes if it is longer.
- Parameters: new_size – The new size of the box
splice
Section titled “splice”splice(start_index: algopy.UInt64 | int, length: algopy.UInt64 | int, value: algopy.Bytes | bytes) → None
set box to contain its previous bytes up to index start_index, followed by bytes,
followed by the original bytes of the box that began at index start_index + length
Important: This op does not resize the box If the new value is longer than the box size, it will be truncated. If the new value is shorter than the box size, it will be padded with zero bytes
- Parameters:
- start_index – The index to start inserting
value - length – The number of bytes after
start_indexto omit from the new value - value – The
valueto be inserted.
- start_index – The index to start inserting
property value : algopy._TValue
Section titled “property value : algopy._TValue”Retrieve the contents of the box. Fails if the box has not been created.
class algopy.BoxMap
Section titled “class algopy.BoxMap”*class algopy.BoxMap(key_type: type[algopy._TKey], value_type: type[algopy._TValue], /, *, key_prefix: bytes | str | algopy.Bytes | algopy.String = …)*
BoxMap abstracts the reading and writing of a set of boxes using a common key and content type.
Each composite key (prefix + key) still needs to be made available to the application via the
boxes property of the Transaction.
Initialization
Section titled “Initialization”Declare a box map.
- Parameters:
- key_type – The type of the keys
- value_type – The type of the values
- key_prefix – The value used as a prefix to key data, can be empty. When the BoxMap is being assigned to a member variable, this argument is optional and defaults to the member variable name, and if a custom value is supplied it must be static.
__contains__
Section titled “__contains__”__contains__(key: algopy._TKey) → bool
Returns True if a box with the specified key exists in the map, regardless of the truthiness of the contents of the box
__delitem__
Section titled “__delitem__”__delitem__(key: algopy._TKey) → None
Deletes a keyed box
__getitem__
Section titled “__getitem__”__getitem__(key: algopy._TKey) → algopy._TValue
Retrieve the contents of a keyed box. Fails if the box for the key has not been created.
__setitem__
Section titled “__setitem__”__setitem__(key: algopy._TKey, value: algopy._TValue) → None
Write value to a keyed box. Creates the box if it does not exist
_box(key: algopy._TKey) → algopy.Box[algopy.TValue]
Returns a Box holding the box value at key
get(key: algopy._TKey, *, default: algopy._TValue) → algopy._TValue
Retrieve the contents of a keyed box, or return the default value if the box has not been created.
- Parameters:
- key – The key of the box to get
- default – The default value to return if the box has not been created.
property key_prefix *: [algopy.Bytes]
Section titled “property key_prefix *: [algopy.Bytes]”property key_prefix : algopy.Bytes
Provides access to the raw storage key-prefix
length
Section titled “length”length(key: algopy._TKey) → algopy.UInt64
Get the length of an item in this BoxMap. Fails if the box does not exist
- Parameters: key – The key of the box to get
maybe(key: algopy._TKey) → tuple[algopy._TValue, bool]
Retrieve the contents of a keyed box if it exists, and return a boolean indicating if the box exists.
- Parameters: key – The key of the box to get
class algopy.BoxRef
Section titled “class algopy.BoxRef”*class algopy.BoxRef(/, *, key: bytes | str | algopy.Bytes | algopy.String = …)*
BoxRef abstracts the reading and writing of boxes containing raw binary data. The size is configured manually, and can be set to values larger than what the AVM can handle in a single value.
Initialization
Section titled “Initialization”__bool__
Section titled “__bool__”__bool__() → bool
Returns True if the box has a value set, regardless of the truthiness of that value
create
Section titled “create”create(*, size: algopy.UInt64 | int) → bool
Creates a box with the specified size, setting all bits to zero. Fails if the box already exists with a different size. Fails if the specified size is greater than the max box size (32,768)
Returns True if the box was created, False if the box already existed
delete
Section titled “delete”delete() → bool
Deletes the box if it exists and returns a value indicating if the box existed
extract
Section titled “extract”extract(start_index: algopy.UInt64 | int, length: algopy.UInt64 | int) → algopy.Bytes
Extract a slice of bytes from the box.
Fails if the box does not exist, or if start_index + length > len(box)
- Parameters:
- start_index – The offset to start extracting bytes from
- length – The number of bytes to extract
get(*, default: algopy.Bytes | bytes) → algopy.Bytes
Retrieve the contents of the box, or return the default value if the box has not been created.
- Parameters: default – The default value to return if the box has not been created
property key *: [algopy.Bytes]
Section titled “property key *: [algopy.Bytes]”property key : algopy.Bytes
Provides access to the raw storage key
property length *: [algopy.UInt64]
Section titled “property length *: [algopy.UInt64]”property length : algopy.UInt64
Get the length of this Box. Fails if the box does not exist
maybe() → tuple[algopy.Bytes, bool]
Retrieve the contents of the box if it exists, and return a boolean indicating if the box exists.
put(value: algopy.Bytes | bytes) → None
Replaces the contents of box with value. Fails if box exists and len(box) != len(value). Creates box if it does not exist
- Parameters: value – The value to write to the box
replace
Section titled “replace”replace(start_index: algopy.UInt64 | int, value: algopy.Bytes | bytes) → None
Write value to the box starting at start_index. Fails if the box does not exist,
or if start_index + len(value) > len(box)
- Parameters:
- start_index – The offset to start writing bytes from
- value – The bytes to be written
resize
Section titled “resize”resize(new_size: algopy.UInt64 | int) → None
Resizes the box the specified new_size. Truncating existing data if the new value is
shorter or padding with zero bytes if it is longer.
- Parameters: new_size – The new size of the box
splice
Section titled “splice”splice(start_index: algopy.UInt64 | int, length: algopy.UInt64 | int, value: algopy.Bytes | bytes) → None
set box to contain its previous bytes up to index start_index, followed by bytes,
followed by the original bytes of the box that began at index start_index + length
Important: This op does not resize the box If the new value is longer than the box size, it will be truncated. If the new value is shorter than the box size, it will be padded with zero bytes
- Parameters:
- start_index – The index to start inserting
value - length – The number of bytes after
start_indexto omit from the new value - value – The
valueto be inserted.
- start_index – The index to start inserting
class algopy.Bytes
Section titled “class algopy.Bytes”*class algopy.Bytes(value: bytes = b”, /)*
A byte sequence, with a maximum length of 4096 bytes, one of the primary data types on the AVM
Initialization
Section titled “Initialization”Bytes can be initialized with a Python bytes literal, or bytes variable declared at the module level
__add__
Section titled “__add__”__add__(other: algopy.Bytes | bytes) → algopy.Bytes
Concatenate Bytes with another Bytes or bytes literal
e.g. Bytes(b"Hello ") + b"World".
__and__
Section titled “__and__”__and__(other: algopy.Bytes | bytes) → algopy.Bytes
Bytes can bitwise and with another Bytes or bytes e.g. Bytes(b"FF") & b"0F")
__bool__
Section titled “__bool__”__bool__() → bool
Returns True if length of bytes is >0
__contains__
Section titled “__contains__”__contains__(other: algopy.Bytes | bytes) → bool
Test whether another Bytes is a substring of this one. Note this is expensive due to a lack of AVM support.
__eq__
Section titled “__eq__”__eq__(other: algopy.Bytes | bytes) → bool
Bytes can be compared using the == operator with another Bytes or bytes
__getitem__
Section titled “__getitem__”__getitem__(index: algopy.UInt64 | int | slice[int | algopy.UInt64 | None, int | algopy.UInt64 | None, None]) → algopy.Bytes
Returns a Bytes containing a single byte if indexed with UInt64 or int otherwise the substring o bytes described by the slice
__iadd__
Section titled “__iadd__”__iadd__(other: algopy.Bytes | bytes) → algopy.Bytes
Concatenate Bytes with another Bytes or bytes literal
e.g. a += Bytes(b"World").
__iand__
Section titled “__iand__”__iand__(other: algopy.Bytes | bytes) → algopy.Bytes
Bytes can bitwise and with another Bytes or bytes e.g. a &= Bytes(b"0F")
__invert__
Section titled “__invert__”__invert__() → algopy.Bytes
Bytes can be bitwise inverted e.g. ~Bytes(b"FF)
__ior__
Section titled “__ior__”__ior__(other: algopy.Bytes | bytes) → algopy.Bytes
Bytes can bitwise or with another Bytes or bytes e.g. a |= Bytes(b"0F")
__iter__
Section titled “__iter__”__iter__() → collections.abc.Iterator[algopy.Bytes]
Bytes can be iterated, yielding each consecutive byte
__ixor__
Section titled “__ixor__”__ixor__(other: algopy.Bytes | bytes) → algopy.Bytes
Bytes can bitwise xor with another Bytes or bytes e.g. a ^= Bytes(b"0F")
__ne__
Section titled “__ne__”__ne__(other: algopy.Bytes | bytes) → bool
Bytes can be compared using the != operator with another Bytes or bytes
__or__
Section titled “__or__”__or__(other: algopy.Bytes | bytes) → algopy.Bytes
Bytes can bitwise or with another Bytes or bytes e.g. Bytes(b"FF") | b"0F")
__radd__
Section titled “__radd__”__radd__(other: algopy.Bytes | bytes) → algopy.Bytes
Concatenate Bytes with another Bytes or bytes literal
e.g. b"Hello " + Bytes(b"World").
__reversed__
Section titled “__reversed__”__reversed__() → collections.abc.Iterator[algopy.Bytes]
Bytes can be iterated in reverse, yield each preceding byte starting at the end
__xor__
Section titled “__xor__”__xor__(other: algopy.Bytes | bytes) → algopy.Bytes
Bytes can bitwise xor with another Bytes or bytes e.g. Bytes(b"FF") ^ b"0F")
static from_base32
Section titled “static from_base32”*static from_base32(value: str, /) → algopy.Bytes*
Creates Bytes from a base32 encoded string e.g. Bytes.from_base32("74======")
static from_base64
Section titled “static from_base64”*static from_base64(value: str, /) → algopy.Bytes*
Creates Bytes from a base64 encoded string e.g. Bytes.from_base64("RkY=")
static from_hex
Section titled “static from_hex”*static from_hex(value: str, /) → algopy.Bytes*
Creates Bytes from a hex/octal encoded string e.g. Bytes.from_hex("FF")
property length *: [algopy.UInt64]
Section titled “property length *: [algopy.UInt64]”property length : algopy.UInt64
Returns the length of the Bytes
class algopy.BytesBacked
Section titled “class algopy.BytesBacked”Represents a type that is a single bytes value
property bytes *: [algopy.Bytes]
Section titled “property bytes *: [algopy.Bytes]”property bytes : algopy.Bytes
Get the underlying Bytes
classmethod from_bytes
Section titled “classmethod from_bytes”*classmethod from_bytes(value: algopy.Bytes | bytes, /) → Self*
Construct an instance from the underlying bytes (no validation)
class algopy.CompiledContract
Section titled “class algopy.CompiledContract”Provides compiled programs and state allocation values for a Contract.
Create by calling compile_contract.
approval_program *: [tuple]
Section titled “approval_program *: [tuple]”_approval_program _: tuple[algopy.Bytes, algopy.Bytes]**
None
Approval program pages for a contract, after template variables have been replaced and compiled to AVM bytecode
clear_state_program *: [tuple]
Section titled “clear_state_program *: [tuple]”_clear_state_program _: tuple[algopy.Bytes, algopy.Bytes]**
None
Clear state program pages for a contract, after template variables have been replaced and compiled to AVM bytecode
extra_program_pages *: [algopy.UInt64]
Section titled “extra_program_pages *: [algopy.UInt64]”_extra_program_pages _: algopy.UInt64**
None
By default, provides extra program pages required based on approval and clear state program size, can be overridden when calling compile_contract
global_bytes *: [algopy.UInt64]
Section titled “global_bytes *: [algopy.UInt64]”_global_bytes _: algopy.UInt64**
None
By default, provides global num bytes based on contract state totals, can be overridden when calling compile_contract
global_uints *: [algopy.UInt64]
Section titled “global_uints *: [algopy.UInt64]”_global_uints _: algopy.UInt64**
None
By default, provides global num uints based on contract state totals, can be overridden when calling compile_contract
local_bytes *: [algopy.UInt64]
Section titled “local_bytes *: [algopy.UInt64]”_local_bytes _: algopy.UInt64**
None
By default, provides local num bytes based on contract state totals, can be overridden when calling compile_contract
local_uints *: [algopy.UInt64]
Section titled “local_uints *: [algopy.UInt64]”_local_uints _: algopy.UInt64**
None
By default, provides local num uints based on contract state totals, can be overridden when calling compile_contract
class algopy.CompiledLogicSig
Section titled “class algopy.CompiledLogicSig”Provides account for a Logic Signature.
Create by calling compile_logicsig.
account *: [algopy.Account]
Section titled “account *: [algopy.Account]”_account _: algopy.Account**
None
Address of a logic sig program, after template variables have been replaced and compiled to AVM bytecode
class algopy.Contract
Section titled “class algopy.Contract”Base class for an Algorand Smart Contract
classmethod __initsubclass_
Section titled “classmethod __initsubclass_”*classmethod __initsubclass_(*, name: str = …, scratch_slots: algopy.urange | tuple[int | algopy.urange, …] | list[int | algopy.urange] = …, state_totals: algopy.StateTotals = …, avm_version: int = …)*
When declaring a Contract subclass, options and configuration are passed in the base class list:
class MyContract(algopy.Contract, name="CustomName"): ...-
Parameters:
-
name –
Will affect the output TEAL file name if there are multiple non-abstract contracts in the same file.
If the contract is a subclass of algopy.ARC4Contract,
namewill also be used as the contract name in the ARC-32 application.json, instead of the class name. -
scratch_slots –
Allows you to mark a slot ID or range of slot IDs as “off limits” to Puya. These slot ID(s) will never be written to or otherwise manipulating by the compiler itself. This is particularly useful in combination with
algopy.op.gload_bytes/algopy.op.gload_uint64which lets a contract in a group transaction read from the scratch slots of another contract that occurs earlier in the transaction group.In the case of inheritance, scratch slots reserved become cumulative. It is not an error to have overlapping ranges or values either, so if a base class contract reserves slots 0-5 inclusive and the derived contract reserves 5-10 inclusive, then within the derived contract all slots 0-10 will be marked as reserved.
-
state_totals –
Allows defining what values should be used for global and local uint and bytes storage values when creating a contract. Used when outputting ARC-32 application.json schemas.
If let unspecified, the totals will be determined by the compiler based on state variables assigned to
self.This setting is not inherited, and only applies to the exact
Contractit is specified on. If a base class does specify this setting, and a derived class does not, a warning will be emitted for the derived class. To resolve this warning,state_totalsmust be specified. Note that it is valid to not provide any arguments to theStateTotalsconstructor, like sostate_totals=StateTotals(), in which case all values will be automatically calculated. -
avm_version – Determines which AVM version to use, this affects what operations are supported. Defaults to value provided supplied on command line (which defaults to current mainnet version)
-
abstract approval_program
Section titled “abstract approval_program”*abstract approval_program() → algopy.UInt64 | bool*
Represents the program called for all transactions
where OnCompletion != ClearState
abstract clear_state_program
Section titled “abstract clear_state_program”*abstract clear_state_program() → algopy.UInt64 | bool*
Represents the program called when OnCompletion == ClearState
class algopy.FixedArray
Section titled “class algopy.FixedArray”*class algopy.FixedArray(values: collections.abc.Iterable[algopy._TArrayItem])*
A fixed length Array of the specified type and length
Initialization
Section titled “Initialization”__getitem__
Section titled “__getitem__”__getitem__(index: algopy.UInt64 | int) → algopy._TArrayItem
Gets the item of the array at the provided index
__iter__
Section titled “__iter__”___iter__() → Iterator[algopy.TArrayItem]
Returns an iterator for the items in the array
__reversed__
Section titled “__reversed__”___reversed__() → Iterator[algopy.TArrayItem]
Returns an iterator for the items in the array, in reverse order
__setitem__
Section titled “__setitem__”__setitem__(index: algopy.UInt64 | int, value: algopy._TArrayItem) → algopy._TArrayItem
Sets the item of the array at the specified index to provided value
copy() → Self
Create a copy of this array
freeze
Section titled “freeze”_freeze() → algopy.ImmutableFixedArray[algopy._TArrayItem, algopy.TArrayLength]
Returns an immutable copy of this array
classmethod full
Section titled “classmethod full”*classmethod full(item: algopy._TArrayItem) → Self*
Initializes a new array, filled with copies of the specified value
property length *: [algopy.UInt64]
Section titled “property length *: [algopy.UInt64]”property length : algopy.UInt64
Returns the (compile-time) length of the array
replace
Section titled “replace”replace(index: algopy.UInt64 | int, value: algopy._TArrayItem) → Self
Returns a copy of the array with the item at the specified index replaced with the specified value
validate
Section titled “validate”validate() → None
Performs validation to ensure the value is well-formed, errors if it is not
class algopy.Global
Section titled “class algopy.Global”Get Global values
Native TEAL op: global
asset_create_min_balance *: [Final]
Section titled “asset_create_min_balance *: [Final]”_asset_create_min_balance _: Final[algopy.UInt64]**
Ellipsis
The additional minimum balance required to create (and opt-in to) an asset.
asset_opt_in_min_balance *: [Final]
Section titled “asset_opt_in_min_balance *: [Final]”_asset_opt_in_min_balance _: Final[algopy.UInt64]**
Ellipsis
The additional minimum balance required to opt-in to an asset.
caller_application_address *: [Final]
Section titled “caller_application_address *: [Final]”_caller_application_address _: Final[algopy.Account]**
Ellipsis
The application address of the application that called this application. ZeroAddress if this application is at the top-level. Application mode only.
caller_application_id *: [Final]
Section titled “caller_application_id *: [Final]”_caller_application_id _: Final[algopy.UInt64]**
Ellipsis
The application ID of the application that called this application. 0 if this application is at the top-level. Application mode only.
creator_address *: [Final]
Section titled “creator_address *: [Final]”_creator_address _: Final[algopy.Account]**
Ellipsis
Address of the creator of the current application. Application mode only.
current_application_address *: [Final]
Section titled “current_application_address *: [Final]”_current_application_address _: Final[algopy.Account]**
Ellipsis
Address that the current application controls. Application mode only.
current_application_id *: [Final]
Section titled “current_application_id *: [Final]”_current_application_id _: Final[algopy.Application]**
Ellipsis
ID of current application executing. Application mode only.
genesis_hash *: [Final]
Section titled “genesis_hash *: [Final]”_genesis_hash _: Final[algopy.Bytes]**
Ellipsis
The Genesis Hash for the network.
group_id *: [Final]
Section titled “group_id *: [Final]”_group_id _: Final[algopy.Bytes]**
Ellipsis
ID of the transaction group. 32 zero bytes if the transaction is not part of a group.
group_size *: [Final]
Section titled “group_size *: [Final]”_group_size _: Final[algopy.UInt64]**
Ellipsis
Number of transactions in this atomic transaction group. At least 1
latest_timestamp *: [Final]
Section titled “latest_timestamp *: [Final]”_latest_timestamp _: Final[algopy.UInt64]**
Ellipsis
Last confirmed block UNIX timestamp. Fails if negative. Application mode only.
logic_sig_version *: [Final]
Section titled “logic_sig_version *: [Final]”_logic_sig_version _: Final[algopy.UInt64]**
Ellipsis
Maximum supported version
max_txn_life *: [Final]
Section titled “max_txn_life *: [Final]”_max_txn_life _: Final[algopy.UInt64]**
Ellipsis
rounds
min_balance *: [Final]
Section titled “min_balance *: [Final]”_min_balance _: Final[algopy.UInt64]**
Ellipsis
microalgos
min_txn_fee *: [Final]
Section titled “min_txn_fee *: [Final]”_min_txn_fee _: Final[algopy.UInt64]**
Ellipsis
microalgos
static opcode_budget
Section titled “static opcode_budget”*static opcode_budget() → algopy.UInt64*
The remaining cost that can be spent by opcodes in this program.
Native TEAL opcode: global
payouts_enabled *: [Final]
Section titled “payouts_enabled *: [Final]”_payouts_enabled _: Final[bool]**
Ellipsis
Whether block proposal payouts are enabled. Min AVM version: 11
payouts_go_online_fee *: [Final]
Section titled “payouts_go_online_fee *: [Final]”_payouts_go_online_fee _: Final[algopy.UInt64]**
Ellipsis
The fee required in a keyreg transaction to make an account incentive eligible. Min AVM version: 11
payouts_max_balance *: [Final]
Section titled “payouts_max_balance *: [Final]”_payouts_max_balance _: Final[algopy.UInt64]**
Ellipsis
The maximum balance an account can have in the agreement round to receive block payouts in the proposal round. Min AVM version: 11
payouts_min_balance *: [Final]
Section titled “payouts_min_balance *: [Final]”_payouts_min_balance _: Final[algopy.UInt64]**
Ellipsis
The minimum balance an account must have in the agreement round to receive block payouts in the proposal round. Min AVM version: 11
payouts_percent *: [Final]
Section titled “payouts_percent *: [Final]”_payouts_percent _: Final[algopy.UInt64]**
Ellipsis
The percentage of transaction fees in a block that can be paid to the block proposer. Min AVM version: 11
round *: [Final]
Section titled “round *: [Final]”_round _: Final[algopy.UInt64]**
Ellipsis
Current round number. Application mode only.
zero_address *: [Final]
Section titled “zero_address *: [Final]”_zero_address _: Final[algopy.Account]**
Ellipsis
32 byte address of all zero bytes
class algopy.GlobalState
Section titled “class algopy.GlobalState”Global state associated with the application, the key will be the name of the member, this is assigned to
The GlobalState class provides a richer API that in addition to storing and retrieving
values, can test if a value is set or unset it. However if this extra functionality is not
needed then it is simpler to just store the data without the GlobalState proxy
e.g. self.some_variable = UInt64(0)
__bool__
Section titled “__bool__”__bool__() → bool
Returns True if the key has a value set, regardless of the truthiness of that value
get(default: algopy._TState) → algopy._TState
Returns the value or default if no value is set
name = self.name.get(Bytes(b"no name")property key *: [algopy.Bytes]
Section titled “property key *: [algopy.Bytes]”property key : algopy.Bytes
Provides access to the raw storage key
maybe() → tuple[algopy._TState, bool]
Returns the value, and a bool
name, name_exists = self.name.maybe()if not name_exists: name = Bytes(b"no name")property value : algopy._TState
Section titled “property value : algopy._TState”Returns the value or and error if the value is not set
name = self.name.valueclass algopy.ImmutableArray
Section titled “class algopy.ImmutableArray”An immutable array that supports fixed and dynamically sized immutable elements. Modifications are done by returning a new copy of the array with the modifications applied.
Example:
arr = ImmutableArray[UInt64]()
arr = arr.append(UInt64(42))element = arr[0]assert element == 42arr = arr.pop()__add__
Section titled “__add__”___add__(other: collections.abc.Iterable[algopy.TArrayItem], /) → Self
Return a copy of this array extended with the contents of another array
__bool__
Section titled “__bool__”__bool__() → bool
Returns True if not an empty array
__getitem__
Section titled “__getitem__”__getitem__(index: algopy.UInt64 | int) → algopy._TArrayItem
Gets the item of the array at provided index
__reversed__
Section titled “__reversed__”___reversed__() → collections.abc.Iterator[algopy.TArrayItem]
Returns an iterator for the items in the array, in reverse order
append
Section titled “append”append(item: algopy._TArrayItem, /) → Self
Return a copy of the array with a another value appended to the end
property length *: [algopy.UInt64]
Section titled “property length *: [algopy.UInt64]”property length : algopy.UInt64
Returns the current length of the array
pop() → Self
Return a copy of this array with the last item removed
replace
Section titled “replace”replace(index: algopy.UInt64 | int, value: algopy._TArrayItem) → Self
Returns a copy of the array with the item at specified index replaced with the specified value
validate
Section titled “validate”validate() → None
Performs validation to ensure the value is well-formed, errors if it is not
class algopy.ImmutableFixedArray
Section titled “class algopy.ImmutableFixedArray”*class algopy.ImmutableFixedArray(values: collections.abc.Iterable[algopy._TArrayItem])*
An immutable fixed length Array of the specified type and length
Initialization
Section titled “Initialization”__getitem__
Section titled “__getitem__”__getitem__(index: algopy.UInt64 | int) → algopy._TArrayItem
Gets the item of the array at the provided index
__iter__
Section titled “__iter__”___iter__() → Iterator[algopy.TArrayItem]
Returns an iterator for the items in the array
__reversed__
Section titled “__reversed__”___reversed__() → Iterator[algopy.TArrayItem]
Returns an iterator for the items in the array, in reverse order
copy() → Self
Create a copy of this array
classmethod full
Section titled “classmethod full”*classmethod full(item: algopy._TArrayItem) → Self*
Initializes a new array, filled with copies of the specified value
property length *: [algopy.UInt64]
Section titled “property length *: [algopy.UInt64]”property length : algopy.UInt64
Returns the (compile-time) length of the array
replace
Section titled “replace”replace(index: algopy.UInt64 | int, value: algopy._TArrayItem) → Self
Returns a copy of the array with the item at the specified index replaced with the specified value
validate
Section titled “validate”validate() → None
Performs validation to ensure the value is well-formed, errors if it is not
class algopy.LocalState
Section titled “class algopy.LocalState”*class algopy.LocalState(type_: type[algopy._TState], /, *, key: algopy.String | algopy.Bytes | bytes | str = …, description: str = ”)*
Local state associated with the application and an account
Initialization
Section titled “Initialization”Declare the local state key and it’s associated type
self.names = LocalState(algopy.Bytes)__contains__
Section titled “__contains__”__contains__(account: algopy.Account | algopy.UInt64 | int) → bool
Can test if data exists by using an Account reference or foreign account index
assert account in self.names__delitem__
Section titled “__delitem__”__delitem__(account: algopy.Account | algopy.UInt64 | int) → None
Data can be removed by using an Account reference or foreign account index
del self.names[account]__getitem__
Section titled “__getitem__”__getitem__(account: algopy.Account | algopy.UInt64 | int) → algopy._TState
Data can be accessed by an Account reference or foreign account index
account_name = self.names[account]__setitem__
Section titled “__setitem__”__setitem__(account: algopy.Account | algopy.UInt64 | int, value: algopy._TState) → None
Data can be stored by using an Account reference or foreign account index
self.names[account] = account_nameget(account: algopy.Account | algopy.UInt64 | int, default: algopy._TState) → algopy._TState
Can retrieve value using an Account reference or foreign account index,
and a fallback default value.
name = self.names.get(account, Bytes(b"no name")property key *: [algopy.Bytes]
Section titled “property key *: [algopy.Bytes]”property key : algopy.Bytes
Provides access to the raw storage key
maybe(account: algopy.Account | algopy.UInt64 | int) → tuple[algopy._TState, bool]
Can retrieve value, and a bool indicating if the value was present
using an Account reference or foreign account index.
name, name_exists = self.names.maybe(account)if not name_exists: name = Bytes(b"no name")class algopy.LogicSig
Section titled “class algopy.LogicSig”A logic signature
class algopy.OnCompleteAction
Section titled “class algopy.OnCompleteAction”*class algopy.OnCompleteAction(value: int = 0, /)*
On Completion actions available in an application call transaction
Initialization
Section titled “Initialization”A UInt64 can be initialized with a Python int literal, or an int variable declared at the module level
ClearState *: [algopy.OnCompleteAction]
Section titled “ClearState *: [algopy.OnCompleteAction]”_ClearState _: algopy.OnCompleteAction**
Ellipsis
ClearState is similar to CloseOut, but may never fail. This allows users to reclaim their minimum balance from an application they no longer wish to opt in to.
CloseOut *: [algopy.OnCompleteAction]
Section titled “CloseOut *: [algopy.OnCompleteAction]”_CloseOut _: algopy.OnCompleteAction**
Ellipsis
CloseOut indicates that an application transaction will deallocate some LocalState for the application from the user’s account
DeleteApplication *: [algopy.OnCompleteAction]
Section titled “DeleteApplication *: [algopy.OnCompleteAction]”_DeleteApplication _: algopy.OnCompleteAction**
Ellipsis
DeleteApplication indicates that an application transaction will delete the AppParams for the application from the creator’s balance record
NoOp *: [algopy.OnCompleteAction]
Section titled “NoOp *: [algopy.OnCompleteAction]”_NoOp _: algopy.OnCompleteAction**
Ellipsis
NoOP indicates that no additional action is performed when the transaction completes
OptIn *: [algopy.OnCompleteAction]
Section titled “OptIn *: [algopy.OnCompleteAction]”_OptIn _: algopy.OnCompleteAction**
Ellipsis
OptIn indicates that an application transaction will allocate some LocalState for the application in the sender’s account
UpdateApplication *: [algopy.OnCompleteAction]
Section titled “UpdateApplication *: [algopy.OnCompleteAction]”_UpdateApplication _: algopy.OnCompleteAction**
Ellipsis
UpdateApplication indicates that an application transaction will update the ApprovalProgram and ClearStateProgram for the application
__add__
Section titled “__add__”__add__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can be added with another UInt64 or int e.g. UInt(4) + 2.
This will error on overflow
__and__
Section titled “__and__”__and__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can bitwise and with another UInt64 or int e.g. UInt64(4) & 2
__bool__
Section titled “__bool__”__bool__() → bool
A UInt64 will evaluate to False if zero, and True otherwise
__eq__
Section titled “__eq__”__eq__(other: algopy.UInt64 | int) → bool
A UInt64 can use the == operator with another UInt64 or int
__floordiv__
Section titled “__floordiv__”__floordiv__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can be floor divided with another UInt64 or int e.g. UInt64(4) // 2.
This will error on divide by zero
__ge__
Section titled “__ge__”__ge__(other: algopy.UInt64 | int) → bool
A UInt64 can use the >= operator with another UInt64 or int
__gt__
Section titled “__gt__”__gt__(other: algopy.UInt64 | int) → bool
A UInt64 can use the > operator with another UInt64 or int
__iadd__
Section titled “__iadd__”__iadd__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can be incremented with another UInt64 or int e.g. a += UInt(2).
This will error on overflow
__iand__
Section titled “__iand__”__iand__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can bitwise and with another UInt64 or int e.g. a &= UInt64(2)
__ifloordiv__
Section titled “__ifloordiv__”__ifloordiv__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can be floor divided with another UInt64 or int e.g. a //= UInt64(2).
This will error on divide by zero
__ilshift__
Section titled “__ilshift__”__ilshift__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can be left shifted by another UInt64 or int e.g. a <<= UInt64(2)
__imod__
Section titled “__imod__”__imod__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can be modded with another UInt64 or int e.g. a %= UInt64(2).
This will error on mod by zero
__imul__
Section titled “__imul__”__imul__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can be multiplied with another UInt64 or int e.g. a*= UInt64(2).
This will error on overflow
__index__
Section titled “__index__”__index__() → int
A UInt64 can be used in indexing/slice expressions
__invert__
Section titled “__invert__”__invert__() → algopy.UInt64
A UInt64 can be bitwise inverted e.g. ~UInt64(4)
__ior__
Section titled “__ior__”__ior__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can bitwise or with another UInt64 or int e.g. a |= UInt64(2)
__ipow__
Section titled “__ipow__”__ipow__(power: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can be raised to the power of another UInt64 or int e.g. a **= UInt64(2).
This will error on overflow
__irshift__
Section titled “__irshift__”__irshift__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can be right shifted by another UInt64 or int e.g. a >>= UInt64(2)
__isub__
Section titled “__isub__”__isub__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can be subtracted with another UInt64 or int e.g. a -= UInt64(2).
This will error on underflow
__ixor__
Section titled “__ixor__”__ixor__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can bitwise xor with another UInt64 or int e.g. a ^= UInt64(2)
__le__
Section titled “__le__”__le__(other: algopy.UInt64 | int) → bool
A UInt64 can use the <= operator with another UInt64 or int
__lshift__
Section titled “__lshift__”__lshift__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can be left shifted by another UInt64 or int e.g. UInt64(4) << 2
__lt__
Section titled “__lt__”__lt__(other: algopy.UInt64 | int) → bool
A UInt64 can use the < operator with another UInt64 or int
__mod__
Section titled “__mod__”__mod__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can be modded with another UInt64 or int e.g. UInt64(4) % 2.
This will error on mod by zero
__mul__
Section titled “__mul__”__mul__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can be multiplied with another UInt64 or int e.g. 4 + UInt64(2).
This will error on overflow
__ne__
Section titled “__ne__”__ne__(other: algopy.UInt64 | int) → bool
A UInt64 can use the != operator with another UInt64 or int
__or__
Section titled “__or__”__or__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can bitwise or with another UInt64 or int e.g. UInt64(4) | 2
__pos__
Section titled “__pos__”__pos__() → algopy.UInt64
Supports unary + operator. Redundant given the type is unsigned
__pow__
Section titled “__pow__”__pow__(power: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can be raised to the power of another UInt64 or int e.g. UInt64(4) ** 2.
This will error on overflow
__radd__
Section titled “__radd__”__radd__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can be added with another UInt64 or int e.g. 4 + UInt64(2).
This will error on overflow
__rand__
Section titled “__rand__”__rand__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can bitwise and with another UInt64 or int e.g. 4 & UInt64(2)
__rfloordiv__
Section titled “__rfloordiv__”__rfloordiv__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can be floor divided with another UInt64 or int e.g. 4 // UInt64(2).
This will error on divide by zero
__rlshift__
Section titled “__rlshift__”__rlshift__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can be left shifted by another UInt64 or int e.g. 4 << UInt64(2)
__rmod__
Section titled “__rmod__”__rmod__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can be modded with another UInt64 or int e.g. 4 % UInt64(2).
This will error on mod by zero
__rmul__
Section titled “__rmul__”__rmul__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can be multiplied with another UInt64 or int e.g. UInt64(4) + 2.
This will error on overflow
__ror__
Section titled “__ror__”__ror__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can bitwise or with another UInt64 or int e.g. 4 | UInt64(2)
__rpow__
Section titled “__rpow__”__rpow__(power: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can be raised to the power of another UInt64 or int e.g. 4 ** UInt64(2).
This will error on overflow
__rrshift__
Section titled “__rrshift__”__rrshift__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can be right shifted by another UInt64 or int e.g. 4 >> UInt64(2)
__rshift__
Section titled “__rshift__”__rshift__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can be right shifted by another UInt64 or int e.g. UInt64(4) >> 2
__rsub__
Section titled “__rsub__”__rsub__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can be subtracted with another UInt64 or int e.g. 4 - UInt64(2).
This will error on underflow
__rxor__
Section titled “__rxor__”__rxor__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can bitwise xor with another UInt64 or int e.g. 4 ^ UInt64(2)
__sub__
Section titled “__sub__”__sub__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can be subtracted with another UInt64 or int e.g. UInt(4) - 2.
This will error on underflow
__xor__
Section titled “__xor__”__xor__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can bitwise xor with another UInt64 or int e.g. UInt64(4) ^ 2
class algopy.OpUpFeeSource
Section titled “class algopy.OpUpFeeSource”*class algopy.OpUpFeeSource(value: int = 0, /)*
Defines the source of fees for the OpUp utility.
Initialization
Section titled “Initialization”A UInt64 can be initialized with a Python int literal, or an int variable declared at the module level
Any *: [algopy.OpUpFeeSource]
Section titled “Any *: [algopy.OpUpFeeSource]”_Any _: algopy.OpUpFeeSource**
Ellipsis
First the excess will be used, remaining fees will be taken from the app account
AppAccount *: [algopy.OpUpFeeSource]
Section titled “AppAccount *: [algopy.OpUpFeeSource]”_AppAccount _: algopy.OpUpFeeSource**
Ellipsis
The app’s account will cover all fees (set inner_tx.fee=Global.min_tx_fee())
GroupCredit *: [algopy.OpUpFeeSource]
Section titled “GroupCredit *: [algopy.OpUpFeeSource]”_GroupCredit _: algopy.OpUpFeeSource**
Ellipsis
Only the excess fee (credit) on the outer group should be used (set inner_tx.fee=0)
__add__
Section titled “__add__”__add__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can be added with another UInt64 or int e.g. UInt(4) + 2.
This will error on overflow
__and__
Section titled “__and__”__and__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can bitwise and with another UInt64 or int e.g. UInt64(4) & 2
__bool__
Section titled “__bool__”__bool__() → bool
A UInt64 will evaluate to False if zero, and True otherwise
__eq__
Section titled “__eq__”__eq__(other: algopy.UInt64 | int) → bool
A UInt64 can use the == operator with another UInt64 or int
__floordiv__
Section titled “__floordiv__”__floordiv__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can be floor divided with another UInt64 or int e.g. UInt64(4) // 2.
This will error on divide by zero
__ge__
Section titled “__ge__”__ge__(other: algopy.UInt64 | int) → bool
A UInt64 can use the >= operator with another UInt64 or int
__gt__
Section titled “__gt__”__gt__(other: algopy.UInt64 | int) → bool
A UInt64 can use the > operator with another UInt64 or int
__iadd__
Section titled “__iadd__”__iadd__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can be incremented with another UInt64 or int e.g. a += UInt(2).
This will error on overflow
__iand__
Section titled “__iand__”__iand__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can bitwise and with another UInt64 or int e.g. a &= UInt64(2)
__ifloordiv__
Section titled “__ifloordiv__”__ifloordiv__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can be floor divided with another UInt64 or int e.g. a //= UInt64(2).
This will error on divide by zero
__ilshift__
Section titled “__ilshift__”__ilshift__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can be left shifted by another UInt64 or int e.g. a <<= UInt64(2)
__imod__
Section titled “__imod__”__imod__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can be modded with another UInt64 or int e.g. a %= UInt64(2).
This will error on mod by zero
__imul__
Section titled “__imul__”__imul__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can be multiplied with another UInt64 or int e.g. a*= UInt64(2).
This will error on overflow
__index__
Section titled “__index__”__index__() → int
A UInt64 can be used in indexing/slice expressions
__invert__
Section titled “__invert__”__invert__() → algopy.UInt64
A UInt64 can be bitwise inverted e.g. ~UInt64(4)
__ior__
Section titled “__ior__”__ior__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can bitwise or with another UInt64 or int e.g. a |= UInt64(2)
__ipow__
Section titled “__ipow__”__ipow__(power: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can be raised to the power of another UInt64 or int e.g. a **= UInt64(2).
This will error on overflow
__irshift__
Section titled “__irshift__”__irshift__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can be right shifted by another UInt64 or int e.g. a >>= UInt64(2)
__isub__
Section titled “__isub__”__isub__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can be subtracted with another UInt64 or int e.g. a -= UInt64(2).
This will error on underflow
__ixor__
Section titled “__ixor__”__ixor__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can bitwise xor with another UInt64 or int e.g. a ^= UInt64(2)
__le__
Section titled “__le__”__le__(other: algopy.UInt64 | int) → bool
A UInt64 can use the <= operator with another UInt64 or int
__lshift__
Section titled “__lshift__”__lshift__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can be left shifted by another UInt64 or int e.g. UInt64(4) << 2
__lt__
Section titled “__lt__”__lt__(other: algopy.UInt64 | int) → bool
A UInt64 can use the < operator with another UInt64 or int
__mod__
Section titled “__mod__”__mod__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can be modded with another UInt64 or int e.g. UInt64(4) % 2.
This will error on mod by zero
__mul__
Section titled “__mul__”__mul__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can be multiplied with another UInt64 or int e.g. 4 + UInt64(2).
This will error on overflow
__ne__
Section titled “__ne__”__ne__(other: algopy.UInt64 | int) → bool
A UInt64 can use the != operator with another UInt64 or int
__or__
Section titled “__or__”__or__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can bitwise or with another UInt64 or int e.g. UInt64(4) | 2
__pos__
Section titled “__pos__”__pos__() → algopy.UInt64
Supports unary + operator. Redundant given the type is unsigned
__pow__
Section titled “__pow__”__pow__(power: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can be raised to the power of another UInt64 or int e.g. UInt64(4) ** 2.
This will error on overflow
__radd__
Section titled “__radd__”__radd__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can be added with another UInt64 or int e.g. 4 + UInt64(2).
This will error on overflow
__rand__
Section titled “__rand__”__rand__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can bitwise and with another UInt64 or int e.g. 4 & UInt64(2)
__rfloordiv__
Section titled “__rfloordiv__”__rfloordiv__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can be floor divided with another UInt64 or int e.g. 4 // UInt64(2).
This will error on divide by zero
__rlshift__
Section titled “__rlshift__”__rlshift__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can be left shifted by another UInt64 or int e.g. 4 << UInt64(2)
__rmod__
Section titled “__rmod__”__rmod__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can be modded with another UInt64 or int e.g. 4 % UInt64(2).
This will error on mod by zero
__rmul__
Section titled “__rmul__”__rmul__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can be multiplied with another UInt64 or int e.g. UInt64(4) + 2.
This will error on overflow
__ror__
Section titled “__ror__”__ror__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can bitwise or with another UInt64 or int e.g. 4 | UInt64(2)
__rpow__
Section titled “__rpow__”__rpow__(power: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can be raised to the power of another UInt64 or int e.g. 4 ** UInt64(2).
This will error on overflow
__rrshift__
Section titled “__rrshift__”__rrshift__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can be right shifted by another UInt64 or int e.g. 4 >> UInt64(2)
__rshift__
Section titled “__rshift__”__rshift__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can be right shifted by another UInt64 or int e.g. UInt64(4) >> 2
__rsub__
Section titled “__rsub__”__rsub__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can be subtracted with another UInt64 or int e.g. 4 - UInt64(2).
This will error on underflow
__rxor__
Section titled “__rxor__”__rxor__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can bitwise xor with another UInt64 or int e.g. 4 ^ UInt64(2)
__sub__
Section titled “__sub__”__sub__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can be subtracted with another UInt64 or int e.g. UInt(4) - 2.
This will error on underflow
__xor__
Section titled “__xor__”__xor__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can bitwise xor with another UInt64 or int e.g. UInt64(4) ^ 2
class algopy.ReferenceArray
Section titled “class algopy.ReferenceArray”A mutable array that supports fixed sized immutable elements. All references to this array will see any updates made to it.
These arrays may use scratch slots if required. If a contract also needs to use scratch slots
for other purposes then they should be reserved using the scratch_slots parameter
in algopy.Contract,
algopy.arc4.ARC4Contract or algopy.logicsig
__bool__
Section titled “__bool__”__bool__() → bool
Returns True if not an empty array
__getitem__
Section titled “__getitem__”__getitem__(index: algopy.UInt64 | int) → algopy._TArrayItem
Gets the item of the array at provided index
__iter__
Section titled “__iter__”___iter__() → collections.abc.Iterator[algopy.TArrayItem]
Returns an iterator for the items in the array
__reversed__
Section titled “__reversed__”___reversed__() → collections.abc.Iterator[algopy.TArrayItem]
Returns an iterator for the items in the array, in reverse order
__setitem__
Section titled “__setitem__”__setitem__(index: algopy.UInt64 | int, value: algopy._TArrayItem) → algopy._TArrayItem
Sets the item of the array at specified index to provided value
append
Section titled “append”append(item: algopy._TArrayItem, /) → None
Append an item to this array
copy() → Self
Create a copy of this array
extend
Section titled “extend”_extend(other: collections.abc.Iterable[algopy.TArrayItem], /) → None
Extend this array with the contents of another array
freeze
Section titled “freeze”_freeze() → algopy.ImmutableArray[algopy.TArrayItem]
Returns an immutable copy of this array
property length *: [algopy.UInt64]
Section titled “property length *: [algopy.UInt64]”property length : algopy.UInt64
Returns the current length of the array
pop() → algopy._TArrayItem
Remove and return the last item of this array
class algopy.StateTotals
Section titled “class algopy.StateTotals”*class algopy.StateTotals(*, global_uints: int = …, global_bytes: int = …, local_uints: int = …, local_bytes: int = …)*
Options class to manually define the total amount of global and local state contract will use,
used by Contract.__init_subclass__.
This is not required when all state is assigned to self., but is required if a
contract dynamically interacts with state via AppGlobal.get_bytes etc, or if you want
to reserve additional state storage for future contract updates, since the Algorand protocol
doesn’t allow increasing them after creation.
Initialization
Section titled “Initialization”Specify the totals for both global and local, and for each type. Any arguments not specified default to their automatically calculated values.
Values are validated against the known totals assigned through self., a warning is
produced if the total specified is insufficient to accommodate all self. state values
at once.
class algopy.String
Section titled “class algopy.String”*class algopy.String(value: str = ”, /)*
A UTF-8 encoded string.
In comparison to arc4.String, this type does not store the array length prefix, since that
information is always available through the len AVM op. This makes it more efficient to
operate on when doing operations such as concatenation.
Note that due to the lack of UTF-8 support in the AVM, indexing and length operations are not currently supported.
Initialization
Section titled “Initialization”A String can be initialized with a Python str literal, or a str variable
declared at the module level
__add__
Section titled “__add__”__add__(other: algopy.String | str) → algopy.String
Concatenate String with another String or str literal
e.g. String("Hello ") + "World".
__bool__
Section titled “__bool__”__bool__() → bool
Returns True if the string is not empty
__contains__
Section titled “__contains__”__contains__(other: algopy.String | str) → bool
Test whether another string is a substring of this one. Note this is expensive due to a lack of AVM support.
__eq__
Section titled “__eq__”__eq__(other: algopy.String | str) → bool
Supports using the == operator with another String or literal str
__iadd__
Section titled “__iadd__”__iadd__(other: algopy.String | str) → algopy.String
Concatenate String with another String or str literal
e.g. a = String("Hello"); a += "World".
__ne__
Section titled “__ne__”__ne__(other: algopy.String | str) → bool
Supports using the != operator with another String or literal str
__radd__
Section titled “__radd__”__radd__(other: algopy.String | str) → algopy.String
Concatenate String with another String or str literal
e.g. "Hello " + String("World").
property bytes *: [algopy.Bytes]
Section titled “property bytes *: [algopy.Bytes]”property bytes : algopy.Bytes
Get the underlying Bytes
endswith
Section titled “endswith”endswith(suffix: algopy.String | str) → bool
Check if this string ends with another string.
The behaviour should mirror str.endswith, for example, if suffix is the empty string,
the result will always be True.
Only a single argument is currently supported.
classmethod from_bytes
Section titled “classmethod from_bytes”*classmethod from_bytes(value: algopy.Bytes | bytes, /) → Self*
Construct an instance from the underlying bytes (no validation)
join(others: tuple[algopy.String | str, …], /) → algopy.String
Join a sequence of Strings with a common separator.
The behaviour should mirror str.join.
startswith
Section titled “startswith”startswith(prefix: algopy.String | str) → bool
Check if this string starts with another string.
The behaviour should mirror str.startswith, for example, if prefix is the empty string,
the result will always be True.
Only a single argument is currently supported.
class algopy.Struct
Section titled “class algopy.Struct”Base class for Struct types
_replace
Section titled “_replace”_replace(**kwargs: Any) → Self
Return a new instance of the struct replacing specified fields with new values.
Note that any mutable fields must be explicitly copied to avoid aliasing.
copy() → Self
Create a copy of this struct
validate
Section titled “validate”validate() → None
Performs validation to ensure the value is well-formed, errors if it is not
algopy.TemplateVar : algopy._TemplateVarGeneric
Section titled “algopy.TemplateVar : algopy._TemplateVarGeneric”Ellipsis
Template variables can be used to represent a placeholder for a deploy-time provided value.
class algopy.TransactionType
Section titled “class algopy.TransactionType”*class algopy.TransactionType(value: int = 0, /)*
The different transaction types available in a transaction
Initialization
Section titled “Initialization”A UInt64 can be initialized with a Python int literal, or an int variable declared at the module level
ApplicationCall *: [algopy.TransactionType]
Section titled “ApplicationCall *: [algopy.TransactionType]”_ApplicationCall _: algopy.TransactionType**
Ellipsis
An Application Call transaction
AssetConfig *: [algopy.TransactionType]
Section titled “AssetConfig *: [algopy.TransactionType]”_AssetConfig _: algopy.TransactionType**
Ellipsis
An Asset Config transaction
AssetFreeze *: [algopy.TransactionType]
Section titled “AssetFreeze *: [algopy.TransactionType]”_AssetFreeze _: algopy.TransactionType**
Ellipsis
An Asset Freeze transaction
AssetTransfer *: [algopy.TransactionType]
Section titled “AssetTransfer *: [algopy.TransactionType]”_AssetTransfer _: algopy.TransactionType**
Ellipsis
An Asset Transfer transaction
KeyRegistration *: [algopy.TransactionType]
Section titled “KeyRegistration *: [algopy.TransactionType]”_KeyRegistration _: algopy.TransactionType**
Ellipsis
A Key Registration transaction
Payment *: [algopy.TransactionType]
Section titled “Payment *: [algopy.TransactionType]”_Payment _: algopy.TransactionType**
Ellipsis
A Payment transaction
__add__
Section titled “__add__”__add__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can be added with another UInt64 or int e.g. UInt(4) + 2.
This will error on overflow
__and__
Section titled “__and__”__and__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can bitwise and with another UInt64 or int e.g. UInt64(4) & 2
__bool__
Section titled “__bool__”__bool__() → bool
A UInt64 will evaluate to False if zero, and True otherwise
__eq__
Section titled “__eq__”__eq__(other: algopy.UInt64 | int) → bool
A UInt64 can use the == operator with another UInt64 or int
__floordiv__
Section titled “__floordiv__”__floordiv__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can be floor divided with another UInt64 or int e.g. UInt64(4) // 2.
This will error on divide by zero
__ge__
Section titled “__ge__”__ge__(other: algopy.UInt64 | int) → bool
A UInt64 can use the >= operator with another UInt64 or int
__gt__
Section titled “__gt__”__gt__(other: algopy.UInt64 | int) → bool
A UInt64 can use the > operator with another UInt64 or int
__iadd__
Section titled “__iadd__”__iadd__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can be incremented with another UInt64 or int e.g. a += UInt(2).
This will error on overflow
__iand__
Section titled “__iand__”__iand__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can bitwise and with another UInt64 or int e.g. a &= UInt64(2)
__ifloordiv__
Section titled “__ifloordiv__”__ifloordiv__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can be floor divided with another UInt64 or int e.g. a //= UInt64(2).
This will error on divide by zero
__ilshift__
Section titled “__ilshift__”__ilshift__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can be left shifted by another UInt64 or int e.g. a <<= UInt64(2)
__imod__
Section titled “__imod__”__imod__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can be modded with another UInt64 or int e.g. a %= UInt64(2).
This will error on mod by zero
__imul__
Section titled “__imul__”__imul__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can be multiplied with another UInt64 or int e.g. a*= UInt64(2).
This will error on overflow
__index__
Section titled “__index__”__index__() → int
A UInt64 can be used in indexing/slice expressions
__invert__
Section titled “__invert__”__invert__() → algopy.UInt64
A UInt64 can be bitwise inverted e.g. ~UInt64(4)
__ior__
Section titled “__ior__”__ior__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can bitwise or with another UInt64 or int e.g. a |= UInt64(2)
__ipow__
Section titled “__ipow__”__ipow__(power: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can be raised to the power of another UInt64 or int e.g. a **= UInt64(2).
This will error on overflow
__irshift__
Section titled “__irshift__”__irshift__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can be right shifted by another UInt64 or int e.g. a >>= UInt64(2)
__isub__
Section titled “__isub__”__isub__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can be subtracted with another UInt64 or int e.g. a -= UInt64(2).
This will error on underflow
__ixor__
Section titled “__ixor__”__ixor__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can bitwise xor with another UInt64 or int e.g. a ^= UInt64(2)
__le__
Section titled “__le__”__le__(other: algopy.UInt64 | int) → bool
A UInt64 can use the <= operator with another UInt64 or int
__lshift__
Section titled “__lshift__”__lshift__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can be left shifted by another UInt64 or int e.g. UInt64(4) << 2
__lt__
Section titled “__lt__”__lt__(other: algopy.UInt64 | int) → bool
A UInt64 can use the < operator with another UInt64 or int
__mod__
Section titled “__mod__”__mod__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can be modded with another UInt64 or int e.g. UInt64(4) % 2.
This will error on mod by zero
__mul__
Section titled “__mul__”__mul__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can be multiplied with another UInt64 or int e.g. 4 + UInt64(2).
This will error on overflow
__ne__
Section titled “__ne__”__ne__(other: algopy.UInt64 | int) → bool
A UInt64 can use the != operator with another UInt64 or int
__or__
Section titled “__or__”__or__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can bitwise or with another UInt64 or int e.g. UInt64(4) | 2
__pos__
Section titled “__pos__”__pos__() → algopy.UInt64
Supports unary + operator. Redundant given the type is unsigned
__pow__
Section titled “__pow__”__pow__(power: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can be raised to the power of another UInt64 or int e.g. UInt64(4) ** 2.
This will error on overflow
__radd__
Section titled “__radd__”__radd__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can be added with another UInt64 or int e.g. 4 + UInt64(2).
This will error on overflow
__rand__
Section titled “__rand__”__rand__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can bitwise and with another UInt64 or int e.g. 4 & UInt64(2)
__rfloordiv__
Section titled “__rfloordiv__”__rfloordiv__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can be floor divided with another UInt64 or int e.g. 4 // UInt64(2).
This will error on divide by zero
__rlshift__
Section titled “__rlshift__”__rlshift__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can be left shifted by another UInt64 or int e.g. 4 << UInt64(2)
__rmod__
Section titled “__rmod__”__rmod__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can be modded with another UInt64 or int e.g. 4 % UInt64(2).
This will error on mod by zero
__rmul__
Section titled “__rmul__”__rmul__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can be multiplied with another UInt64 or int e.g. UInt64(4) + 2.
This will error on overflow
__ror__
Section titled “__ror__”__ror__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can bitwise or with another UInt64 or int e.g. 4 | UInt64(2)
__rpow__
Section titled “__rpow__”__rpow__(power: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can be raised to the power of another UInt64 or int e.g. 4 ** UInt64(2).
This will error on overflow
__rrshift__
Section titled “__rrshift__”__rrshift__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can be right shifted by another UInt64 or int e.g. 4 >> UInt64(2)
__rshift__
Section titled “__rshift__”__rshift__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can be right shifted by another UInt64 or int e.g. UInt64(4) >> 2
__rsub__
Section titled “__rsub__”__rsub__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can be subtracted with another UInt64 or int e.g. 4 - UInt64(2).
This will error on underflow
__rxor__
Section titled “__rxor__”__rxor__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can bitwise xor with another UInt64 or int e.g. 4 ^ UInt64(2)
__sub__
Section titled “__sub__”__sub__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can be subtracted with another UInt64 or int e.g. UInt(4) - 2.
This will error on underflow
__xor__
Section titled “__xor__”__xor__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can bitwise xor with another UInt64 or int e.g. UInt64(4) ^ 2
class algopy.Txn
Section titled “class algopy.Txn”Get values for the current executing transaction
Native TEAL ops: txn, txnas
static accounts
Section titled “static accounts”*static accounts(a: algopy.UInt64 | int, /) → algopy.Account*
Accounts listed in the ApplicationCall transaction
Native TEAL opcode: txna, txnas
amount *: [Final]
Section titled “amount *: [Final]”_amount _: Final[algopy.UInt64]**
Ellipsis
microalgos
static application_args
Section titled “static application_args”*static application_args(a: algopy.UInt64 | int, /) → algopy.Bytes*
Arguments passed to the application in the ApplicationCall transaction
Native TEAL opcode: txna, txnas
application_id *: [Final]
Section titled “application_id *: [Final]”_application_id _: Final[algopy.Application]**
Ellipsis
ApplicationID from ApplicationCall transaction
static applications
Section titled “static applications”*static applications(a: algopy.UInt64 | int, /) → algopy.Application*
Foreign Apps listed in the ApplicationCall transaction
Native TEAL opcode: txna, txnas
approval_program *: [Final]
Section titled “approval_program *: [Final]”_approval_program _: Final[algopy.Bytes]**
Ellipsis
Approval program
static approval_program_pages
Section titled “static approval_program_pages”*static approval_program_pages(a: algopy.UInt64 | int, /) → algopy.Bytes*
Approval Program as an array of pages
Native TEAL opcode: txna, txnas
asset_amount *: [Final]
Section titled “asset_amount *: [Final]”_asset_amount _: Final[algopy.UInt64]**
Ellipsis
value in Asset’s units
asset_close_to *: [Final]
Section titled “asset_close_to *: [Final]”_asset_close_to _: Final[algopy.Account]**
Ellipsis
32 byte address
asset_receiver *: [Final]
Section titled “asset_receiver *: [Final]”_asset_receiver _: Final[algopy.Account]**
Ellipsis
32 byte address
asset_sender *: [Final]
Section titled “asset_sender *: [Final]”_asset_sender _: Final[algopy.Account]**
Ellipsis
32 byte address. Source of assets if Sender is the Asset’s Clawback address.
static assets
Section titled “static assets”*static assets(a: algopy.UInt64 | int, /) → algopy.Asset*
Foreign Assets listed in the ApplicationCall transaction
Native TEAL opcode: txna, txnas
clear_state_program *: [Final]
Section titled “clear_state_program *: [Final]”_clear_state_program _: Final[algopy.Bytes]**
Ellipsis
Clear state program
static clear_state_program_pages
Section titled “static clear_state_program_pages”*static clear_state_program_pages(a: algopy.UInt64 | int, /) → algopy.Bytes*
ClearState Program as an array of pages
Native TEAL opcode: txna, txnas
close_remainder_to *: [Final]
Section titled “close_remainder_to *: [Final]”_close_remainder_to _: Final[algopy.Account]**
Ellipsis
32 byte address
config_asset *: [Final]
Section titled “config_asset *: [Final]”_config_asset _: Final[algopy.Asset]**
Ellipsis
Asset ID in asset config transaction
config_asset_clawback *: [Final]
Section titled “config_asset_clawback *: [Final]”_config_asset_clawback _: Final[algopy.Account]**
Ellipsis
32 byte address
config_asset_decimals *: [Final]
Section titled “config_asset_decimals *: [Final]”_config_asset_decimals _: Final[algopy.UInt64]**
Ellipsis
Number of digits to display after the decimal place when displaying the asset
config_asset_default_frozen *: [Final]
Section titled “config_asset_default_frozen *: [Final]”_config_asset_default_frozen _: Final[bool]**
Ellipsis
Whether the asset’s slots are frozen by default or not, 0 or 1
config_asset_freeze *: [Final]
Section titled “config_asset_freeze *: [Final]”_config_asset_freeze _: Final[algopy.Account]**
Ellipsis
32 byte address
config_asset_manager *: [Final]
Section titled “config_asset_manager *: [Final]”_config_asset_manager _: Final[algopy.Account]**
Ellipsis
32 byte address
config_asset_metadata_hash *: [Final]
Section titled “config_asset_metadata_hash *: [Final]”_config_asset_metadata_hash _: Final[algopy.Bytes]**
Ellipsis
32 byte commitment to unspecified asset metadata
config_asset_name *: [Final]
Section titled “config_asset_name *: [Final]”_config_asset_name _: Final[algopy.Bytes]**
Ellipsis
The asset name
config_asset_reserve *: [Final]
Section titled “config_asset_reserve *: [Final]”_config_asset_reserve _: Final[algopy.Account]**
Ellipsis
32 byte address
config_asset_total *: [Final]
Section titled “config_asset_total *: [Final]”_config_asset_total _: Final[algopy.UInt64]**
Ellipsis
Total number of units of this asset created
config_asset_unit_name *: [Final]
Section titled “config_asset_unit_name *: [Final]”_config_asset_unit_name _: Final[algopy.Bytes]**
Ellipsis
Unit name of the asset
config_asset_url *: [Final]
Section titled “config_asset_url *: [Final]”_config_asset_url _: Final[algopy.Bytes]**
Ellipsis
URL
created_application_id *: [Final]
Section titled “created_application_id *: [Final]”_created_application_id _: Final[algopy.Application]**
Ellipsis
ApplicationID allocated by the creation of an application (only with itxn in v5). Application mode only
created_asset_id *: [Final]
Section titled “created_asset_id *: [Final]”_created_asset_id _: Final[algopy.Asset]**
Ellipsis
Asset ID allocated by the creation of an ASA (only with itxn in v5). Application mode only
extra_program_pages *: [Final]
Section titled “extra_program_pages *: [Final]”_extra_program_pages _: Final[algopy.UInt64]**
Ellipsis
Number of additional pages for each of the application’s approval and clear state programs. An ExtraProgramPages of 1 means 2048 more total bytes, or 1024 for each program.
fee *: [Final]
Section titled “fee *: [Final]”_fee _: Final[algopy.UInt64]**
Ellipsis
microalgos
first_valid *: [Final]
Section titled “first_valid *: [Final]”_first_valid _: Final[algopy.UInt64]**
Ellipsis
round number
first_valid_time *: [Final]
Section titled “first_valid_time *: [Final]”_first_valid_time _: Final[algopy.UInt64]**
Ellipsis
UNIX timestamp of block before txn.FirstValid. Fails if negative
freeze_asset *: [Final]
Section titled “freeze_asset *: [Final]”_freeze_asset _: Final[algopy.Asset]**
Ellipsis
Asset ID being frozen or un-frozen
freeze_asset_account *: [Final]
Section titled “freeze_asset_account *: [Final]”_freeze_asset_account _: Final[algopy.Account]**
Ellipsis
32 byte address of the account whose asset slot is being frozen or un-frozen
freeze_asset_frozen *: [Final]
Section titled “freeze_asset_frozen *: [Final]”_freeze_asset_frozen _: Final[bool]**
Ellipsis
The new frozen value, 0 or 1
global_num_byte_slice *: [Final]
Section titled “global_num_byte_slice *: [Final]”_global_num_byte_slice _: Final[algopy.UInt64]**
Ellipsis
Number of global state byteslices in ApplicationCall
global_num_uint *: [Final]
Section titled “global_num_uint *: [Final]”_global_num_uint _: Final[algopy.UInt64]**
Ellipsis
Number of global state integers in ApplicationCall
group_index *: [Final]
Section titled “group_index *: [Final]”_group_index _: Final[algopy.UInt64]**
Ellipsis
Position of this transaction within an atomic transaction group. A stand-alone transaction is implicitly element 0 in a group of 1
last_log *: [Final]
Section titled “last_log *: [Final]”_last_log _: Final[algopy.Bytes]**
Ellipsis
The last message emitted. Empty bytes if none were emitted. Application mode only
last_valid *: [Final]
Section titled “last_valid *: [Final]”_last_valid _: Final[algopy.UInt64]**
Ellipsis
round number
lease *: [Final]
Section titled “lease *: [Final]”_lease _: Final[algopy.Bytes]**
Ellipsis
32 byte lease value
local_num_byte_slice *: [Final]
Section titled “local_num_byte_slice *: [Final]”_local_num_byte_slice _: Final[algopy.UInt64]**
Ellipsis
Number of local state byteslices in ApplicationCall
local_num_uint *: [Final]
Section titled “local_num_uint *: [Final]”_local_num_uint _: Final[algopy.UInt64]**
Ellipsis
Number of local state integers in ApplicationCall
static logs
Section titled “static logs”*static logs(a: algopy.UInt64 | int, /) → algopy.Bytes*
Log messages emitted by an application call (only with itxn in v5). Application mode only
Native TEAL opcode: txna, txnas
nonparticipation *: [Final]
Section titled “nonparticipation *: [Final]”_nonparticipation _: Final[bool]**
Ellipsis
Marks an account nonparticipating for rewards
note *: [Final]
Section titled “note *: [Final]”_note _: Final[algopy.Bytes]**
Ellipsis
Any data up to 1024 bytes
num_accounts *: [Final]
Section titled “num_accounts *: [Final]”_num_accounts _: Final[algopy.UInt64]**
Ellipsis
Number of Accounts
num_app_args *: [Final]
Section titled “num_app_args *: [Final]”_num_app_args _: Final[algopy.UInt64]**
Ellipsis
Number of ApplicationArgs
num_applications *: [Final]
Section titled “num_applications *: [Final]”_num_applications _: Final[algopy.UInt64]**
Ellipsis
Number of Applications
num_approval_program_pages *: [Final]
Section titled “num_approval_program_pages *: [Final]”_num_approval_program_pages _: Final[algopy.UInt64]**
Ellipsis
Number of Approval Program pages
num_assets *: [Final]
Section titled “num_assets *: [Final]”_num_assets _: Final[algopy.UInt64]**
Ellipsis
Number of Assets
num_clear_state_program_pages *: [Final]
Section titled “num_clear_state_program_pages *: [Final]”_num_clear_state_program_pages _: Final[algopy.UInt64]**
Ellipsis
Number of ClearState Program pages
num_logs *: [Final]
Section titled “num_logs *: [Final]”_num_logs _: Final[algopy.UInt64]**
Ellipsis
Number of Logs (only with itxn in v5). Application mode only
on_completion *: [Final]
Section titled “on_completion *: [Final]”_on_completion _: Final[algopy.OnCompleteAction]**
Ellipsis
ApplicationCall transaction on completion action
receiver *: [Final]
Section titled “receiver *: [Final]”_receiver _: Final[algopy.Account]**
Ellipsis
32 byte address
reject_version *: [Final]
Section titled “reject_version *: [Final]”_reject_version _: Final[algopy.UInt64]**
Ellipsis
Application version for which the txn must reject Min AVM version: 12
rekey_to *: [Final]
Section titled “rekey_to *: [Final]”_rekey_to _: Final[algopy.Account]**
Ellipsis
32 byte Sender’s new AuthAddr
selection_pk *: [Final]
Section titled “selection_pk *: [Final]”_selection_pk _: Final[algopy.Bytes]**
Ellipsis
32 byte address
sender *: [Final]
Section titled “sender *: [Final]”_sender _: Final[algopy.Account]**
Ellipsis
32 byte address
state_proof_pk *: [Final]
Section titled “state_proof_pk *: [Final]”_state_proof_pk _: Final[algopy.Bytes]**
Ellipsis
State proof public key
tx_id *: [Final]
Section titled “tx_id *: [Final]”_tx_id _: Final[algopy.Bytes]**
Ellipsis
The computed ID for this transaction. 32 bytes.
type *: [Final]
Section titled “type *: [Final]”_type _: Final[algopy.Bytes]**
Ellipsis
Transaction type as bytes
type_enum *: [Final]
Section titled “type_enum *: [Final]”_type_enum _: Final[algopy.TransactionType]**
Ellipsis
Transaction type as integer
vote_first *: [Final]
Section titled “vote_first *: [Final]”_vote_first _: Final[algopy.UInt64]**
Ellipsis
The first round that the participation key is valid.
vote_key_dilution *: [Final]
Section titled “vote_key_dilution *: [Final]”_vote_key_dilution _: Final[algopy.UInt64]**
Ellipsis
Dilution for the 2-level participation key
vote_last *: [Final]
Section titled “vote_last *: [Final]”_vote_last _: Final[algopy.UInt64]**
Ellipsis
The last round that the participation key is valid.
vote_pk *: [Final]
Section titled “vote_pk *: [Final]”_vote_pk _: Final[algopy.Bytes]**
Ellipsis
32 byte address
xfer_asset *: [Final]
Section titled “xfer_asset *: [Final]”_xfer_asset _: Final[algopy.Asset]**
Ellipsis
Asset ID
class algopy.UInt64
Section titled “class algopy.UInt64”*class algopy.UInt64(value: int = 0, /)*
A 64-bit unsigned integer, one of the primary data types on the AVM
Initialization
Section titled “Initialization”A UInt64 can be initialized with a Python int literal, or an int variable declared at the module level
__add__
Section titled “__add__”__add__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can be added with another UInt64 or int e.g. UInt(4) + 2.
This will error on overflow
__and__
Section titled “__and__”__and__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can bitwise and with another UInt64 or int e.g. UInt64(4) & 2
__bool__
Section titled “__bool__”__bool__() → bool
A UInt64 will evaluate to False if zero, and True otherwise
__eq__
Section titled “__eq__”__eq__(other: algopy.UInt64 | int) → bool
A UInt64 can use the == operator with another UInt64 or int
__floordiv__
Section titled “__floordiv__”__floordiv__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can be floor divided with another UInt64 or int e.g. UInt64(4) // 2.
This will error on divide by zero
__ge__
Section titled “__ge__”__ge__(other: algopy.UInt64 | int) → bool
A UInt64 can use the >= operator with another UInt64 or int
__gt__
Section titled “__gt__”__gt__(other: algopy.UInt64 | int) → bool
A UInt64 can use the > operator with another UInt64 or int
__iadd__
Section titled “__iadd__”__iadd__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can be incremented with another UInt64 or int e.g. a += UInt(2).
This will error on overflow
__iand__
Section titled “__iand__”__iand__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can bitwise and with another UInt64 or int e.g. a &= UInt64(2)
__ifloordiv__
Section titled “__ifloordiv__”__ifloordiv__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can be floor divided with another UInt64 or int e.g. a //= UInt64(2).
This will error on divide by zero
__ilshift__
Section titled “__ilshift__”__ilshift__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can be left shifted by another UInt64 or int e.g. a <<= UInt64(2)
__imod__
Section titled “__imod__”__imod__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can be modded with another UInt64 or int e.g. a %= UInt64(2).
This will error on mod by zero
__imul__
Section titled “__imul__”__imul__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can be multiplied with another UInt64 or int e.g. a*= UInt64(2).
This will error on overflow
__index__
Section titled “__index__”__index__() → int
A UInt64 can be used in indexing/slice expressions
__invert__
Section titled “__invert__”__invert__() → algopy.UInt64
A UInt64 can be bitwise inverted e.g. ~UInt64(4)
__ior__
Section titled “__ior__”__ior__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can bitwise or with another UInt64 or int e.g. a |= UInt64(2)
__ipow__
Section titled “__ipow__”__ipow__(power: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can be raised to the power of another UInt64 or int e.g. a **= UInt64(2).
This will error on overflow
__irshift__
Section titled “__irshift__”__irshift__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can be right shifted by another UInt64 or int e.g. a >>= UInt64(2)
__isub__
Section titled “__isub__”__isub__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can be subtracted with another UInt64 or int e.g. a -= UInt64(2).
This will error on underflow
__ixor__
Section titled “__ixor__”__ixor__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can bitwise xor with another UInt64 or int e.g. a ^= UInt64(2)
__le__
Section titled “__le__”__le__(other: algopy.UInt64 | int) → bool
A UInt64 can use the <= operator with another UInt64 or int
__lshift__
Section titled “__lshift__”__lshift__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can be left shifted by another UInt64 or int e.g. UInt64(4) << 2
__lt__
Section titled “__lt__”__lt__(other: algopy.UInt64 | int) → bool
A UInt64 can use the < operator with another UInt64 or int
__mod__
Section titled “__mod__”__mod__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can be modded with another UInt64 or int e.g. UInt64(4) % 2.
This will error on mod by zero
__mul__
Section titled “__mul__”__mul__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can be multiplied with another UInt64 or int e.g. 4 + UInt64(2).
This will error on overflow
__ne__
Section titled “__ne__”__ne__(other: algopy.UInt64 | int) → bool
A UInt64 can use the != operator with another UInt64 or int
__or__
Section titled “__or__”__or__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can bitwise or with another UInt64 or int e.g. UInt64(4) | 2
__pos__
Section titled “__pos__”__pos__() → algopy.UInt64
Supports unary + operator. Redundant given the type is unsigned
__pow__
Section titled “__pow__”__pow__(power: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can be raised to the power of another UInt64 or int e.g. UInt64(4) ** 2.
This will error on overflow
__radd__
Section titled “__radd__”__radd__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can be added with another UInt64 or int e.g. 4 + UInt64(2).
This will error on overflow
__rand__
Section titled “__rand__”__rand__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can bitwise and with another UInt64 or int e.g. 4 & UInt64(2)
__rfloordiv__
Section titled “__rfloordiv__”__rfloordiv__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can be floor divided with another UInt64 or int e.g. 4 // UInt64(2).
This will error on divide by zero
__rlshift__
Section titled “__rlshift__”__rlshift__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can be left shifted by another UInt64 or int e.g. 4 << UInt64(2)
__rmod__
Section titled “__rmod__”__rmod__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can be modded with another UInt64 or int e.g. 4 % UInt64(2).
This will error on mod by zero
__rmul__
Section titled “__rmul__”__rmul__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can be multiplied with another UInt64 or int e.g. UInt64(4) + 2.
This will error on overflow
__ror__
Section titled “__ror__”__ror__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can bitwise or with another UInt64 or int e.g. 4 | UInt64(2)
__rpow__
Section titled “__rpow__”__rpow__(power: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can be raised to the power of another UInt64 or int e.g. 4 ** UInt64(2).
This will error on overflow
__rrshift__
Section titled “__rrshift__”__rrshift__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can be right shifted by another UInt64 or int e.g. 4 >> UInt64(2)
__rshift__
Section titled “__rshift__”__rshift__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can be right shifted by another UInt64 or int e.g. UInt64(4) >> 2
__rsub__
Section titled “__rsub__”__rsub__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can be subtracted with another UInt64 or int e.g. 4 - UInt64(2).
This will error on underflow
__rxor__
Section titled “__rxor__”__rxor__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can bitwise xor with another UInt64 or int e.g. 4 ^ UInt64(2)
__sub__
Section titled “__sub__”__sub__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can be subtracted with another UInt64 or int e.g. UInt(4) - 2.
This will error on underflow
__xor__
Section titled “__xor__”__xor__(other: algopy.UInt64 | int) → algopy.UInt64
A UInt64 can bitwise xor with another UInt64 or int e.g. UInt64(4) ^ 2
algopy.compile_contract
Section titled “algopy.compile_contract”algopy.compile_contract(contract: type[Contract], /, *, extra_program_pages: algopy.UInt64 | int = …, global_uints: algopy.UInt64 | int = …, global_bytes: algopy.UInt64 | int = …, local_uints: algopy.UInt64 | int = …, local_bytes: algopy.UInt64 | int = …, template_vars: collections.abc.Mapping[str, object] = …, template_vars_prefix: str = …) → algopy.CompiledContract
Returns the compiled data for the specified contract
- Parameters:
- contract – Algorand Python Contract to compile
- extra_program_pages – Number of extra program pages, defaults to minimum required for contract
- global_uints – Number of global uint64s, defaults to value defined for contract
- global_bytes – Number of global bytes, defaults to value defined for contract
- local_uints – Number of local uint64s, defaults to value defined for contract
- local_bytes – Number of local bytes, defaults to value defined for contract
- template_vars – Template variables to substitute into the contract, key should be without the prefix, must evaluate to a compile time constant and match the type of the template var declaration
- template_vars_prefix – Prefix to add to provided template vars, defaults to the prefix supplied on command line (which defaults to TMPL_)
algopy.compile_logicsig
Section titled “algopy.compile_logicsig”algopy.compile_logicsig(logicsig: LogicSig, /, *, template_vars: collections.abc.Mapping[str, object] = …, template_vars_prefix: str = …) → algopy.CompiledLogicSig
Returns the Account for the specified logic signature
- Parameters:
- logicsig – Algorand Python Logic Signature to compile
- template_vars – Template variables to substitute into the logic signature, key should be without the prefix, must evaluate to a compile time constant and match the type of the template var declaration
- template_vars_prefix – Prefix to add to provided template vars, defaults to the prefix supplied on command line (which defaults to TMPL_)
algopy.ensure_budget
Section titled “algopy.ensure_budget”algopy.ensure_budget(required_budget: algopy.UInt64 | int, fee_source: algopy.OpUpFeeSource = …) → None
Ensure the available op code budget is greater than or equal to required_budget
algopy.log
Section titled “algopy.log”algopy.log(*args: object, sep: algopy.String | str | algopy.Bytes | bytes = ”) → None
Concatenates and logs supplied args as a single bytes value.
UInt64 args are converted to bytes and each argument is separated by sep.
Literal str values will be encoded as UTF8.
algopy.logicsig
Section titled “algopy.logicsig”algopy.logicsig(*, name: str = …, avm_version: int = …, scratch_slots: algopy.urange | tuple[int | algopy.urange, …] | list[int | algopy.urange] = ()) → collections.abc.Callable[[collections.abc.Callable[[], bool | algopy.UInt64]], algopy.LogicSig]
Decorator to indicate a function is a logic signature
algopy.size_of
Section titled “algopy.size_of”algopy.size_of(type_or_expression: type | object, /) → algopy.UInt64
Returns the number of bytes required to store the provided type object or the type of provided expression
algopy.subroutine
Section titled “algopy.subroutine”_algopy.subroutine(*, inline: bool | Literal[auto] = ‘auto’) → collections.abc.Callable[[collections.abc.Callable[algopy._P, algopy._R]], collections.abc.Callable[algopy._P, algopy.R]]
Decorator to indicate functions or methods that can be called by a Smart Contract
Inlining can be controlled with the decorator argument inline.
When unspecified it defaults to auto, which allows the optimizer to decide whether to inline
or not. Setting inline=True forces inlining, and inline=False ensures the function will
never be inlined.
class algopy.uenumerate
Section titled “class algopy.uenumerate”*class algopy.uenumerate(iterable: collections.abc.Iterable[algopy._T])*
Yields pairs containing a count (from zero) and a value yielded by the iterable argument.
enumerate is useful for obtaining an indexed list: (0, seq[0]), (1, seq[1]), (2, seq[2]), …
enumerate((a, b, c)) produces (0, a), (1, b), (2, c)
Initialization
Section titled “Initialization”class algopy.urange
Section titled “class algopy.urange”Produces a sequence of UInt64 from start (inclusive) to stop (exclusive) by step.
urange(4) produces 0, 1, 2, 3 urange(i, j) produces i, i+1, i+2, …, j-1. urange(i, j, 2) produces i, i+2, i+4, …, i+2n where n is the largest value where i+2n < j
algopy.zero_bytes
Section titled “algopy.zero_bytes”algopy.zero_bytes(typ: type[algopy.zero_bytes.T]) → algopy.zero_bytes.T
Initializes a new value of the specified type, based on it’s zero bytes representation.
Only works for fixed size types that are bytes encoded.