Skip to content

algopy

Classes

ARC4ContractThe base class for a contract that conforms to the ARC4 ABI specification. Most contracts
should inherit from this class or a superclass thereof.
AccountAn Account on the Algorand network.
ApplicationAn Application on the Algorand network.
AssetAn Asset on the Algorand network.
BigUIntA variable length (max 512-bit) unsigned integer
BoxBox 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.
BoxMapBoxMap 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.
BoxRefBoxRef 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.
BytesA byte sequence, with a maximum length of 4096 bytes, one of the primary data types on the AVM
BytesBackedRepresents a type that is a single bytes value
CompiledContractProvides compiled programs and state allocation values for a Contract.
Create by calling compile_contract.
CompiledLogicSigProvides account for a Logic Signature.
Create by calling compile_logicsig.
ContractBase class for an Algorand Smart Contract
GlobalGet Global values
Native TEAL op: global
GlobalStateGlobal state associated with the application, the key will be the name of the member, this
is assigned to
LocalStateLocal state associated with the application and an account
LogicSigA logic signature
OnCompleteActionOn Completion actions available in an application call transaction
OpUpFeeSourceDefines the source of fees for the OpUp utility.
StateTotalsOptions class to manually define the total amount of global and local state contract will use,
used by Contract.__init_subclass__.
StringA UTF-8 encoded string.
TransactionTypeThe different transaction types available in a transaction
TxnGet values for the current executing transaction
Native TEAL ops: txn, txnas
UInt64A 64-bit unsigned integer, one of the primary data types on the AVM
uenumerateYields pairs containing a count (from zero) and a value yielded by the iterable argument.
urangeProduces a sequence of UInt64 from start (inclusive) to stop (exclusive) by step.

Functions

compile_contractReturns the compiled data for the specified contract
compile_logicsigReturns the Account for the specified logic signature
ensure_budgetEnsure the available op code budget is greater than or equal to required_budget
logConcatenates and logs supplied args as a single bytes value.
logicsigDecorator to indicate a function is a logic signature
subroutineDecorator to indicate functions or methods that can be called by a Smart Contract

Data

TemplateVarTemplate variables can be used to represent a placeholder for a deploy-time provided value.

API

class algopy.ARC4Contract

ARC4Contract

The base class for a contract that conforms to the ARC4 ABI specification. Most contracts should inherit from this class or a superclass thereof.

class HelloWorldContract(ARC4Contract):
# ...

Functions decorated with algopy.arc4.abimethod() or algopy.arc4.baremethod() will form the public interface of the contract.

The algopy.arc4.ARC4Contract.approval_program() will be implemented by the compiler, and route application args according to the ARC4 ABI specification.

The algopy.arc4.ARC4Contract.clear_state_program() will by default return True, but can be overridden

The Puya compiler will generate ARC32 and ARC56 application specifications for the contract automatically.

classmethod __init_subclass__

init_subclass(*, 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"):
...

:param 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, name will also be used as the contract name in the ARC-32 application.json, instead of the class name.

:param 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_uint64 which 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.

:param 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 Contract it 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_totals must be specified. Note that it is valid to not provide any arguments to the StateTotals constructor, like so state_totals=StateTotals(), in which case all values will be automatically calculated. :param 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

approval_program() → bool

The approval program for the ARC4Contract is implemented by the compile in accordance with ARC4

clear_state_program

clear_state_program() → algopy.UInt64 | bool

The clear_state_program contains the logic when the OnCompletion is ClearState.

The default implementation simply returns True, but this can be overridden.

ClearState transactions always clear local state of the sender. Documentation on ClearState behavior should be read before implementing this method: https://developer.algorand.org/docs/get-details/dapps/smart-contracts/frontend/apps/#clear-state

class algopy.Account

Account(value: str | algopy.Bytes = …, /)

An Account on the Algorand network.

Note: must be an available resource to access properties other than bytes

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__

bool() → bool

Returns True if not equal to the zero-address

__eq__

eq(other: algopy.Account | str) → bool

Account equality is determined by the address of another Account or str

__ne__

ne(other: algopy.Account | str) → bool

Account equality is determined by the address of another Account or str

property auth_address

auth_address : algopy.Account

Address the account is rekeyed to

property balance

balance : algopy.UInt64

Account balance in microalgos

property bytes

bytes : algopy.Bytes

Get the underlying Bytes

classmethod from_bytes

from_bytes(value: algopy.Bytes | bytes, /) → Self

Construct an instance from the underlying bytes (no validation)

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.

property min_balance

min_balance : algopy.UInt64

Minimum required balance for account, in microalgos

property total_apps_created

total_apps_created : algopy.UInt64

The number of existing apps created by this account.

property total_apps_opted_in

total_apps_opted_in : algopy.UInt64

The number of apps this account is opted into.

property total_assets

total_assets : algopy.UInt64

The numbers of ASAs held by this account (including ASAs this account created).

property total_assets_created

total_assets_created : algopy.UInt64

The number of existing ASAs created by this account.

property total_box_bytes

total_box_bytes : algopy.UInt64

The total number of bytes used by this account’s app’s box keys and values.

property total_boxes

total_boxes : algopy.UInt64

The number of existing boxes created by this account’s app.

property total_extra_app_pages

total_extra_app_pages : algopy.UInt64

The number of extra app code pages used by this account.

property total_num_byte_slice

total_num_byte_slice : algopy.UInt64

The total number of byte array values allocated by this account in Global and Local States.

property total_num_uint

total_num_uint : algopy.UInt64

The total number of uint64 values allocated by this account in Global and Local States.

class algopy.Application

Application(application_id: algopy.UInt64 | int = 0, /)

An Application on the Algorand network.

Initialization

Initialized with the id of an application. Defaults to zero (an invalid ID).

__bool__

bool() → bool

Returns True if application_id is not 0

__eq__

eq(other: algopy.Application) → bool

Application equality is determined by the equality of an Application’s id

__ne__

ne(other: algopy.Application) → bool

Application equality is determined by the equality of an Application’s id

property address

address : algopy.Account

Address for which this application has authority

property approval_program

approval_program : algopy.Bytes

Bytecode of Approval Program

property clear_state_program

clear_state_program : algopy.Bytes

Bytecode of Clear State Program

property creator

creator : algopy.Account

Creator address

property extra_program_pages

extra_program_pages : algopy.UInt64

Number of Extra Program Pages of code space

property global_num_bytes

global_num_bytes : algopy.UInt64

Number of byte array values allowed in Global State

property global_num_uint

global_num_uint : algopy.UInt64

Number of uint64 values allowed in Global State

property id

id : algopy.UInt64

Returns the id of the application

property local_num_bytes

local_num_bytes : algopy.UInt64

Number of byte array values allowed in Local State

property local_num_uint

local_num_uint : algopy.UInt64

Number of uint64 values allowed in Local State

class algopy.Asset

Asset(asset_id: algopy.UInt64 | int = 0, /)

An Asset on the Algorand network.

Initialization

Initialized with the id of an asset. Defaults to zero (an invalid ID).

__bool__

bool() → bool

Returns True if asset_id is not 0

__eq__

eq(other: algopy.Asset) → bool

Asset equality is determined by the equality of an Asset’s id

__ne__

ne(other: algopy.Asset) → bool

Asset equality is determined by the equality of an Asset’s id

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.

property clawback

clawback : algopy.Account

Clawback address

property creator

creator : algopy.Account

Creator address

property decimals

decimals : algopy.UInt64

See AssetParams.Decimals

property default_frozen

default_frozen : bool

Frozen by default or not

property freeze

freeze : algopy.Account

Freeze address

frozen

frozen(account: algopy.Account, /) → bool

Is the asset frozen or not. Fails if the account has not opted in to the asset.

property id

id : algopy.UInt64

Returns the id of the Asset

property manager

manager : algopy.Account

Manager address

property metadata_hash

metadata_hash : algopy.Bytes

Arbitrary commitment

property name

name : algopy.Bytes

Asset name

property reserve

reserve : algopy.Account

Reserve address

property total

total : algopy.UInt64

Total number of units of this asset

property unit_name

unit_name : algopy.Bytes

Asset unit name

property url

url : algopy.Bytes

URL with additional info about the asset

class algopy.BigUInt

BigUInt(value: algopy.UInt64 | int = 0, /)

A variable length (max 512-bit) unsigned integer

Initialization

A BigUInt can be initialized with a UInt64, a Python int literal, or an int variable declared at the module level

__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__

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__

bool() → bool

A BigUInt will evaluate to False if zero, and True otherwise

__eq__

eq(other: algopy.BigUInt | algopy.UInt64 | int) → bool

A BigUInt can use the == operator with another BigUInt, UInt64 or int

__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__

ge(other: algopy.BigUInt | algopy.UInt64 | int) → bool

A BigUInt can use the >= operator with another BigUInt, UInt64 or int

__gt__

gt(other: algopy.BigUInt | algopy.UInt64 | int) → bool

A BigUInt can use the > operator with another BigUInt, UInt64 or int

__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__

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__

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__

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__

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__

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__

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__

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__

le(other: algopy.BigUInt | algopy.UInt64 | int) → bool

A BigUInt can use the <= operator with another BigUInt, UInt64 or int

__lt__

lt(other: algopy.BigUInt | algopy.UInt64 | int) → bool

A BigUInt can use the < operator with another BigUInt, UInt64 or int

__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__

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__

ne(other: algopy.BigUInt | algopy.UInt64 | int) → bool

A BigUInt can use the != operator with another BigUInt, UInt64 or int

__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__

pos() → algopy.BigUInt

Supports unary + operator. Redundant given the type is unsigned

__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__

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__

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__

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__

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__

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__

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__

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__

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__

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

bytes : algopy.Bytes

Get the underlying Bytes

classmethod from_bytes

from_bytes(value: algopy.Bytes | bytes, /) → Self

Construct an instance from the underlying bytes (no validation)

class algopy.Box

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

__bool__

bool() → bool

Returns True if the box exists, regardless of the truthiness of the contents of the box

get

get(*, default: algopy._TValue) → algopy._TValue

Retrieve the contents of the box, or return the default value if the box has not been created.

:arg default: The default value to return if the box has not been created

property key

key : algopy.Bytes

Provides access to the raw storage key

property length

length : algopy.UInt64

Get the length of this Box. Fails if the box does not exist

maybe

maybe() → tuple[algopy._TValue, bool]

Retrieve the contents of the box if it exists, and return a boolean indicating if the box exists.

property value

value : algopy._TValue

Retrieve the contents of the box. Fails if the box has not been created.

class algopy.BoxMap

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

Declare a box map.

:arg key_type: The type of the keys :arg value_type: The type of the values :arg 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__

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__

delitem(key: algopy._TKey) → None

Deletes a keyed box

__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__

setitem(key: algopy._TKey, value: algopy._TValue) → None

Write value to a keyed box. Creates the box if it does not exist

get

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.

:arg key: The key of the box to get :arg default: The default value to return if the box has not been created.

property key_prefix

key_prefix : algopy.Bytes

Provides access to the raw storage key-prefix

length

length(key: algopy._TKey) → algopy.UInt64

Get the length of an item in this BoxMap. Fails if the box does not exist

:arg key: The key of the box to get

maybe

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.

:arg key: The key of the box to get

class algopy.BoxRef

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

__bool__

bool() → bool

Returns True if the box has a value set, regardless of the truthiness of that value

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

delete() → bool

Deletes the box if it exists and returns a value indicating if the box existed

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)

:arg start_index: The offset to start extracting bytes from :arg length: The number of bytes to extract

get

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.

:arg default: The default value to return if the box has not been created

property key

key : algopy.Bytes

Provides access to the raw storage key

property length

length : algopy.UInt64

Get the length of this Box. Fails if the box does not exist

maybe

maybe() → tuple[algopy.Bytes, bool]

Retrieve the contents of the box if it exists, and return a boolean indicating if the box exists.

put

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

:arg value: The value to write to the box

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)

:arg start_index: The offset to start writing bytes from :arg value: The bytes to be written

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.

:arg new_size: The new size of the box

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

:arg start_index: The index to start inserting value :arg length: The number of bytes after start_index to omit from the new value :arg value: The value to be inserted.

class algopy.Bytes

Bytes(value: bytes = b”, /)

A byte sequence, with a maximum length of 4096 bytes, one of the primary data types on the AVM

Initialization

Bytes can be initialized with a Python bytes literal, or bytes variable declared at the module level

__add__

add(other: algopy.Bytes | bytes) → algopy.Bytes

Concatenate Bytes with another Bytes or bytes literal e.g. Bytes(b"Hello ") + b"World".

__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__

bool() → bool

Returns True if length of bytes is >0

__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__

eq(other: algopy.Bytes | bytes) → bool

Bytes can be compared using the == operator with another Bytes or bytes

__getitem__

getitem(index: algopy.UInt64 | int | slice) → 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__

iadd(other: algopy.Bytes | bytes) → algopy.Bytes

Concatenate Bytes with another Bytes or bytes literal e.g. a += Bytes(b"World").

__iand__

iand(other: algopy.Bytes | bytes) → algopy.Bytes

Bytes can bitwise and with another Bytes or bytes e.g. a &= Bytes(b"0F")

__invert__

invert() → algopy.Bytes

Bytes can be bitwise inverted e.g. ~Bytes(b"FF)

__ior__

ior(other: algopy.Bytes | bytes) → algopy.Bytes

Bytes can bitwise or with another Bytes or bytes e.g. a |= Bytes(b"0F")

__iter__

iter() → collections.abc.Iterator[algopy.Bytes]

Bytes can be iterated, yielding each consecutive byte

__ixor__

ixor(other: algopy.Bytes | bytes) → algopy.Bytes

Bytes can bitwise xor with another Bytes or bytes e.g. a ^= Bytes(b"0F")

__ne__

ne(other: algopy.Bytes | bytes) → bool

Bytes can be compared using the != operator with another Bytes or bytes

__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__

radd(other: algopy.Bytes | bytes) → algopy.Bytes

Concatenate Bytes with another Bytes or bytes literal e.g. b"Hello " + Bytes(b"World").

__reversed__

reversed() → collections.abc.Iterator[algopy.Bytes]

Bytes can be iterated in reverse, yield each preceding byte starting at the end

__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

from_base32(value: str, /) → algopy.Bytes

Creates Bytes from a base32 encoded string e.g. Bytes.from_base32("74======")

static from_base64

from_base64(value: str, /) → algopy.Bytes

Creates Bytes from a base64 encoded string e.g. Bytes.from_base64("RkY=")

static from_hex

from_hex(value: str, /) → algopy.Bytes

Creates Bytes from a hex/octal encoded string e.g. Bytes.from_hex("FF")

property length

length : algopy.UInt64

Returns the length of the Bytes

class algopy.BytesBacked

BytesBacked

Represents a type that is a single bytes value

property bytes

bytes : algopy.Bytes

Get the underlying Bytes

classmethod from_bytes

from_bytes(value: algopy.Bytes | bytes, /) → Self

Construct an instance from the underlying bytes (no validation)

class algopy.CompiledContract

CompiledContract

Provides compiled programs and state allocation values for a Contract. Create by calling compile_contract.

approval_program

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

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

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

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

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

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

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

CompiledLogicSig

Provides account for a Logic Signature. Create by calling compile_logicsig.

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

Contract

Base class for an Algorand Smart Contract

classmethod __init_subclass__

init_subclass(*, 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"):
...

:param 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, name will also be used as the contract name in the ARC-32 application.json, instead of the class name.

:param 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_uint64 which 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.

:param 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 Contract it 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_totals must be specified. Note that it is valid to not provide any arguments to the StateTotals constructor, like so state_totals=StateTotals(), in which case all values will be automatically calculated. :param 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

approval_program() → algopy.UInt64 | bool

Represents the program called for all transactions where OnCompletion != ClearState

abstract clear_state_program

clear_state_program() → algopy.UInt64 | bool

Represents the program called when OnCompletion == ClearState

class algopy.Global

Global

Get Global values Native TEAL op: global

asset_create_min_balance

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

asset_opt_in_min_balance : Final[algopy.UInt64]

Ellipsis

The additional minimum balance required to opt-in to an asset.

caller_application_address

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

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

creator_address : Final[algopy.Account]

Ellipsis

Address of the creator of the current application. Application mode only.

current_application_address

current_application_address : Final[algopy.Account]

Ellipsis

Address that the current application controls. Application mode only.

current_application_id

current_application_id : Final[algopy.Application]

Ellipsis

ID of current application executing. Application mode only.

genesis_hash

genesis_hash : Final[algopy.Bytes]

Ellipsis

The Genesis Hash for the network.

group_id

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

group_size : Final[algopy.UInt64]

Ellipsis

Number of transactions in this atomic transaction group. At least 1

latest_timestamp

latest_timestamp : Final[algopy.UInt64]

Ellipsis

Last confirmed block UNIX timestamp. Fails if negative. Application mode only.

logic_sig_version

logic_sig_version : Final[algopy.UInt64]

Ellipsis

Maximum supported version

max_txn_life

max_txn_life : Final[algopy.UInt64]

Ellipsis

rounds

min_balance

min_balance : Final[algopy.UInt64]

Ellipsis

microalgos

min_txn_fee

min_txn_fee : Final[algopy.UInt64]

Ellipsis

microalgos

static opcode_budget

opcode_budget() → algopy.UInt64

The remaining cost that can be spent by opcodes in this program.

Native TEAL opcode: global

payouts_enabled

payouts_enabled : Final[bool]

Ellipsis

Whether block proposal payouts are enabled. Min AVM version: 11

payouts_go_online_fee

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

payouts_max_balance : Final[algopy.UInt64]

Ellipsis

The maximum algo balance an account can have in the agreement round to receive block payouts in the proposal round. Min AVM version: 11

payouts_min_balance

payouts_min_balance : Final[algopy.UInt64]

Ellipsis

The minimum algo balance an account must have in the agreement round to receive block payouts in the proposal round. Min AVM version: 11

payouts_percent

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

round : Final[algopy.UInt64]

Ellipsis

Current round number. Application mode only.

zero_address

zero_address : Final[algopy.Account]

Ellipsis

32 byte address of all zero bytes

class algopy.GlobalState

GlobalState

Global state associated with the application, the key will be the name of the member, this is assigned to

__bool__

bool() → bool

Returns True if the key has a value set, regardless of the truthiness of that value

get

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

key : algopy.Bytes

Provides access to the raw storage key

maybe

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

value : algopy._TState

Returns the value or and error if the value is not set

name = self.name.value

class algopy.LocalState

LocalState(type_: type[algopy._TState], /, *, key: algopy.String | algopy.Bytes | bytes | str = …, description: str = ”)

Local state associated with the application and an account

Initialization

Declare the local state key and it’s associated type

self.names = LocalState(algopy.Bytes)

__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__

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__

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__

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_name

get

get(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

key : algopy.Bytes

Provides access to the raw storage key

maybe

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

LogicSig

A logic signature

class algopy.OnCompleteAction

OnCompleteAction(value: int = 0, /)

On Completion actions available in an application call transaction

Initialization

A UInt64 can be initialized with a Python int literal, or an int variable declared at the module level

ClearState

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

CloseOut : algopy.OnCompleteAction

Ellipsis

CloseOut indicates that an application transaction will deallocate some LocalState for the application from the user’s account

DeleteApplication

DeleteApplication : algopy.OnCompleteAction

Ellipsis

DeleteApplication indicates that an application transaction will delete the AppParams for the application from the creator’s balance record

NoOp

NoOp : algopy.OnCompleteAction

Ellipsis

NoOP indicates that no additional action is performed when the transaction completes

OptIn

OptIn : algopy.OnCompleteAction

Ellipsis

OptIn indicates that an application transaction will allocate some LocalState for the application in the sender’s account

UpdateApplication

UpdateApplication : algopy.OnCompleteAction

Ellipsis

UpdateApplication indicates that an application transaction will update the ApprovalProgram and ClearStateProgram for the application

__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__

and(other: algopy.UInt64 | int) → algopy.UInt64

A UInt64 can bitwise and with another UInt64 or int e.g. UInt64(4) & 2

__bool__

bool() → bool

A UInt64 will evaluate to False if zero, and True otherwise

__eq__

eq(other: algopy.UInt64 | int) → bool

A UInt64 can use the == operator with another UInt64 or int

__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__

ge(other: algopy.UInt64 | int) → bool

A UInt64 can use the >= operator with another UInt64 or int

__gt__

gt(other: algopy.UInt64 | int) → bool

A UInt64 can use the > operator with another UInt64 or int

__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__

iand(other: algopy.UInt64 | int) → algopy.UInt64

A UInt64 can bitwise and with another UInt64 or int e.g. a &= UInt64(2)

__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__

ilshift(other: algopy.UInt64 | int) → algopy.UInt64

A UInt64 can be left shifted by another UInt64 or int e.g. a <<= UInt64(2)

__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__

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__

index() → int

A UInt64 can be used in indexing/slice expressions

__invert__

invert() → algopy.UInt64

A UInt64 can be bitwise inverted e.g. ~UInt64(4)

__ior__

ior(other: algopy.UInt64 | int) → algopy.UInt64

A UInt64 can bitwise or with another UInt64 or int e.g. a |= UInt64(2)

__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__

irshift(other: algopy.UInt64 | int) → algopy.UInt64

A UInt64 can be right shifted by another UInt64 or int e.g. a >>= UInt64(2)

__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__

ixor(other: algopy.UInt64 | int) → algopy.UInt64

A UInt64 can bitwise xor with another UInt64 or int e.g. a ^= UInt64(2)

__le__

le(other: algopy.UInt64 | int) → bool

A UInt64 can use the <= operator with another UInt64 or int

__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__

lt(other: algopy.UInt64 | int) → bool

A UInt64 can use the < operator with another UInt64 or int

__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__

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__

ne(other: algopy.UInt64 | int) → bool

A UInt64 can use the != operator with another UInt64 or int

__or__

or(other: algopy.UInt64 | int) → algopy.UInt64

A UInt64 can bitwise or with another UInt64 or int e.g. UInt64(4) | 2

__pos__

pos() → algopy.UInt64

Supports unary + operator. Redundant given the type is unsigned

__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__

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__

rand(other: algopy.UInt64 | int) → algopy.UInt64

A UInt64 can bitwise and with another UInt64 or int e.g. 4 & UInt64(2)

__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__

rlshift(other: algopy.UInt64 | int) → algopy.UInt64

A UInt64 can be left shifted by another UInt64 or int e.g. 4 << UInt64(2)

__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__

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__

ror(other: algopy.UInt64 | int) → algopy.UInt64

A UInt64 can bitwise or with another UInt64 or int e.g. 4 | UInt64(2)

__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__

rrshift(other: algopy.UInt64 | int) → algopy.UInt64

A UInt64 can be right shifted by another UInt64 or int e.g. 4 >> UInt64(2)

__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__

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__

rxor(other: algopy.UInt64 | int) → algopy.UInt64

A UInt64 can bitwise xor with another UInt64 or int e.g. 4 ^ UInt64(2)

__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__

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

OpUpFeeSource(value: int = 0, /)

Defines the source of fees for the OpUp utility.

Initialization

A UInt64 can be initialized with a Python int literal, or an int variable declared at the module level

Any

Any : algopy.OpUpFeeSource

Ellipsis

First the excess will be used, remaining fees will be taken from the app account

AppAccount

AppAccount : algopy.OpUpFeeSource

Ellipsis

The app’s account will cover all fees (set inner_tx.fee=Global.min_tx_fee())

GroupCredit

GroupCredit : algopy.OpUpFeeSource

Ellipsis

Only the excess fee (credit) on the outer group should be used (set inner_tx.fee=0)

__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__

and(other: algopy.UInt64 | int) → algopy.UInt64

A UInt64 can bitwise and with another UInt64 or int e.g. UInt64(4) & 2

__bool__

bool() → bool

A UInt64 will evaluate to False if zero, and True otherwise

__eq__

eq(other: algopy.UInt64 | int) → bool

A UInt64 can use the == operator with another UInt64 or int

__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__

ge(other: algopy.UInt64 | int) → bool

A UInt64 can use the >= operator with another UInt64 or int

__gt__

gt(other: algopy.UInt64 | int) → bool

A UInt64 can use the > operator with another UInt64 or int

__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__

iand(other: algopy.UInt64 | int) → algopy.UInt64

A UInt64 can bitwise and with another UInt64 or int e.g. a &= UInt64(2)

__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__

ilshift(other: algopy.UInt64 | int) → algopy.UInt64

A UInt64 can be left shifted by another UInt64 or int e.g. a <<= UInt64(2)

__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__

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__

index() → int

A UInt64 can be used in indexing/slice expressions

__invert__

invert() → algopy.UInt64

A UInt64 can be bitwise inverted e.g. ~UInt64(4)

__ior__

ior(other: algopy.UInt64 | int) → algopy.UInt64

A UInt64 can bitwise or with another UInt64 or int e.g. a |= UInt64(2)

__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__

irshift(other: algopy.UInt64 | int) → algopy.UInt64

A UInt64 can be right shifted by another UInt64 or int e.g. a >>= UInt64(2)

__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__

ixor(other: algopy.UInt64 | int) → algopy.UInt64

A UInt64 can bitwise xor with another UInt64 or int e.g. a ^= UInt64(2)

__le__

le(other: algopy.UInt64 | int) → bool

A UInt64 can use the <= operator with another UInt64 or int

__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__

lt(other: algopy.UInt64 | int) → bool

A UInt64 can use the < operator with another UInt64 or int

__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__

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__

ne(other: algopy.UInt64 | int) → bool

A UInt64 can use the != operator with another UInt64 or int

__or__

or(other: algopy.UInt64 | int) → algopy.UInt64

A UInt64 can bitwise or with another UInt64 or int e.g. UInt64(4) | 2

__pos__

pos() → algopy.UInt64

Supports unary + operator. Redundant given the type is unsigned

__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__

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__

rand(other: algopy.UInt64 | int) → algopy.UInt64

A UInt64 can bitwise and with another UInt64 or int e.g. 4 & UInt64(2)

__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__

rlshift(other: algopy.UInt64 | int) → algopy.UInt64

A UInt64 can be left shifted by another UInt64 or int e.g. 4 << UInt64(2)

__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__

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__

ror(other: algopy.UInt64 | int) → algopy.UInt64

A UInt64 can bitwise or with another UInt64 or int e.g. 4 | UInt64(2)

__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__

rrshift(other: algopy.UInt64 | int) → algopy.UInt64

A UInt64 can be right shifted by another UInt64 or int e.g. 4 >> UInt64(2)

__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__

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__

rxor(other: algopy.UInt64 | int) → algopy.UInt64

A UInt64 can bitwise xor with another UInt64 or int e.g. 4 ^ UInt64(2)

__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__

xor(other: algopy.UInt64 | int) → algopy.UInt64

A UInt64 can bitwise xor with another UInt64 or int e.g. UInt64(4) ^ 2

class algopy.StateTotals

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

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

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

A String can be initialized with a Python str literal, or a str variable declared at the module level

__add__

add(other: algopy.String | str) → algopy.String

Concatenate String with another String or str literal e.g. String("Hello ") + "World".

__bool__

bool() → bool

Returns True if the string is not empty

__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__

eq(other: algopy.String | str) → bool

Supports using the == operator with another String or literal str

__iadd__

iadd(other: algopy.String | str) → algopy.String

Concatenate String with another String or str literal e.g. a = String("Hello"); a += "World".

__ne__

ne(other: algopy.String | str) → bool

Supports using the != operator with another String or literal str

__radd__

radd(other: algopy.String | str) → algopy.String

Concatenate String with another String or str literal e.g. "Hello " + String("World").

property bytes

bytes : algopy.Bytes

Get the underlying Bytes

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

from_bytes(value: algopy.Bytes | bytes, /) → Self

Construct an instance from the underlying bytes (no validation)

join

join(others: tuple[algopy.String | str, …], /) → algopy.String

Join a sequence of Strings with a common separator.

The behaviour should mirror str.join.

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.

algopy.TemplateVar

TemplateVar : algopy._TemplateVarGeneric

Ellipsis

Template variables can be used to represent a placeholder for a deploy-time provided value.

class algopy.TransactionType

TransactionType(value: int = 0, /)

The different transaction types available in a transaction

Initialization

A UInt64 can be initialized with a Python int literal, or an int variable declared at the module level

ApplicationCall

ApplicationCall : algopy.TransactionType

Ellipsis

An Application Call transaction

AssetConfig

AssetConfig : algopy.TransactionType

Ellipsis

An Asset Config transaction

AssetFreeze

AssetFreeze : algopy.TransactionType

Ellipsis

An Asset Freeze transaction

AssetTransfer

AssetTransfer : algopy.TransactionType

Ellipsis

An Asset Transfer transaction

KeyRegistration

KeyRegistration : algopy.TransactionType

Ellipsis

A Key Registration transaction

Payment

Payment : algopy.TransactionType

Ellipsis

A Payment transaction

__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__

and(other: algopy.UInt64 | int) → algopy.UInt64

A UInt64 can bitwise and with another UInt64 or int e.g. UInt64(4) & 2

__bool__

bool() → bool

A UInt64 will evaluate to False if zero, and True otherwise

__eq__

eq(other: algopy.UInt64 | int) → bool

A UInt64 can use the == operator with another UInt64 or int

__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__

ge(other: algopy.UInt64 | int) → bool

A UInt64 can use the >= operator with another UInt64 or int

__gt__

gt(other: algopy.UInt64 | int) → bool

A UInt64 can use the > operator with another UInt64 or int

__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__

iand(other: algopy.UInt64 | int) → algopy.UInt64

A UInt64 can bitwise and with another UInt64 or int e.g. a &= UInt64(2)

__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__

ilshift(other: algopy.UInt64 | int) → algopy.UInt64

A UInt64 can be left shifted by another UInt64 or int e.g. a <<= UInt64(2)

__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__

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__

index() → int

A UInt64 can be used in indexing/slice expressions

__invert__

invert() → algopy.UInt64

A UInt64 can be bitwise inverted e.g. ~UInt64(4)

__ior__

ior(other: algopy.UInt64 | int) → algopy.UInt64

A UInt64 can bitwise or with another UInt64 or int e.g. a |= UInt64(2)

__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__

irshift(other: algopy.UInt64 | int) → algopy.UInt64

A UInt64 can be right shifted by another UInt64 or int e.g. a >>= UInt64(2)

__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__

ixor(other: algopy.UInt64 | int) → algopy.UInt64

A UInt64 can bitwise xor with another UInt64 or int e.g. a ^= UInt64(2)

__le__

le(other: algopy.UInt64 | int) → bool

A UInt64 can use the <= operator with another UInt64 or int

__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__

lt(other: algopy.UInt64 | int) → bool

A UInt64 can use the < operator with another UInt64 or int

__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__

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__

ne(other: algopy.UInt64 | int) → bool

A UInt64 can use the != operator with another UInt64 or int

__or__

or(other: algopy.UInt64 | int) → algopy.UInt64

A UInt64 can bitwise or with another UInt64 or int e.g. UInt64(4) | 2

__pos__

pos() → algopy.UInt64

Supports unary + operator. Redundant given the type is unsigned

__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__

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__

rand(other: algopy.UInt64 | int) → algopy.UInt64

A UInt64 can bitwise and with another UInt64 or int e.g. 4 & UInt64(2)

__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__

rlshift(other: algopy.UInt64 | int) → algopy.UInt64

A UInt64 can be left shifted by another UInt64 or int e.g. 4 << UInt64(2)

__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__

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__

ror(other: algopy.UInt64 | int) → algopy.UInt64

A UInt64 can bitwise or with another UInt64 or int e.g. 4 | UInt64(2)

__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__

rrshift(other: algopy.UInt64 | int) → algopy.UInt64

A UInt64 can be right shifted by another UInt64 or int e.g. 4 >> UInt64(2)

__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__

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__

rxor(other: algopy.UInt64 | int) → algopy.UInt64

A UInt64 can bitwise xor with another UInt64 or int e.g. 4 ^ UInt64(2)

__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__

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

Txn

Get values for the current executing transaction Native TEAL ops: txn, txnas

static accounts

accounts(a: algopy.UInt64 | int, /) → algopy.Account

Accounts listed in the ApplicationCall transaction

Native TEAL opcode: txna, txnas

amount

amount : Final[algopy.UInt64]

Ellipsis

microalgos

static application_args

application_args(a: algopy.UInt64 | int, /) → algopy.Bytes

Arguments passed to the application in the ApplicationCall transaction

Native TEAL opcode: txna, txnas

application_id

application_id : Final[algopy.Application]

Ellipsis

ApplicationID from ApplicationCall transaction

static applications

applications(a: algopy.UInt64 | int, /) → algopy.Application

Foreign Apps listed in the ApplicationCall transaction

Native TEAL opcode: txna, txnas

approval_program

approval_program : Final[algopy.Bytes]

Ellipsis

Approval program

static approval_program_pages

approval_program_pages(a: algopy.UInt64 | int, /) → algopy.Bytes

Approval Program as an array of pages

Native TEAL opcode: txna, txnas

asset_amount

asset_amount : Final[algopy.UInt64]

Ellipsis

value in Asset’s units

asset_close_to

asset_close_to : Final[algopy.Account]

Ellipsis

32 byte address

asset_receiver

asset_receiver : Final[algopy.Account]

Ellipsis

32 byte address

asset_sender

asset_sender : Final[algopy.Account]

Ellipsis

32 byte address. Source of assets if Sender is the Asset’s Clawback address.

static assets

assets(a: algopy.UInt64 | int, /) → algopy.Asset

Foreign Assets listed in the ApplicationCall transaction

Native TEAL opcode: txna, txnas

clear_state_program

clear_state_program : Final[algopy.Bytes]

Ellipsis

Clear state program

static clear_state_program_pages

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

close_remainder_to : Final[algopy.Account]

Ellipsis

32 byte address

config_asset

config_asset : Final[algopy.Asset]

Ellipsis

Asset ID in asset config transaction

config_asset_clawback

config_asset_clawback : Final[algopy.Account]

Ellipsis

32 byte address

config_asset_decimals

config_asset_decimals : Final[algopy.UInt64]

Ellipsis

Number of digits to display after the decimal place when displaying the asset

config_asset_default_frozen

config_asset_default_frozen : Final[bool]

Ellipsis

Whether the asset’s slots are frozen by default or not, 0 or 1

config_asset_freeze

config_asset_freeze : Final[algopy.Account]

Ellipsis

32 byte address

config_asset_manager

config_asset_manager : Final[algopy.Account]

Ellipsis

32 byte address

config_asset_metadata_hash

config_asset_metadata_hash : Final[algopy.Bytes]

Ellipsis

32 byte commitment to unspecified asset metadata

config_asset_name

config_asset_name : Final[algopy.Bytes]

Ellipsis

The asset name

config_asset_reserve

config_asset_reserve : Final[algopy.Account]

Ellipsis

32 byte address

config_asset_total

config_asset_total : Final[algopy.UInt64]

Ellipsis

Total number of units of this asset created

config_asset_unit_name

config_asset_unit_name : Final[algopy.Bytes]

Ellipsis

Unit name of the asset

config_asset_url

config_asset_url : Final[algopy.Bytes]

Ellipsis

URL

created_application_id

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

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

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

fee : Final[algopy.UInt64]

Ellipsis

microalgos

first_valid

first_valid : Final[algopy.UInt64]

Ellipsis

round number

first_valid_time

first_valid_time : Final[algopy.UInt64]

Ellipsis

UNIX timestamp of block before txn.FirstValid. Fails if negative

freeze_asset

freeze_asset : Final[algopy.Asset]

Ellipsis

Asset ID being frozen or un-frozen

freeze_asset_account

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

freeze_asset_frozen : Final[bool]

Ellipsis

The new frozen value, 0 or 1

global_num_byte_slice

global_num_byte_slice : Final[algopy.UInt64]

Ellipsis

Number of global state byteslices in ApplicationCall

global_num_uint

global_num_uint : Final[algopy.UInt64]

Ellipsis

Number of global state integers in ApplicationCall

group_index

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

last_log : Final[algopy.Bytes]

Ellipsis

The last message emitted. Empty bytes if none were emitted. Application mode only

last_valid

last_valid : Final[algopy.UInt64]

Ellipsis

round number

lease

lease : Final[algopy.Bytes]

Ellipsis

32 byte lease value

local_num_byte_slice

local_num_byte_slice : Final[algopy.UInt64]

Ellipsis

Number of local state byteslices in ApplicationCall

local_num_uint

local_num_uint : Final[algopy.UInt64]

Ellipsis

Number of local state integers in ApplicationCall

static logs

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

nonparticipation : Final[bool]

Ellipsis

Marks an account nonparticipating for rewards

note

note : Final[algopy.Bytes]

Ellipsis

Any data up to 1024 bytes

num_accounts

num_accounts : Final[algopy.UInt64]

Ellipsis

Number of Accounts

num_app_args

num_app_args : Final[algopy.UInt64]

Ellipsis

Number of ApplicationArgs

num_applications

num_applications : Final[algopy.UInt64]

Ellipsis

Number of Applications

num_approval_program_pages

num_approval_program_pages : Final[algopy.UInt64]

Ellipsis

Number of Approval Program pages

num_assets

num_assets : Final[algopy.UInt64]

Ellipsis

Number of Assets

num_clear_state_program_pages

num_clear_state_program_pages : Final[algopy.UInt64]

Ellipsis

Number of ClearState Program pages

num_logs

num_logs : Final[algopy.UInt64]

Ellipsis

Number of Logs (only with itxn in v5). Application mode only

on_completion

on_completion : Final[algopy.OnCompleteAction]

Ellipsis

ApplicationCall transaction on completion action

receiver

receiver : Final[algopy.Account]

Ellipsis

32 byte address

rekey_to

rekey_to : Final[algopy.Account]

Ellipsis

32 byte Sender’s new AuthAddr

selection_pk

selection_pk : Final[algopy.Bytes]

Ellipsis

32 byte address

sender

sender : Final[algopy.Account]

Ellipsis

32 byte address

state_proof_pk

state_proof_pk : Final[algopy.Bytes]

Ellipsis

64 byte state proof public key

tx_id

tx_id : Final[algopy.Bytes]

Ellipsis

The computed ID for this transaction. 32 bytes.

type

type : Final[algopy.Bytes]

Ellipsis

Transaction type as bytes

type_enum

type_enum : Final[algopy.TransactionType]

Ellipsis

Transaction type as integer

vote_first

vote_first : Final[algopy.UInt64]

Ellipsis

The first round that the participation key is valid.

vote_key_dilution

vote_key_dilution : Final[algopy.UInt64]

Ellipsis

Dilution for the 2-level participation key

vote_last

vote_last : Final[algopy.UInt64]

Ellipsis

The last round that the participation key is valid.

vote_pk

vote_pk : Final[algopy.Bytes]

Ellipsis

32 byte address

xfer_asset

xfer_asset : Final[algopy.Asset]

Ellipsis

Asset ID

class algopy.UInt64

UInt64(value: int = 0, /)

A 64-bit unsigned integer, one of the primary data types on the AVM

Initialization

A UInt64 can be initialized with a Python int literal, or an int variable declared at the module level

__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__

and(other: algopy.UInt64 | int) → algopy.UInt64

A UInt64 can bitwise and with another UInt64 or int e.g. UInt64(4) & 2

__bool__

bool() → bool

A UInt64 will evaluate to False if zero, and True otherwise

__eq__

eq(other: algopy.UInt64 | int) → bool

A UInt64 can use the == operator with another UInt64 or int

__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__

ge(other: algopy.UInt64 | int) → bool

A UInt64 can use the >= operator with another UInt64 or int

__gt__

gt(other: algopy.UInt64 | int) → bool

A UInt64 can use the > operator with another UInt64 or int

__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__

iand(other: algopy.UInt64 | int) → algopy.UInt64

A UInt64 can bitwise and with another UInt64 or int e.g. a &= UInt64(2)

__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__

ilshift(other: algopy.UInt64 | int) → algopy.UInt64

A UInt64 can be left shifted by another UInt64 or int e.g. a <<= UInt64(2)

__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__

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__

index() → int

A UInt64 can be used in indexing/slice expressions

__invert__

invert() → algopy.UInt64

A UInt64 can be bitwise inverted e.g. ~UInt64(4)

__ior__

ior(other: algopy.UInt64 | int) → algopy.UInt64

A UInt64 can bitwise or with another UInt64 or int e.g. a |= UInt64(2)

__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__

irshift(other: algopy.UInt64 | int) → algopy.UInt64

A UInt64 can be right shifted by another UInt64 or int e.g. a >>= UInt64(2)

__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__

ixor(other: algopy.UInt64 | int) → algopy.UInt64

A UInt64 can bitwise xor with another UInt64 or int e.g. a ^= UInt64(2)

__le__

le(other: algopy.UInt64 | int) → bool

A UInt64 can use the <= operator with another UInt64 or int

__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__

lt(other: algopy.UInt64 | int) → bool

A UInt64 can use the < operator with another UInt64 or int

__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__

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__

ne(other: algopy.UInt64 | int) → bool

A UInt64 can use the != operator with another UInt64 or int

__or__

or(other: algopy.UInt64 | int) → algopy.UInt64

A UInt64 can bitwise or with another UInt64 or int e.g. UInt64(4) | 2

__pos__

pos() → algopy.UInt64

Supports unary + operator. Redundant given the type is unsigned

__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__

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__

rand(other: algopy.UInt64 | int) → algopy.UInt64

A UInt64 can bitwise and with another UInt64 or int e.g. 4 & UInt64(2)

__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__

rlshift(other: algopy.UInt64 | int) → algopy.UInt64

A UInt64 can be left shifted by another UInt64 or int e.g. 4 << UInt64(2)

__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__

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__

ror(other: algopy.UInt64 | int) → algopy.UInt64

A UInt64 can bitwise or with another UInt64 or int e.g. 4 | UInt64(2)

__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__

rrshift(other: algopy.UInt64 | int) → algopy.UInt64

A UInt64 can be right shifted by another UInt64 or int e.g. 4 >> UInt64(2)

__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__

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__

rxor(other: algopy.UInt64 | int) → algopy.UInt64

A UInt64 can bitwise xor with another UInt64 or int e.g. 4 ^ UInt64(2)

__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__

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

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

:param contract: Algorand Python Contract to compile :param extra_program_pages: Number of extra program pages, defaults to minimum required for contract :param global_uints: Number of global uint64s, defaults to value defined for contract :param global_bytes: Number of global bytes, defaults to value defined for contract :param local_uints: Number of local uint64s, defaults to value defined for contract :param local_bytes: Number of local bytes, defaults to value defined for contract :param 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 :param 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

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

:param logicsig: Algorand Python Logic Signature to compile :param 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 :param 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

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

log(*args: algopy.UInt64 | algopy.Bytes | algopy.BytesBacked | str | bytes | int, 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

logicsig(*, name: str = …, avm_version: int = …) → collections.abc.Callable[[collections.abc.Callable[[], bool | algopy.UInt64]], algopy.LogicSig]

Decorator to indicate a function is a logic signature

algopy.subroutine

subroutine(sub: 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

class algopy.uenumerate

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

class algopy.urange

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