Answer:
Back to top
View this page
Toggle Light / Dark / Auto color theme
Toggle table of contents sidebar
algopy
¶
Package Contents
¶
Classes
¶
ARC4Contract
A contract that conforms to the ARC4 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.
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
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
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.
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.
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
¶
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
subroutine
Decorator to indicate functions or methods that can be called by a Smart Contract
Data
¶
TemplateVar
Template variables can be used to represent a placeholder for a deploy-time provided value.
API
¶
class
algopy.
ARC4Contract
¶
A contract that conforms to the ARC4 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 ARC4 ABI specification
The clear_state_program will by default return True, but can be overridden
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
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
¶
Returns
True
if not equal to the zero-address
__eq__
(
other
:
algopy.Account
|
str
)
→
bool
¶
Account equality is determined by the address of another
Account
or
str
__ne__
(
other
:
algopy.Account
|
str
)
→
bool
¶
Account equality is determined by the address of another
Account
or
str
property
auth_address
:
algopy.Account
¶
Address the account is rekeyed to
Note
Account must be an available resource
property
balance
:
algopy.UInt64
¶
Account balance in microalgos
Note
Account must be an available resource
property
bytes
:
algopy.Bytes
¶
Get the underlying Bytes
classmethod
from_bytes
(
value
:
algopy.Bytes
|
bytes
,
/
)
→
Self
¶
Construct an instance from the underlying bytes (no validation)
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.
Note
Account and Asset/Application must be an available resource
property
min_balance
:
algopy.UInt64
¶
Minimum required balance for account, in microalgos
Note
Account must be an available resource
property
total_apps_created
:
algopy.UInt64
¶
The number of existing apps created by this account.
Note
Account must be an available resource
property
total_apps_opted_in
:
algopy.UInt64
¶
The number of apps this account is opted into.
Note
Account must be an available resource
property
total_assets
:
algopy.UInt64
¶
The numbers of ASAs held by this account (including ASAs this account created).
Note
Account must be an available resource
property
total_assets_created
:
algopy.UInt64
¶
The number of existing ASAs created by this account.
Note
Account must be an available resource
property
total_box_bytes
:
algopy.UInt64
¶
The total number of bytes used by this account’s app’s box keys and values.
Note
Account must be an available resource
property
total_boxes
:
algopy.UInt64
¶
The number of existing boxes created by this account’s app.
Note
Account must be an available resource
property
total_extra_app_pages
:
algopy.UInt64
¶
The number of extra app code pages used by this account.
Note
Account must be an available resource
property
total_num_byte_slice
:
algopy.UInt64
¶
The total number of byte array values allocated by this account in Global and Local States.
Note
Account must be an available resource
property
total_num_uint
:
algopy.UInt64
¶
The total number of uint64 values allocated by this account in Global and Local States.
Note
Account must be an available resource
class
algopy.
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
¶
Returns
True
if
application_id
is not
0
__eq__
(
other
:
algopy.Application
)
→
bool
¶
Application equality is determined by the equality of an Application’s id
__ne__
(
other
:
algopy.Application
)
→
bool
¶
Application equality is determined by the equality of an Application’s id
property
address
:
algopy.Account
¶
Address for which this application has authority
Note
Application must be an available resource
property
approval_program
:
algopy.Bytes
¶
Bytecode of Approval Program
Note
Application must be an available resource
property
clear_state_program
:
algopy.Bytes
¶
Bytecode of Clear State Program
Note
Application must be an available resource
property
creator
:
algopy.Account
¶
Creator address
Note
Application must be an available resource
property
extra_program_pages
:
algopy.UInt64
¶
Number of Extra Program Pages of code space
Note
Application must be an available resource
property
global_num_bytes
:
algopy.UInt64
¶
Number of byte array values allowed in Global State
Note
Application must be an available resource
property
global_num_uint
:
algopy.UInt64
¶
Number of uint64 values allowed in Global State
Note
Application must be an available resource
property
id
:
algopy.UInt64
¶
Returns the id of the application
property
local_num_bytes
:
algopy.UInt64
¶
Number of byte array values allowed in Local State
Note
Application must be an available resource
property
local_num_uint
:
algopy.UInt64
¶
Number of uint64 values allowed in Local State
Note
Application must be an available resource
class
algopy.
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
¶
Returns
True
if
asset_id
is not
0
__eq__
(
other
:
algopy.Asset
)
→
bool
¶
Asset equality is determined by the equality of an Asset’s id
__ne__
(
other
:
algopy.Asset
)
→
bool
¶
Asset equality is determined by the equality of an Asset’s id
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.
Note
Asset and supplied Account must be an available resource
property
clawback
:
algopy.Account
¶
Clawback address
Note
Asset must be an available resource
property
creator
:
algopy.Account
¶
Creator address
Note
Asset must be an available resource
property
decimals
:
algopy.UInt64
¶
See AssetParams.Decimals
Note
Asset must be an available resource
property
default_frozen
:
bool
¶
Frozen by default or not
Note
Asset must be an available resource
property
freeze
:
algopy.Account
¶
Freeze address
Note
Asset must be an available resource
frozen
(
account
:
algopy.Account
,
/
)
→
bool
¶
Is the asset frozen or not. Fails if the account has not
opted in to the asset.
Note
Asset and supplied Account must be an available resource
property
id
:
algopy.UInt64
¶
Returns the id of the Asset
property
manager
:
algopy.Account
¶
Manager address
Note
Asset must be an available resource
property
metadata_hash
:
algopy.Bytes
¶
Arbitrary commitment
Note
Asset must be an available resource
property
name
:
algopy.Bytes
¶
Asset name
Note
Asset must be an available resource
property
reserve
:
algopy.Account
¶
Reserve address
Note
Asset must be an available resource
property
total
:
algopy.UInt64
¶
Total number of units of this asset
Note
Asset must be an available resource
property
unit_name
:
algopy.Bytes
¶
Asset unit name
Note
Asset must be an available resource
property
url
:
algopy.Bytes
¶
URL with additional info about the asset
Note
Asset must be an available resource
class
algopy.
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__
(
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__
(
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
¶
A BigUInt will evaluate to
False
if zero, and
True
otherwise
__eq__
(
other
:
algopy.BigUInt
|
algopy.UInt64
|
int
)
→
bool
¶
A BigUInt can use the
==
operator with another BigUInt, UInt64 or int
__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__
(
other
:
algopy.BigUInt
|
algopy.UInt64
|
int
)
→
bool
¶
A BigUInt can use the
>=
operator with another BigUInt, UInt64 or int
__gt__
(
other
:
algopy.BigUInt
|
algopy.UInt64
|
int
)
→
bool
¶
A BigUInt can use the
>
operator with another BigUInt, UInt64 or int
__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__
(
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__
(
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__
(
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__
(
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__
(
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__
(
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__
(
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__
(
other
:
algopy.BigUInt
|
algopy.UInt64
|
int
)
→
bool
¶
A BigUInt can use the
<=
operator with another BigUInt, UInt64 or int
__lt__
(
other
:
algopy.BigUInt
|
algopy.UInt64
|
int
)
→
bool
¶
A BigUInt can use the
<
operator with another BigUInt, UInt64 or int
__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__
(
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__
(
other
:
algopy.BigUInt
|
algopy.UInt64
|
int
)
→
bool
¶
A BigUInt can use the
!=
operator with another BigUInt, UInt64 or int
__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__
(
)
→
algopy.BigUInt
¶
Supports unary + operator. Redundant given the type is unsigned
__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__
(
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__
(
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__
(
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__
(
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__
(
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__
(
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__
(
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__
(
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__
(
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
¶
Get the underlying Bytes
classmethod
from_bytes
(
value
:
algopy.Bytes
|
bytes
,
/
)
→
Self
¶
Construct an instance from the underlying bytes (no validation)
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
__bool__
(
)
→
bool
¶
Returns True if the box exists, regardless of the truthiness of the contents
of the box
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
¶
Provides access to the raw storage key
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
value
:
algopy._TValue
¶
Retrieve the contents of the box. Fails if the box has not been created.
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
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__
(
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__
(
key
:
algopy._TKey
)
→
None
¶
Deletes a keyed box
__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__
(
key
:
algopy._TKey
,
value
:
algopy._TValue
)
→
None
¶
Write
value
to a keyed box. Creates the box if it does not exist
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
¶
Provides access to the raw storage key-prefix
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
(
/
,
*
,
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
¶
Returns True if the box has a value set, regardless of the truthiness of that value
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
(
)
→
bool
¶
Deletes the box if it exists and returns a value indicating if the box existed
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
¶
Provides access to the raw storage key
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
(
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
(
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
(
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_index
to omit from the new value
value
– The
value
to be inserted.
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
Bytes can be initialized with a Python bytes literal, or bytes variable
declared at the module level
__add__
(
other
:
algopy.Bytes
|
bytes
)
→
algopy.Bytes
¶
Concatenate Bytes with another Bytes or bytes literal
e.g.
Bytes(b"Hello
")
+
b"World"
.
__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
¶
Returns
True
if length of bytes is >0
__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__
(
other
:
algopy.Bytes
|
bytes
)
→
bool
¶
Bytes can be compared using the
==
operator with another Bytes or bytes
__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__
(
other
:
algopy.Bytes
|
bytes
)
→
algopy.Bytes
¶
Concatenate Bytes with another Bytes or bytes literal
e.g.
a
+=
Bytes(b"World")
.
__iand__
(
other
:
algopy.Bytes
|
bytes
)
→
algopy.Bytes
¶
Bytes can bitwise and with another Bytes or bytes e.g.
a
&=
Bytes(b"0F")
__invert__
(
)
→
algopy.Bytes
¶
Bytes can be bitwise inverted e.g.
~Bytes(b"FF)
__ior__
(
other
:
algopy.Bytes
|
bytes
)
→
algopy.Bytes
¶
Bytes can bitwise or with another Bytes or bytes e.g.
a
|=
Bytes(b"0F")
__iter__
(
)
→
collections.abc.Iterator
[
algopy.Bytes
]
¶
Bytes can be iterated, yielding each consecutive byte
__ixor__
(
other
:
algopy.Bytes
|
bytes
)
→
algopy.Bytes
¶
Bytes can bitwise xor with another Bytes or bytes e.g.
a
^=
Bytes(b"0F")
__ne__
(
other
:
algopy.Bytes
|
bytes
)
→
bool
¶
Bytes can be compared using the
!=
operator with another Bytes or bytes
__or__
(
other
:
algopy.Bytes
|
bytes
)
→
algopy.Bytes
¶
Bytes can bitwise or with another Bytes or bytes e.g.
Bytes(b"FF")
|
b"0F")
__radd__
(
other
:
algopy.Bytes
|
bytes
)
→
algopy.Bytes
¶
Concatenate Bytes with another Bytes or bytes literal
e.g.
b"Hello
"
+
Bytes(b"World")
.
__reversed__
(
)
→
collections.abc.Iterator
[
algopy.Bytes
]
¶
Bytes can be iterated in reverse, yield each preceding byte starting at the end
__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
(
value
:
str
,
/
)
→
algopy.Bytes
¶
Creates Bytes from a base32 encoded string e.g.
Bytes.from_base32("74======")
static
from_base64
(
value
:
str
,
/
)
→
algopy.Bytes
¶
Creates Bytes from a base64 encoded string e.g.
Bytes.from_base64("RkY=")
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
¶
Returns the length of the Bytes
class
algopy.
BytesBacked
¶
Represents a type that is a single bytes value
property
bytes
:
algopy.Bytes
¶
Get the underlying Bytes
classmethod
from_bytes
(
value
:
algopy.Bytes
|
bytes
,
/
)
→
Self
¶
Construct an instance from the underlying bytes (no validation)
class
algopy.
CompiledContract
¶
Provides compiled programs and state allocation values for a Contract.
Create by calling
compile_contract
.
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
[
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
¶
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
¶
None
By default, provides global num bytes based on contract state totals, can be overridden
when calling compile_contract
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
¶
None
By default, provides local num bytes based on contract state totals, can be overridden
when calling compile_contract
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
¶
Provides account for a Logic Signature.
Create by calling
compile_logicsig
.
account
:
algopy.Account
¶
None
Address of a logic sig program, after template variables have been replaced and compiled
to AVM bytecode
class
algopy.
Contract
¶
Base class for an Algorand Smart Contract
classmethod
__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"
):
...
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,
name
will 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_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.
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.
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
(
)
→
algopy.UInt64
|
bool
¶
Represents the program called for all transactions
where
OnCompletion
!=
ClearState
abstract
clear_state_program
(
)
→
algopy.UInt64
|
bool
¶
Represents the program called when
OnCompletion
==
ClearState
class
algopy.
Global
¶
Get Global values
Native TEAL op:
global
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
[
algopy.UInt64
]
¶
Ellipsis
The additional minimum balance required to opt-in to an asset.
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
[
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
[
algopy.Account
]
¶
Ellipsis
Address of the creator of the current application. Application mode only.
current_application_address
:
Final
[
algopy.Account
]
¶
Ellipsis
Address that the current application controls. Application mode only.
current_application_id
:
Final
[
algopy.Application
]
¶
Ellipsis
ID of current application executing. Application mode only.
genesis_hash
:
Final
[
algopy.Bytes
]
¶
Ellipsis
The Genesis Hash for the network.
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
[
algopy.UInt64
]
¶
Ellipsis
Number of transactions in this atomic transaction group. At least 1
latest_timestamp
:
Final
[
algopy.UInt64
]
¶
Ellipsis
Last confirmed block UNIX timestamp. Fails if negative. Application mode only.
logic_sig_version
:
Final
[
algopy.UInt64
]
¶
Ellipsis
Maximum supported version
max_txn_life
:
Final
[
algopy.UInt64
]
¶
Ellipsis
rounds
min_balance
:
Final
[
algopy.UInt64
]
¶
Ellipsis
microalgos
min_txn_fee
:
Final
[
algopy.UInt64
]
¶
Ellipsis
microalgos
static
opcode_budget
(
)
→
algopy.UInt64
¶
The remaining cost that can be spent by opcodes in this program.
Native TEAL opcode:
global
payouts_enabled
:
Final
[
bool
]
¶
Ellipsis
Whether block proposal payouts are enabled.
Min AVM version: 11
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
[
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
[
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
[
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
[
algopy.UInt64
]
¶
Ellipsis
Current round number. Application mode only.
zero_address
:
Final
[
algopy.Account
]
¶
Ellipsis
32 byte address of all zero bytes
class
algopy.
GlobalState
¶
Global state associated with the application, the key will be the name of the member, this
is assigned to
Note
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__
(
)
→
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
¶
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
¶
Returns the value or and error if the value is not set
name
=
self
.
name
.
value
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
Declare the local state key and it’s associated type
self
.
names
=
LocalState
(
algopy
.
Bytes
)
__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__
(
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__
(
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__
(
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
(
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
¶
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
¶
A logic signature
class
algopy.
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
:
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
¶
Ellipsis
CloseOut indicates that an application transaction will deallocate
some LocalState for the application from the user’s account
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
¶
Ellipsis
NoOP indicates that no additional action is performed when the transaction completes
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
¶
Ellipsis
UpdateApplication indicates that an application transaction will
update the ApprovalProgram and ClearStateProgram for the application
__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__
(
other
:
algopy.UInt64
|
int
)
→
algopy.UInt64
¶
A UInt64 can bitwise and with another UInt64 or int e.g.
UInt64(4)
&
2
__bool__
(
)
→
bool
¶
A UInt64 will evaluate to
False
if zero, and
True
otherwise
__eq__
(
other
:
algopy.UInt64
|
int
)
→
bool
¶
A UInt64 can use the
==
operator with another UInt64 or int
__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__
(
other
:
algopy.UInt64
|
int
)
→
bool
¶
A UInt64 can use the
>=
operator with another UInt64 or int
__gt__
(
other
:
algopy.UInt64
|
int
)
→
bool
¶
A UInt64 can use the
>
operator with another UInt64 or int
__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__
(
other
:
algopy.UInt64
|
int
)
→
algopy.UInt64
¶
A UInt64 can bitwise and with another UInt64 or int e.g.
a
&=
UInt64(2)
__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__
(
other
:
algopy.UInt64
|
int
)
→
algopy.UInt64
¶
A UInt64 can be left shifted by another UInt64 or int e.g.
a
<<=
UInt64(2)
__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__
(
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__
(
)
→
int
¶
A UInt64 can be used in indexing/slice expressions
__invert__
(
)
→
algopy.UInt64
¶
A UInt64 can be bitwise inverted e.g.
~UInt64(4)
__ior__
(
other
:
algopy.UInt64
|
int
)
→
algopy.UInt64
¶
A UInt64 can bitwise or with another UInt64 or int e.g.
a
|=
UInt64(2)
__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__
(
other
:
algopy.UInt64
|
int
)
→
algopy.UInt64
¶
A UInt64 can be right shifted by another UInt64 or int e.g.
a
>>=
UInt64(2)
__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__
(
other
:
algopy.UInt64
|
int
)
→
algopy.UInt64
¶
A UInt64 can bitwise xor with another UInt64 or int e.g.
a
^=
UInt64(2)
__le__
(
other
:
algopy.UInt64
|
int
)
→
bool
¶
A UInt64 can use the
<=
operator with another UInt64 or int
__lshift__
(
other
:
algopy.UInt64
|
int
)
→
algopy.UInt64
¶
A UInt64 can be left shifted by another UInt64 or int e.g.
UInt64(4)
<<
2
__lt__
(
other
:
algopy.UInt64
|
int
)
→
bool
¶
A UInt64 can use the
<
operator with another UInt64 or int
__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__
(
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__
(
other
:
algopy.UInt64
|
int
)
→
bool
¶
A UInt64 can use the
!=
operator with another UInt64 or int
__or__
(
other
:
algopy.UInt64
|
int
)
→
algopy.UInt64
¶
A UInt64 can bitwise or with another UInt64 or int e.g.
UInt64(4)
|
2
__pos__
(
)
→
algopy.UInt64
¶
Supports unary + operator. Redundant given the type is unsigned
__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__
(
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__
(
other
:
algopy.UInt64
|
int
)
→
algopy.UInt64
¶
A UInt64 can bitwise and with another UInt64 or int e.g.
4
&
UInt64(2)
__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__
(
other
:
algopy.UInt64
|
int
)
→
algopy.UInt64
¶
A UInt64 can be left shifted by another UInt64 or int e.g.
4
<<
UInt64(2)
__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__
(
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__
(
other
:
algopy.UInt64
|
int
)
→
algopy.UInt64
¶
A UInt64 can bitwise or with another UInt64 or int e.g.
4
|
UInt64(2)
__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__
(
other
:
algopy.UInt64
|
int
)
→
algopy.UInt64
¶
A UInt64 can be right shifted by another UInt64 or int e.g.
4
>>
UInt64(2)
__rshift__
(
other
:
algopy.UInt64
|
int
)
→
algopy.UInt64
¶
A UInt64 can be right shifted by another UInt64 or int e.g.
UInt64(4)
>>
2
__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__
(
other
:
algopy.UInt64
|
int
)
→
algopy.UInt64
¶
A UInt64 can bitwise xor with another UInt64 or int e.g.
4
^
UInt64(2)
__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__
(
other
:
algopy.UInt64
|
int
)
→
algopy.UInt64
¶
A UInt64 can bitwise xor with another UInt64 or int e.g.
UInt64(4)
^
2
class
algopy.
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
:
algopy.OpUpFeeSource
¶
Ellipsis
First the excess will be used, remaining fees will be taken from the app account
AppAccount
:
algopy.OpUpFeeSource
¶
Ellipsis
The app’s account will cover all fees (set inner_tx.fee=Global.min_tx_fee())
GroupCredit
:
algopy.OpUpFeeSource
¶
Ellipsis
Only the excess fee (credit) on the outer group should be used (set inner_tx.fee=0)
__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__
(
other
:
algopy.UInt64
|
int
)
→
algopy.UInt64
¶
A UInt64 can bitwise and with another UInt64 or int e.g.
UInt64(4)
&
2
__bool__
(
)
→
bool
¶
A UInt64 will evaluate to
False
if zero, and
True
otherwise
__eq__
(
other
:
algopy.UInt64
|
int
)
→
bool
¶
A UInt64 can use the
==
operator with another UInt64 or int
__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__
(
other
:
algopy.UInt64
|
int
)
→
bool
¶
A UInt64 can use the
>=
operator with another UInt64 or int
__gt__
(
other
:
algopy.UInt64
|
int
)
→
bool
¶
A UInt64 can use the
>
operator with another UInt64 or int
__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__
(
other
:
algopy.UInt64
|
int
)
→
algopy.UInt64
¶
A UInt64 can bitwise and with another UInt64 or int e.g.
a
&=
UInt64(2)
__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__
(
other
:
algopy.UInt64
|
int
)
→
algopy.UInt64
¶
A UInt64 can be left shifted by another UInt64 or int e.g.
a
<<=
UInt64(2)
__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__
(
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__
(
)
→
int
¶
A UInt64 can be used in indexing/slice expressions
__invert__
(
)
→
algopy.UInt64
¶
A UInt64 can be bitwise inverted e.g.
~UInt64(4)
__ior__
(
other
:
algopy.UInt64
|
int
)
→
algopy.UInt64
¶
A UInt64 can bitwise or with another UInt64 or int e.g.
a
|=
UInt64(2)
__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__
(
other
:
algopy.UInt64
|
int
)
→
algopy.UInt64
¶
A UInt64 can be right shifted by another UInt64 or int e.g.
a
>>=
UInt64(2)
__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__
(
other
:
algopy.UInt64
|
int
)
→
algopy.UInt64
¶
A UInt64 can bitwise xor with another UInt64 or int e.g.
a
^=
UInt64(2)
__le__
(
other
:
algopy.UInt64
|
int
)
→
bool
¶
A UInt64 can use the
<=
operator with another UInt64 or int
__lshift__
(
other
:
algopy.UInt64
|
int
)
→
algopy.UInt64
¶
A UInt64 can be left shifted by another UInt64 or int e.g.
UInt64(4)
<<
2
__lt__
(
other
:
algopy.UInt64
|
int
)
→
bool
¶
A UInt64 can use the
<
operator with another UInt64 or int
__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__
(
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__
(
other
:
algopy.UInt64
|
int
)
→
bool
¶
A UInt64 can use the
!=
operator with another UInt64 or int
__or__
(
other
:
algopy.UInt64
|
int
)
→
algopy.UInt64
¶
A UInt64 can bitwise or with another UInt64 or int e.g.
UInt64(4)
|
2
__pos__
(
)
→
algopy.UInt64
¶
Supports unary + operator. Redundant given the type is unsigned
__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__
(
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__
(
other
:
algopy.UInt64
|
int
)
→
algopy.UInt64
¶
A UInt64 can bitwise and with another UInt64 or int e.g.
4
&
UInt64(2)
__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__
(
other
:
algopy.UInt64
|
int
)
→
algopy.UInt64
¶
A UInt64 can be left shifted by another UInt64 or int e.g.
4
<<
UInt64(2)
__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__
(
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__
(
other
:
algopy.UInt64
|
int
)
→
algopy.UInt64
¶
A UInt64 can bitwise or with another UInt64 or int e.g.
4
|
UInt64(2)
__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__
(
other
:
algopy.UInt64
|
int
)
→
algopy.UInt64
¶
A UInt64 can be right shifted by another UInt64 or int e.g.
4
>>
UInt64(2)
__rshift__
(
other
:
algopy.UInt64
|
int
)
→
algopy.UInt64
¶
A UInt64 can be right shifted by another UInt64 or int e.g.
UInt64(4)
>>
2
__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__
(
other
:
algopy.UInt64
|
int
)
→
algopy.UInt64
¶
A UInt64 can bitwise xor with another UInt64 or int e.g.
4
^
UInt64(2)
__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__
(
other
:
algopy.UInt64
|
int
)
→
algopy.UInt64
¶
A UInt64 can bitwise xor with another UInt64 or int e.g.
UInt64(4)
^
2
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
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
(
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__
(
other
:
algopy.String
|
str
)
→
algopy.String
¶
Concatenate
String
with another
String
or
str
literal
e.g.
String("Hello
")
+
"World"
.
__bool__
(
)
→
bool
¶
Returns
True
if the string is not empty
__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__
(
other
:
algopy.String
|
str
)
→
bool
¶
Supports using the
==
operator with another
String
or literal
str
__iadd__
(
other
:
algopy.String
|
str
)
→
algopy.String
¶
Concatenate
String
with another
String
or
str
literal
e.g.
a
=
String("Hello");
a
+=
"World"
.
__ne__
(
other
:
algopy.String
|
str
)
→
bool
¶
Supports using the
!=
operator with another
String
or literal
str
__radd__
(
other
:
algopy.String
|
str
)
→
algopy.String
¶
Concatenate String with another
String
or
str
literal
e.g.
"Hello
"
+
String("World")
.
property
bytes
:
algopy.Bytes
¶
Get the underlying Bytes
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
(
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
(
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
:
algopy._TemplateVarGeneric
¶
Ellipsis
Template variables can be used to represent a placeholder for a deploy-time provided value.
class
algopy.
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
:
algopy.TransactionType
¶
Ellipsis
An Application Call transaction
AssetConfig
:
algopy.TransactionType
¶
Ellipsis
An Asset Config transaction
AssetFreeze
:
algopy.TransactionType
¶
Ellipsis
An Asset Freeze transaction
AssetTransfer
:
algopy.TransactionType
¶
Ellipsis
An Asset Transfer transaction
KeyRegistration
:
algopy.TransactionType
¶
Ellipsis
A Key Registration transaction
Payment
:
algopy.TransactionType
¶
Ellipsis
A Payment transaction
__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__
(
other
:
algopy.UInt64
|
int
)
→
algopy.UInt64
¶
A UInt64 can bitwise and with another UInt64 or int e.g.
UInt64(4)
&
2
__bool__
(
)
→
bool
¶
A UInt64 will evaluate to
False
if zero, and
True
otherwise
__eq__
(
other
:
algopy.UInt64
|
int
)
→
bool
¶
A UInt64 can use the
==
operator with another UInt64 or int
__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__
(
other
:
algopy.UInt64
|
int
)
→
bool
¶
A UInt64 can use the
>=
operator with another UInt64 or int
__gt__
(
other
:
algopy.UInt64
|
int
)
→
bool
¶
A UInt64 can use the
>
operator with another UInt64 or int
__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__
(
other
:
algopy.UInt64
|
int
)
→
algopy.UInt64
¶
A UInt64 can bitwise and with another UInt64 or int e.g.
a
&=
UInt64(2)
__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__
(
other
:
algopy.UInt64
|
int
)
→
algopy.UInt64
¶
A UInt64 can be left shifted by another UInt64 or int e.g.
a
<<=
UInt64(2)
__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__
(
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__
(
)
→
int
¶
A UInt64 can be used in indexing/slice expressions
__invert__
(
)
→
algopy.UInt64
¶
A UInt64 can be bitwise inverted e.g.
~UInt64(4)
__ior__
(
other
:
algopy.UInt64
|
int
)
→
algopy.UInt64
¶
A UInt64 can bitwise or with another UInt64 or int e.g.
a
|=
UInt64(2)
__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__
(
other
:
algopy.UInt64
|
int
)
→
algopy.UInt64
¶
A UInt64 can be right shifted by another UInt64 or int e.g.
a
>>=
UInt64(2)
__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__
(
other
:
algopy.UInt64
|
int
)
→
algopy.UInt64
¶
A UInt64 can bitwise xor with another UInt64 or int e.g.
a
^=
UInt64(2)
__le__
(
other
:
algopy.UInt64
|
int
)
→
bool
¶
A UInt64 can use the
<=
operator with another UInt64 or int
__lshift__
(
other
:
algopy.UInt64
|
int
)
→
algopy.UInt64
¶
A UInt64 can be left shifted by another UInt64 or int e.g.
UInt64(4)
<<
2
__lt__
(
other
:
algopy.UInt64
|
int
)
→
bool
¶
A UInt64 can use the
<
operator with another UInt64 or int
__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__
(
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__
(
other
:
algopy.UInt64
|
int
)
→
bool
¶
A UInt64 can use the
!=
operator with another UInt64 or int
__or__
(
other
:
algopy.UInt64
|
int
)
→
algopy.UInt64
¶
A UInt64 can bitwise or with another UInt64 or int e.g.
UInt64(4)
|
2
__pos__
(
)
→
algopy.UInt64
¶
Supports unary + operator. Redundant given the type is unsigned
__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__
(
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__
(
other
:
algopy.UInt64
|
int
)
→
algopy.UInt64
¶
A UInt64 can bitwise and with another UInt64 or int e.g.
4
&
UInt64(2)
__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__
(
other
:
algopy.UInt64
|
int
)
→
algopy.UInt64
¶
A UInt64 can be left shifted by another UInt64 or int e.g.
4
<<
UInt64(2)
__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__
(
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__
(
other
:
algopy.UInt64
|
int
)
→
algopy.UInt64
¶
A UInt64 can bitwise or with another UInt64 or int e.g.
4
|
UInt64(2)
__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__
(
other
:
algopy.UInt64
|
int
)
→
algopy.UInt64
¶
A UInt64 can be right shifted by another UInt64 or int e.g.
4
>>
UInt64(2)
__rshift__
(
other
:
algopy.UInt64
|
int
)
→
algopy.UInt64
¶
A UInt64 can be right shifted by another UInt64 or int e.g.
UInt64(4)
>>
2
__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__
(
other
:
algopy.UInt64
|
int
)
→
algopy.UInt64
¶
A UInt64 can bitwise xor with another UInt64 or int e.g.
4
^
UInt64(2)
__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__
(
other
:
algopy.UInt64
|
int
)
→
algopy.UInt64
¶
A UInt64 can bitwise xor with another UInt64 or int e.g.
UInt64(4)
^
2
class
algopy.
Txn
¶
Get values for the current executing transaction
Native TEAL ops:
txn
,
txnas
static
accounts
(
a
:
algopy.UInt64
|
int
,
/
)
→
algopy.Account
¶
Accounts listed in the ApplicationCall transaction
Native TEAL opcode:
txna
,
txnas
amount
:
Final
[
algopy.UInt64
]
¶
Ellipsis
microalgos
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
[
algopy.Application
]
¶
Ellipsis
ApplicationID from ApplicationCall transaction
static
applications
(
a
:
algopy.UInt64
|
int
,
/
)
→
algopy.Application
¶
Foreign Apps listed in the ApplicationCall transaction
Native TEAL opcode:
txna
,
txnas
approval_program
:
Final
[
algopy.Bytes
]
¶
Ellipsis
Approval program
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
[
algopy.UInt64
]
¶
Ellipsis
value in Asset’s units
asset_close_to
:
Final
[
algopy.Account
]
¶
Ellipsis
32 byte address
asset_receiver
:
Final
[
algopy.Account
]
¶
Ellipsis
32 byte address
asset_sender
:
Final
[
algopy.Account
]
¶
Ellipsis
32 byte address. Source of assets if Sender is the Asset’s Clawback address.
static
assets
(
a
:
algopy.UInt64
|
int
,
/
)
→
algopy.Asset
¶
Foreign Assets listed in the ApplicationCall transaction
Native TEAL opcode:
txna
,
txnas
clear_state_program
:
Final
[
algopy.Bytes
]
¶
Ellipsis
Clear state program
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
[
algopy.Account
]
¶
Ellipsis
32 byte address
config_asset
:
Final
[
algopy.Asset
]
¶
Ellipsis
Asset ID in asset config transaction
config_asset_clawback
:
Final
[
algopy.Account
]
¶
Ellipsis
32 byte address
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
[
bool
]
¶
Ellipsis
Whether the asset’s slots are frozen by default or not, 0 or 1
config_asset_freeze
:
Final
[
algopy.Account
]
¶
Ellipsis
32 byte address
config_asset_manager
:
Final
[
algopy.Account
]
¶
Ellipsis
32 byte address
config_asset_metadata_hash
:
Final
[
algopy.Bytes
]
¶
Ellipsis
32 byte commitment to unspecified asset metadata
config_asset_name
:
Final
[
algopy.Bytes
]
¶
Ellipsis
The asset name
config_asset_reserve
:
Final
[
algopy.Account
]
¶
Ellipsis
32 byte address
config_asset_total
:
Final
[
algopy.UInt64
]
¶
Ellipsis
Total number of units of this asset created
config_asset_unit_name
:
Final
[
algopy.Bytes
]
¶
Ellipsis
Unit name of the asset
config_asset_url
:
Final
[
algopy.Bytes
]
¶
Ellipsis
URL
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
[
algopy.Asset
]
¶
Ellipsis
Asset ID allocated by the creation of an ASA (only with
itxn
in v5). Application mode only
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
[
algopy.UInt64
]
¶
Ellipsis
microalgos
first_valid
:
Final
[
algopy.UInt64
]
¶
Ellipsis
round number
first_valid_time
:
Final
[
algopy.UInt64
]
¶
Ellipsis
UNIX timestamp of block before txn.FirstValid. Fails if negative
freeze_asset
:
Final
[
algopy.Asset
]
¶
Ellipsis
Asset ID being frozen or un-frozen
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
[
bool
]
¶
Ellipsis
The new frozen value, 0 or 1
global_num_byte_slice
:
Final
[
algopy.UInt64
]
¶
Ellipsis
Number of global state byteslices in ApplicationCall
global_num_uint
:
Final
[
algopy.UInt64
]
¶
Ellipsis
Number of global state integers in ApplicationCall
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
[
algopy.Bytes
]
¶
Ellipsis
The last message emitted. Empty bytes if none were emitted. Application mode only
last_valid
:
Final
[
algopy.UInt64
]
¶
Ellipsis
round number
lease
:
Final
[
algopy.Bytes
]
¶
Ellipsis
32 byte lease value
local_num_byte_slice
:
Final
[
algopy.UInt64
]
¶
Ellipsis
Number of local state byteslices in ApplicationCall
local_num_uint
:
Final
[
algopy.UInt64
]
¶
Ellipsis
Number of local state integers in ApplicationCall
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
[
bool
]
¶
Ellipsis
Marks an account nonparticipating for rewards
note
:
Final
[
algopy.Bytes
]
¶
Ellipsis
Any data up to 1024 bytes
num_accounts
:
Final
[
algopy.UInt64
]
¶
Ellipsis
Number of Accounts
num_app_args
:
Final
[
algopy.UInt64
]
¶
Ellipsis
Number of ApplicationArgs
num_applications
:
Final
[
algopy.UInt64
]
¶
Ellipsis
Number of Applications
num_approval_program_pages
:
Final
[
algopy.UInt64
]
¶
Ellipsis
Number of Approval Program pages
num_assets
:
Final
[
algopy.UInt64
]
¶
Ellipsis
Number of Assets
num_clear_state_program_pages
:
Final
[
algopy.UInt64
]
¶
Ellipsis
Number of ClearState Program pages
num_logs
:
Final
[
algopy.UInt64
]
¶
Ellipsis
Number of Logs (only with
itxn
in v5). Application mode only
on_completion
:
Final
[
algopy.OnCompleteAction
]
¶
Ellipsis
ApplicationCall transaction on completion action
receiver
:
Final
[
algopy.Account
]
¶
Ellipsis
32 byte address
rekey_to
:
Final
[
algopy.Account
]
¶
Ellipsis
32 byte Sender’s new AuthAddr
selection_pk
:
Final
[
algopy.Bytes
]
¶
Ellipsis
32 byte address
sender
:
Final
[
algopy.Account
]
¶
Ellipsis
32 byte address
state_proof_pk
:
Final
[
algopy.Bytes
]
¶
Ellipsis
64 byte state proof public key
tx_id
:
Final
[
algopy.Bytes
]
¶
Ellipsis
The computed ID for this transaction. 32 bytes.
type
:
Final
[
algopy.Bytes
]
¶
Ellipsis
Transaction type as bytes
type_enum
:
Final
[
algopy.TransactionType
]
¶
Ellipsis
Transaction type as integer
vote_first
:
Final
[
algopy.UInt64
]
¶
Ellipsis
The first round that the participation key is valid.
vote_key_dilution
:
Final
[
algopy.UInt64
]
¶
Ellipsis
Dilution for the 2-level participation key
vote_last
:
Final
[
algopy.UInt64
]
¶
Ellipsis
The last round that the participation key is valid.
vote_pk
:
Final
[
algopy.Bytes
]
¶
Ellipsis
32 byte address
xfer_asset
:
Final
[
algopy.Asset
]
¶
Ellipsis
Asset ID
class
algopy.
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__
(
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__
(
other
:
algopy.UInt64
|
int
)
→
algopy.UInt64
¶
A UInt64 can bitwise and with another UInt64 or int e.g.
UInt64(4)
&
2
__bool__
(
)
→
bool
¶
A UInt64 will evaluate to
False
if zero, and
True
otherwise
__eq__
(
other
:
algopy.UInt64
|
int
)
→
bool
¶
A UInt64 can use the
==
operator with another UInt64 or int
__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__
(
other
:
algopy.UInt64
|
int
)
→
bool
¶
A UInt64 can use the
>=
operator with another UInt64 or int
__gt__
(
other
:
algopy.UInt64
|
int
)
→
bool
¶
A UInt64 can use the
>
operator with another UInt64 or int
__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__
(
other
:
algopy.UInt64
|
int
)
→
algopy.UInt64
¶
A UInt64 can bitwise and with another UInt64 or int e.g.
a
&=
UInt64(2)
__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__
(
other
:
algopy.UInt64
|
int
)
→
algopy.UInt64
¶
A UInt64 can be left shifted by another UInt64 or int e.g.
a
<<=
UInt64(2)
__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__
(
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__
(
)
→
int
¶
A UInt64 can be used in indexing/slice expressions
__invert__
(
)
→
algopy.UInt64
¶
A UInt64 can be bitwise inverted e.g.
~UInt64(4)
__ior__
(
other
:
algopy.UInt64
|
int
)
→
algopy.UInt64
¶
A UInt64 can bitwise or with another UInt64 or int e.g.
a
|=
UInt64(2)
__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__
(
other
:
algopy.UInt64
|
int
)
→
algopy.UInt64
¶
A UInt64 can be right shifted by another UInt64 or int e.g.
a
>>=
UInt64(2)
__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__
(
other
:
algopy.UInt64
|
int
)
→
algopy.UInt64
¶
A UInt64 can bitwise xor with another UInt64 or int e.g.
a
^=
UInt64(2)
__le__
(
other
:
algopy.UInt64
|
int
)
→
bool
¶
A UInt64 can use the
<=
operator with another UInt64 or int
__lshift__
(
other
:
algopy.UInt64
|
int
)
→
algopy.UInt64
¶
A UInt64 can be left shifted by another UInt64 or int e.g.
UInt64(4)
<<
2
__lt__
(
other
:
algopy.UInt64
|
int
)
→
bool
¶
A UInt64 can use the
<
operator with another UInt64 or int
__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__
(
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__
(
other
:
algopy.UInt64
|
int
)
→
bool
¶
A UInt64 can use the
!=
operator with another UInt64 or int
__or__
(
other
:
algopy.UInt64
|
int
)
→
algopy.UInt64
¶
A UInt64 can bitwise or with another UInt64 or int e.g.
UInt64(4)
|
2
__pos__
(
)
→
algopy.UInt64
¶
Supports unary + operator. Redundant given the type is unsigned
__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__
(
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__
(
other
:
algopy.UInt64
|
int
)
→
algopy.UInt64
¶
A UInt64 can bitwise and with another UInt64 or int e.g.
4
&
UInt64(2)
__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__
(
other
:
algopy.UInt64
|
int
)
→
algopy.UInt64
¶
A UInt64 can be left shifted by another UInt64 or int e.g.
4
<<
UInt64(2)
__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__
(
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__
(
other
:
algopy.UInt64
|
int
)
→
algopy.UInt64
¶
A UInt64 can bitwise or with another UInt64 or int e.g.
4
|
UInt64(2)
__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__
(
other
:
algopy.UInt64
|
int
)
→
algopy.UInt64
¶
A UInt64 can be right shifted by another UInt64 or int e.g.
4
>>
UInt64(2)
__rshift__
(
other
:
algopy.UInt64
|
int
)
→
algopy.UInt64
¶
A UInt64 can be right shifted by another UInt64 or int e.g.
UInt64(4)
>>
2
__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__
(
other
:
algopy.UInt64
|
int
)
→
algopy.UInt64
¶
A UInt64 can bitwise xor with another UInt64 or int e.g.
4
^
UInt64(2)
__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__
(
other
:
algopy.UInt64
|
int
)
→
algopy.UInt64
¶
A UInt64 can bitwise xor with another UInt64 or int e.g.
UInt64(4)
^
2
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
(
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
(
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
(
*
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
(
*
,
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
(
*
,
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
(
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
¶
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
Next
algopy.arc4
Previous
API Reference
Copyright © 2024, Algorand Foundation
Made with
Sphinx
and
@pradyunsg
's
Furo


Answer:
Back to top
View this page
Toggle Light / Dark / Auto color theme
Toggle table of contents sidebar
algopy.arc4
¶
Module Contents
¶
Classes
¶
ARC4Client
Used to provide typed method signatures for ARC4 contracts
ARC4Contract
A contract that conforms to the ARC4 ABI specification, functions decorated with
@abimethod
or
@baremethod
will form the public interface of the contract
Address
An alias for an array containing 32 bytes representing an Algorand address
BigUFixedNxM
An ARC4 UFixed representing a decimal with the number of bits and precision specified.
BigUIntN
An ARC4 UInt consisting of the number of bits specified.
Bool
An ARC4 encoded bool
Byte
An ARC4 alias for a UInt8
DynamicArray
A dynamically sized ARC4 Array of the specified type
DynamicBytes
A variable sized array of bytes
StaticArray
A fixed length ARC4 Array of the specified type and length
String
An ARC4 sequence of bytes containing a UTF8 string
Struct
Base class for ARC4 Struct types
Tuple
An ARC4 ABI tuple, containing other ARC4 ABI types
UFixedNxM
An ARC4 UFixed representing a decimal with the number of bits and precision specified.
UIntN
An ARC4 UInt consisting of the number of bits specified.
Functions
¶
abimethod
Decorator that indicates a method is an ARC4 ABI method.
arc4_create
Provides a typesafe and convenient way of creating an ARC4Contract via an inner transaction
arc4_signature
Returns the ARC4 encoded method selector for the specified signature
arc4_update
Provides a typesafe and convenient way of updating an ARC4Contract via an inner transaction
baremethod
Decorator that indicates a method is an ARC4 bare method.
emit
Emit an ARC-28 event for the provided event signature or name, and provided args.
Data
¶
UInt128
An ARC4 UInt128
UInt16
An ARC4 UInt16
UInt256
An ARC4 UInt256
UInt32
An ARC4 UInt32
UInt512
An ARC4 UInt512
UInt64
An ARC4 UInt64
UInt8
An ARC4 UInt8
abi_call
Provides a typesafe way of calling ARC4 methods via an inner transaction
API
¶
class
algopy.arc4.
ARC4Client
¶
Used to provide typed method signatures for ARC4 contracts
class
algopy.arc4.
ARC4Contract
¶
A contract that conforms to the ARC4 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 ARC4 ABI specification
The clear_state_program will by default return True, but can be overridden
class
algopy.arc4.
Address
(
value
:
algopy.Account
|
str
|
algopy.Bytes
=
...
,
/
)
¶
An alias for an array containing 32 bytes representing an Algorand address
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
¶
Returns
True
if not equal to the zero address
__eq__
(
other
:
algopy.arc4.Address
|
algopy.Account
|
str
)
→
bool
¶
Address equality is determined by the address of another
arc4.Address
,
Account
or
str
__getitem__
(
index
:
algopy.UInt64
|
int
)
→
algopy.arc4._TArrayItem
¶
Gets the item of the array at provided index
__iter__
(
)
→
Iterator
[
algopy.arc4._TArrayItem
]
¶
Returns an iterator for the items in the array
__ne__
(
other
:
algopy.arc4.Address
|
algopy.Account
|
str
)
→
bool
¶
Address equality is determined by the address of another
arc4.Address
,
Account
or
str
__reversed__
(
)
→
Iterator
[
algopy.arc4._TArrayItem
]
¶
Returns an iterator for the items in the array, in reverse order
__setitem__
(
index
:
algopy.UInt64
|
int
,
value
:
algopy.arc4._TArrayItem
,
)
→
algopy.arc4._TArrayItem
¶
Sets the item of the array at specified index to provided value
copy
(
)
→
Self
¶
Create a copy of this array
classmethod
from_log
(
log
:
algopy.Bytes
,
/
)
→
Self
¶
Load an ABI type from application logs, checking for the ABI return prefix
0x151f7c75
property
length
:
algopy.UInt64
¶
Returns the current length of the array
property
native
:
algopy.Account
¶
Return the Account representation of the address after ARC4 decoding
class
algopy.arc4.
BigUFixedNxM
(
value
:
str
=
'0.0'
,
/
)
¶
An ARC4 UFixed representing a decimal with the number of bits and precision specified.
Max size: 512 bits
Initialization
Construct an instance of UFixedNxM where value (v) is determined from the original
decimal value (d) by the formula v = round(d * (10^M))
__bool__
(
)
→
bool
¶
Returns
True
if not equal to zero
__eq__
(
other
:
Self
)
→
bool
¶
Compare for equality, note both operands must be the exact same type
classmethod
from_log
(
log
:
algopy.Bytes
,
/
)
→
Self
¶
Load an ABI type from application logs, checking for the ABI return prefix
0x151f7c75
class
algopy.arc4.
BigUIntN
(
value
:
algopy.BigUInt
|
algopy.UInt64
|
int
=
0
,
/
)
¶
An ARC4 UInt consisting of the number of bits specified.
Max size: 512 bits
Initialization
__bool__
(
)
→
bool
¶
Returns
True
if not equal to zero
classmethod
from_log
(
log
:
algopy.Bytes
,
/
)
→
Self
¶
Load an ABI type from application logs, checking for the ABI return prefix
0x151f7c75
property
native
:
algopy.BigUInt
¶
Return the BigUInt representation of the value after ARC4 decoding
class
algopy.arc4.
Bool
(
value
:
bool
=
False
,
/
)
¶
An ARC4 encoded bool
Initialization
classmethod
from_log
(
log
:
algopy.Bytes
,
/
)
→
Self
¶
Load an ABI type from application logs, checking for the ABI return prefix
0x151f7c75
property
native
:
bool
¶
Return the bool representation of the value after ARC4 decoding
class
algopy.arc4.
Byte
(
value
:
algopy.BigUInt
|
algopy.UInt64
|
int
=
0
,
/
)
¶
An ARC4 alias for a UInt8
Initialization
__bool__
(
)
→
bool
¶
Returns
True
if not equal to zero
classmethod
from_log
(
log
:
algopy.Bytes
,
/
)
→
Self
¶
Load an ABI type from application logs, checking for the ABI return prefix
0x151f7c75
property
native
:
algopy.UInt64
¶
Return the UInt64 representation of the value after ARC4 decoding
class
algopy.arc4.
DynamicArray
(
*
items
:
algopy.arc4._TArrayItem
)
¶
A dynamically sized ARC4 Array of the specified type
Initialization
Initializes a new array with items provided
__add__
(
other
:
algopy.arc4.DynamicArray
[
algopy.arc4._TArrayItem
]
|
algopy.arc4.StaticArray
[
algopy.arc4._TArrayItem
,
algopy.arc4._TArrayLength
]
|
tuple
[
algopy.arc4._TArrayItem
,
...
]
,
)
→
algopy.arc4.DynamicArray
[
algopy.arc4._TArrayItem
]
¶
Concat two arrays together, returning a new array
__bool__
(
)
→
bool
¶
Returns
True
if not an empty array
__getitem__
(
index
:
algopy.UInt64
|
int
)
→
algopy.arc4._TArrayItem
¶
Gets the item of the array at provided index
__iter__
(
)
→
Iterator
[
algopy.arc4._TArrayItem
]
¶
Returns an iterator for the items in the array
__reversed__
(
)
→
Iterator
[
algopy.arc4._TArrayItem
]
¶
Returns an iterator for the items in the array, in reverse order
__setitem__
(
index
:
algopy.UInt64
|
int
,
value
:
algopy.arc4._TArrayItem
,
)
→
algopy.arc4._TArrayItem
¶
Sets the item of the array at specified index to provided value
append
(
item
:
algopy.arc4._TArrayItem
,
/
)
→
None
¶
Append an item to this array
copy
(
)
→
Self
¶
Create a copy of this array
extend
(
other
:
algopy.arc4.DynamicArray
[
algopy.arc4._TArrayItem
]
|
algopy.arc4.StaticArray
[
algopy.arc4._TArrayItem
,
algopy.arc4._TArrayLength
]
|
tuple
[
algopy.arc4._TArrayItem
,
...
]
,
/
,
)
→
None
¶
Extend this array with the contents of another array
classmethod
from_log
(
log
:
algopy.Bytes
,
/
)
→
Self
¶
Load an ABI type from application logs, checking for the ABI return prefix
0x151f7c75
property
length
:
algopy.UInt64
¶
Returns the current length of the array
pop
(
)
→
algopy.arc4._TArrayItem
¶
Remove and return the last item of this array
class
algopy.arc4.
DynamicBytes
¶
A variable sized array of bytes
__add__
(
other
:
algopy.arc4.DynamicArray
[
algopy.arc4._TArrayItem
]
|
algopy.arc4.StaticArray
[
algopy.arc4._TArrayItem
,
algopy.arc4._TArrayLength
]
|
tuple
[
algopy.arc4._TArrayItem
,
...
]
,
)
→
algopy.arc4.DynamicArray
[
algopy.arc4._TArrayItem
]
¶
Concat two arrays together, returning a new array
__bool__
(
)
→
bool
¶
Returns
True
if not an empty array
__getitem__
(
index
:
algopy.UInt64
|
int
)
→
algopy.arc4._TArrayItem
¶
Gets the item of the array at provided index
__iter__
(
)
→
Iterator
[
algopy.arc4._TArrayItem
]
¶
Returns an iterator for the items in the array
__reversed__
(
)
→
Iterator
[
algopy.arc4._TArrayItem
]
¶
Returns an iterator for the items in the array, in reverse order
__setitem__
(
index
:
algopy.UInt64
|
int
,
value
:
algopy.arc4._TArrayItem
,
)
→
algopy.arc4._TArrayItem
¶
Sets the item of the array at specified index to provided value
append
(
item
:
algopy.arc4._TArrayItem
,
/
)
→
None
¶
Append an item to this array
copy
(
)
→
Self
¶
Create a copy of this array
extend
(
other
:
algopy.arc4.DynamicArray
[
algopy.arc4._TArrayItem
]
|
algopy.arc4.StaticArray
[
algopy.arc4._TArrayItem
,
algopy.arc4._TArrayLength
]
|
tuple
[
algopy.arc4._TArrayItem
,
...
]
,
/
,
)
→
None
¶
Extend this array with the contents of another array
classmethod
from_log
(
log
:
algopy.Bytes
,
/
)
→
Self
¶
Load an ABI type from application logs, checking for the ABI return prefix
0x151f7c75
property
length
:
algopy.UInt64
¶
Returns the current length of the array
property
native
:
algopy.Bytes
¶
Return the Bytes representation of the address after ARC4 decoding
pop
(
)
→
algopy.arc4._TArrayItem
¶
Remove and return the last item of this array
class
algopy.arc4.
StaticArray
¶
A fixed length ARC4 Array of the specified type and length
__getitem__
(
index
:
algopy.UInt64
|
int
)
→
algopy.arc4._TArrayItem
¶
Gets the item of the array at provided index
__iter__
(
)
→
Iterator
[
algopy.arc4._TArrayItem
]
¶
Returns an iterator for the items in the array
__reversed__
(
)
→
Iterator
[
algopy.arc4._TArrayItem
]
¶
Returns an iterator for the items in the array, in reverse order
__setitem__
(
index
:
algopy.UInt64
|
int
,
value
:
algopy.arc4._TArrayItem
,
)
→
algopy.arc4._TArrayItem
¶
Sets the item of the array at specified index to provided value
copy
(
)
→
Self
¶
Create a copy of this array
classmethod
from_log
(
log
:
algopy.Bytes
,
/
)
→
Self
¶
Load an ABI type from application logs, checking for the ABI return prefix
0x151f7c75
property
length
:
algopy.UInt64
¶
Returns the current length of the array
class
algopy.arc4.
String
(
value
:
algopy.String
|
str
=
''
,
/
)
¶
An ARC4 sequence of bytes containing a UTF8 string
Initialization
__bool__
(
)
→
bool
¶
Returns
True
if length is not zero
classmethod
from_log
(
log
:
algopy.Bytes
,
/
)
→
Self
¶
Load an ABI type from application logs, checking for the ABI return prefix
0x151f7c75
property
native
:
algopy.String
¶
Return the String representation of the UTF8 string after ARC4 decoding
class
algopy.arc4.
Struct
¶
Base class for ARC4 Struct types
_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.
property
bytes
:
algopy.Bytes
¶
Get the underlying bytes[]
copy
(
)
→
Self
¶
Create a copy of this struct
classmethod
from_bytes
(
value
:
algopy.Bytes
|
bytes
,
/
)
→
Self
¶
Construct an instance from the underlying bytes[] (no validation)
classmethod
from_log
(
log
:
algopy.Bytes
,
/
)
→
Self
¶
Load an ABI type from application logs, checking for the ABI return prefix
0x151f7c75
class
algopy.arc4.
Tuple
(
items
:
tuple
[
Unpack
[
algopy.arc4._TTuple
]
]
,
/
)
¶
An ARC4 ABI tuple, containing other ARC4 ABI types
Initialization
Construct an ARC4 tuple from a native Python tuple
__add__
(
)
¶
Return self+value.
__contains__
(
)
¶
Return bool(key in self).
__delattr__
(
)
¶
Implement delattr(self, name).
__dir__
(
)
¶
Default dir() implementation.
__eq__
(
)
¶
Return self==value.
__format__
(
)
¶
Default object formatter.
Return str(self) if format_spec is empty. Raise TypeError otherwise.
__ge__
(
)
¶
Return self>=value.
__getattribute__
(
)
¶
Return getattr(self, name).
__getitem__
(
)
¶
Return self[key].
__getstate__
(
)
¶
Helper for pickle.
__gt__
(
)
¶
Return self>value.
__hash__
(
)
¶
Return hash(self).
__iter__
(
)
¶
Implement iter(self).
__le__
(
)
¶
Return self<=value.
__len__
(
)
¶
Return len(self).
__lt__
(
)
¶
Return self<value.
__mul__
(
)
¶
Return self*value.
__ne__
(
)
¶
Return self!=value.
__new__
(
)
¶
Create and return a new object.  See help(type) for accurate signature.
__reduce__
(
)
¶
Helper for pickle.
__reduce_ex__
(
)
¶
Helper for pickle.
__repr__
(
)
¶
Return repr(self).
__rmul__
(
)
¶
Return value*self.
__setattr__
(
)
¶
Implement setattr(self, name, value).
__sizeof__
(
)
¶
Size of object in memory, in bytes.
__str__
(
)
¶
Return str(self).
copy
(
)
→
Self
¶
Create a copy of this tuple
count
(
)
¶
Return number of occurrences of value.
classmethod
from_log
(
log
:
algopy.Bytes
,
/
)
→
Self
¶
Load an ABI type from application logs, checking for the ABI return prefix
0x151f7c75
index
(
)
¶
Return first index of value.
Raises ValueError if the value is not present.
property
native
:
tuple
[
Unpack
[
algopy.arc4._TTuple
]
]
¶
Convert to a native Python tuple - note that the elements of the tuple
should be considered to be copies of the original elements
class
algopy.arc4.
UFixedNxM
(
value
:
str
=
'0.0'
,
/
)
¶
An ARC4 UFixed representing a decimal with the number of bits and precision specified.
Max size: 64 bits
Initialization
Construct an instance of UFixedNxM where value (v) is determined from the original
decimal value (d) by the formula v = round(d * (10^M))
__bool__
(
)
→
bool
¶
Returns
True
if not equal to zero
__eq__
(
other
:
Self
)
→
bool
¶
Compare for equality, note both operands must be the exact same type
classmethod
from_log
(
log
:
algopy.Bytes
,
/
)
→
Self
¶
Load an ABI type from application logs, checking for the ABI return prefix
0x151f7c75
algopy.arc4.
UInt128
:
TypeAlias
¶
None
An ARC4 UInt128
algopy.arc4.
UInt16
:
TypeAlias
¶
None
An ARC4 UInt16
algopy.arc4.
UInt256
:
TypeAlias
¶
None
An ARC4 UInt256
algopy.arc4.
UInt32
:
TypeAlias
¶
None
An ARC4 UInt32
algopy.arc4.
UInt512
:
TypeAlias
¶
None
An ARC4 UInt512
algopy.arc4.
UInt64
:
TypeAlias
¶
None
An ARC4 UInt64
algopy.arc4.
UInt8
:
TypeAlias
¶
None
An ARC4 UInt8
class
algopy.arc4.
UIntN
(
value
:
algopy.BigUInt
|
algopy.UInt64
|
int
=
0
,
/
)
¶
An ARC4 UInt consisting of the number of bits specified.
Max Size: 64 bits
Initialization
__bool__
(
)
→
bool
¶
Returns
True
if not equal to zero
classmethod
from_log
(
log
:
algopy.Bytes
,
/
)
→
Self
¶
Load an ABI type from application logs, checking for the ABI return prefix
0x151f7c75
property
native
:
algopy.UInt64
¶
Return the UInt64 representation of the value after ARC4 decoding
algopy.arc4.
abi_call
:
algopy.arc4._ABICallProtocolType
¶
Ellipsis
Provides a typesafe way of calling ARC4 methods via an inner transaction
def
abi_call
(
self
,
method
:
Callable
[
...
,
_TABIResult_co
]
|
str
,
/
,
*
args
:
_TABIArg
,
app_id
:
algopy
.
Application
|
algopy
.
UInt64
|
int
=
...
,
on_completion
:
algopy
.
OnCompleteAction
=
...
,
approval_program
:
algopy
.
Bytes
|
bytes
|
tuple
[
algopy
.
Bytes
,
...
]
=
...
,
clear_state_program
:
algopy
.
Bytes
|
bytes
|
tuple
[
algopy
.
Bytes
,
...
]
=
...
,
global_num_uint
:
UInt64
|
int
=
...
,
global_num_bytes
:
UInt64
|
int
=
...
,
local_num_uint
:
UInt64
|
int
=
...
,
local_num_bytes
:
UInt64
|
int
=
...
,
extra_program_pages
:
UInt64
|
int
=
...
,
fee
:
algopy
.
UInt64
|
int
=
0
,
sender
:
algopy
.
Account
|
str
=
...
,
note
:
algopy
.
Bytes
|
algopy
.
String
|
bytes
|
str
=
...
,
rekey_to
:
algopy
.
Account
|
str
=
...
,
)
->
tuple
[
_TABIResult_co
,
algopy
.
itxn
.
ApplicationCallInnerTransaction
]:
...
PARAMETERS:
method:
The name, method selector or Algorand Python method to call
app_id:
Application to call, if 0 or not specified will create a new application
on_completion:
OnCompleteAction value for the transaction. If not specified will be inferred from Algorand Python method where possible
approval_program:
When creating or updating an application, the approval program
clear_state_program:
When creating or updating an application, the clear state program
global_num_uint:
When creating an application the number of global uints
global_num_bytes:
When creating an application the number of global bytes
local_num_uint:
When creating an application the number of local uints
local_num_bytes:
When creating an application the number of local bytes
extra_program_pages:
When creating an application the The number of extra program pages
fee:
The fee to pay for the transaction, defaults to 0
sender:
The sender address for the transaction
note:
Note to include with the transaction
rekey_to:
Account to rekey to
RETURNS:
If
method
references an Algorand Contract / Client or the function is indexed with a return type,
then the result is a tuple containing the ABI result and the inner transaction of the call.
If no return type is specified, or the method does not have a return value then the result
is the inner transaction of the call.
Examples:
# can reference another algopy contract method
result
,
txn
=
abi_call
(
HelloWorldContract
.
hello
,
arc4
.
String
(
"World"
),
app
=...
)
assert
result
==
"Hello, World"
# can reference a method selector
result
,
txn
=
abi_call
[
arc4
.
String
](
"hello(string)string"
,
arc4
.
String
(
"Algo"
),
app
=...
)
assert
result
==
"Hello, Algo"
# can reference a method name, the method selector is inferred from arguments and return type
result
,
txn
=
abi_call
[
arc4
.
String
](
"hello"
,
"There"
,
app
=...
)
assert
result
==
"Hello, There"
# calling a method without a return value
txn
=
abi_call
(
HelloWorldContract
.
no_return
,
arc4
.
String
(
"World"
),
app
=...
)
algopy.arc4.
abimethod
(
*
,
name
:
str
=
...
,
create
:
Literal
[
allow
,
require
,
disallow
]
=
'disallow'
,
allow_actions
:
collections.abc.Sequence
[
algopy.OnCompleteAction
|
Literal
[
NoOp
,
OptIn
,
CloseOut
,
UpdateApplication
,
DeleteApplication
]
]
=
('NoOp',)
,
readonly
:
bool
=
False
,
default_args
:
collections.abc.Mapping
[
str
,
str
|
algopy.arc4._ReadOnlyNoArgsMethod
|
object
]
=
...
,
)
→
collections.abc.Callable
[
[
collections.abc.Callable
[
algopy.arc4._P
,
algopy.arc4._R
]
]
,
collections.abc.Callable
[
algopy.arc4._P
,
algopy.arc4._R
]
]
¶
Decorator that indicates a method is an ARC4 ABI method.
Parameters
:
name
– Name component of the ABI method selector. Defaults to using the function name.
create
– Controls the validation of the Application ID. “require” means it must be zero,
“disallow” requires it must be non-zero, and “allow” disables the validation.
allow_actions
– A sequence of allowed On-Completion Actions to validate against.
readonly
– If True, then this method can be used via dry-run / simulate.
default_args
– Default argument sources for clients to use. For dynamic defaults, this can
be the name of, or reference to a method member, or the name of a storage
member. For static defaults, this can be any expression which evaluates to
a compile time constant of the exact same type as the parameter.
algopy.arc4.
arc4_create
(
method
:
collections.abc.Callable
[
algopy.arc4._P
,
algopy.arc4._TABIResult_co
]
,
/
,
*
args
:
object
,
compiled
:
algopy.CompiledContract
=
...
,
on_completion
:
algopy.OnCompleteAction
=
...
,
fee
:
algopy.UInt64
|
int
=
0
,
sender
:
algopy.Account
|
str
=
...
,
note
:
algopy.Bytes
|
bytes
|
str
=
...
,
rekey_to
:
algopy.Account
|
str
=
...
,
)
→
tuple
[
algopy.arc4._TABIResult_co
,
algopy.itxn.ApplicationCallInnerTransaction
]
¶
Provides a typesafe and convenient way of creating an ARC4Contract via an inner transaction
Parameters
:
method
– An ARC4 create method (ABI or bare), or an ARC4Contract with a single create method
args
– ABI args for chosen method
compiled
– If supplied will be used to specify transaction parameters required for creation,
can be omitted if template variables are not used
on_completion
– OnCompleteAction value for the transaction
If not specified will be inferred from Algorand Python method where possible
fee
– The fee to pay for the transaction, defaults to 0
sender
– The sender address for the transaction
note
– Note to include with the transaction
rekey_to
– Account to rekey to
algopy.arc4.
arc4_signature
(
signature
:
str
,
/
)
→
algopy.Bytes
¶
Returns the ARC4 encoded method selector for the specified signature
algopy.arc4.
arc4_update
(
method
:
collections.abc.Callable
[
algopy.arc4._P
,
algopy.arc4._TABIResult_co
]
,
/
,
*
args
:
object
,
app_id
:
algopy.Application
|
algopy.UInt64
|
int
,
compiled
:
algopy.CompiledContract
=
...
,
fee
:
algopy.UInt64
|
int
=
0
,
sender
:
algopy.Account
|
str
=
...
,
note
:
algopy.Bytes
|
bytes
|
str
=
...
,
rekey_to
:
algopy.Account
|
str
=
...
,
)
→
tuple
[
algopy.arc4._TABIResult_co
,
algopy.itxn.ApplicationCallInnerTransaction
]
¶
Provides a typesafe and convenient way of updating an ARC4Contract via an inner transaction
Parameters
:
method
– An ARC4 update method (ABI or bare), or an ARC4Contract with a single update method
args
– ABI args for chosen method
app_id
– Application to update
compiled
– If supplied will be used to specify transaction parameters required for updating,
can be omitted if template variables are not used
fee
– The fee to pay for the transaction, defaults to 0
sender
– The sender address for the transaction
note
– Note to include with the transaction
rekey_to
– Account to rekey to
algopy.arc4.
baremethod
(
*
,
create
:
Literal
[
allow
,
require
,
disallow
]
=
'disallow'
,
allow_actions
:
collections.abc.Sequence
[
algopy.OnCompleteAction
|
Literal
[
NoOp
,
OptIn
,
CloseOut
,
UpdateApplication
,
DeleteApplication
]
]
=
...
,
)
→
collections.abc.Callable
[
[
collections.abc.Callable
[
[
algopy.arc4._TARC4Contract
]
,
None
]
]
,
collections.abc.Callable
[
[
algopy.arc4._TARC4Contract
]
,
None
]
]
¶
Decorator that indicates a method is an ARC4 bare method.
There can be only one bare method on a contract for each given On-Completion Action.
Parameters
:
create
– Controls the validation of the Application ID. “require” means it must be zero,
“disallow” requires it must be non-zero, and “allow” disables the validation.
allow_actions
– Which On-Completion Action(s) to handle.
algopy.arc4.
emit
(
event
:
str
|
algopy.arc4.Struct
,
/
,
*
args
:
object
)
→
None
¶
Emit an ARC-28 event for the provided event signature or name, and provided args.
Parameters
:
event
–
Either an ARC4 Struct, an event name, or event signature.
If event is an ARC4 Struct, the event signature will be determined from the Struct name and fields
If event is a signature, then the following args will be typed checked to ensure they match.
If event is just a name, the event signature will be inferred from the name and following arguments
args
– When event is a signature or name, args will be used as the event data.
They will all be encoded as single ARC4 Tuple
Example:
from
algopy
import
ARC4Contract
,
arc4
class
Swapped
(
arc4
.
Struct
):
a
:
arc4
.
UInt64
b
:
arc4
.
UInt64
class
EventEmitter
(
ARC4Contract
):
@arc4
.
abimethod
def
emit_swapped
(
self
,
a
:
arc4
.
UInt64
,
b
:
arc4
.
UInt64
)
->
None
:
arc4
.
emit
(
Swapped
(
b
,
a
))
arc4
.
emit
(
"Swapped(uint64,uint64)"
,
b
,
a
)
arc4
.
emit
(
"Swapped"
,
b
,
a
)
Next
algopy.gtxn
Previous
algopy
Copyright © 2024, Algorand Foundation
Made with
Sphinx
and
@pradyunsg
's
Furo