question
stringclasses 1
value | answer
stringlengths 371
161k
|
---|---|
Back to top
View this page
Toggle Light / Dark / Auto color theme
Toggle table of contents sidebar
Algorand Python
¶
Algorand Python is a partial implementation of the Python programming language that runs on the AVM. It includes a statically typed framework for development of Algorand smart contracts and logic signatures, with Pythonic interfaces to underlying AVM functionality that works with standard Python tooling.
Algorand Python is compiled for execution on the AVM by PuyaPy, an optimising compiler that ensures the resulting AVM bytecode execution semantics that match the given Python code. PuyaPy produces output that is directly compatible with
AlgoKit typed clients
to make deployment and calling easy.
Quick start
¶
The easiest way to use Algorand Python is to instantiate a template with AlgoKit via
algokit
init
-t
python
. This will give you a full development environment with intellisense, linting, automatic formatting, breakpoint debugging, deployment and CI/CD.
Alternatively, if you want to start from scratch you can do the following:
Ensure you have Python 3.12+
Install
AlgoKit CLI
Check you can run the compiler:
algokit
compile
py
-h
Install Algorand Python into your project
poetry
add
algorand-python
Create a contract in a (e.g.)
contract.py
file:
from
algopy
import
ARC4Contract
,
arc4
class
HelloWorldContract
(
ARC4Contract
):
@arc4
.
abimethod
def
hello
(
self
,
name
:
arc4
.
String
)
->
arc4
.
String
:
return
"Hello, "
+
name
Compile the contract:
algokit
compile
py
contract.py
You should now have
HelloWorldContract.approval.teal
and
HelloWorldContract.clear.teal
on the file system!
We generally recommend using ARC-32 and
generated typed clients
to have the most optimal deployment and consumption experience; to do this you need to ask PuyaPy to output an ARC-32 compatible app spec file:
algokit
compile
py
contract.py
--output-arc32
--no-output-teal
You should now have
HelloWorldContract.arc32.json
, which can be generated into a client e.g. using AlgoKit CLI:
algokit
generate
client
HelloWorldContract.arc32.json
--output
client.py
From here you can dive into the
examples
or look at the
documentation
.
Programming with Algorand Python
¶
To get started developing with Algorand Python, please take a look at the
Language Guide
.
Using the PuyaPy compiler
¶
To see detailed guidance for using the PuyaPy compiler, please take a look at the
Compiler guide
.
Next
Language Guide
Copyright © 2024, Algorand Foundation
Made with
Sphinx
and
@pradyunsg
's
Furo |
|
Back to top
View this page
Toggle Light / Dark / Auto color theme
Toggle table of contents sidebar
Program structure
¶
An Algorand Python smart contract is defined within a single class. You can extend other
contracts (through inheritance), and also define standalone functions and reference them. This also
works across different Python packages - in other words, you can have a Python library with common
functions and re-use that library across multiple projects!
Modules
¶
Algorand Python modules are files that end in
.py
, as with standard Python. Sub-modules are
supported as well, so you’re free to organise your Algorand Python code however you see fit.
The standard python import rules apply, including
relative vs absolute import
requirements.
A given module can contain zero, one, or many smart contracts and/or logic signatures.
A module can contain
contracts
,
subroutines
,
logic signatures
, and
compile-time constant code and values
.
Typing
¶
Algorand Python code must be fully typed with
type annotations
.
In practice, this mostly means annotating the arguments and return types of all functions.
Subroutines
¶
Subroutines are “internal” or “private” methods to a contract. They can exist as part of a contract
class, or at the module level so they can be used by multiple classes or even across multiple
projects.
You can pass parameters to subroutines and define local variables, both of which automatically get
managed for you with semantics that match Python semantics.
All subroutines must be decorated with
algopy.subroutine
, like so:
def
foo
()
->
None
:
# compiler error: not decorated with subroutine
...
@algopy
.
subroutine
def
bar
()
->
None
:
...
Note
Requiring this decorator serves two key purposes:
You get an understandable error message if you try and use a third party package that wasn’t
built for Algorand Python
It provides for the ability to modify the functions on the fly when running in Python itself, in
a future testing framework.
Argument and return types to a subroutine can be any Algorand Python variable type (except for
some inner transaction types
).
Returning multiple values is allowed, this is annotated in the standard Python way with
tuple
:
@algopy
.
subroutine
def
return_two_things
()
->
tuple
[
algopy
.
UInt64
,
algopy
.
String
]:
...
Keyword only and positional only argument list modifiers are supported:
@algopy
.
subroutine
def
my_method
(
a
:
algopy
.
UInt64
,
/
,
b
:
algopy
.
UInt64
,
*
,
c
:
algopy
.
UInt64
)
->
None
:
...
In this example,
a
can only be passed positionally,
b
can be passed either by position or by
name, and
c
can only be passed by name.
The following argument/return types are not currently supported:
Type unions
Variadic args like
*args
,
**kwargs
Python types such as
int
Default values are not supported
Contract classes
¶
An
Algorand smart contract
consists of two distinct “programs”; an approval program, and a
clear-state program. These are tied together in Algorand Python as a single class.
All contracts must inherit from the base class
algopy.Contract
- either directly or indirectly,
which can include inheriting from
algopy.ARC4Contract
.
The life-cycle of a smart contract matches the semantics of Python classes when you consider
deploying a smart contract as “instantiating” the class. Any calls to that smart contract are made
to that instance of the smart contract, and any state assigned to
self.
will persist across
different invocations (provided the transaction it was a part of succeeds, of course). You can
deploy the same contract class multiple times, each will become a distinct and isolated instance.
Contract classes can optionally implement an
__init__
method, which will be executed exactly
once, on first deployment. This method takes no arguments, but can contain arbitrary code,
including reading directly from the transaction arguments via
Txn
. This makes
it a good place to put common initialisation code, particularly in ARC-4 contracts with multiple
methods that allow for creation.
The contract class body should not contain any logic or variable initialisations, only method
definitions. Forward type declarations are allowed.
Example:
class
MyContract
(
algopy
.
Contract
):
foo
:
algopy
.
UInt64
# okay
bar
=
algopy
.
UInt64
(
1
)
# not allowed
if
True
:
# also not allowed
bar
=
algopy
.
UInt64
(
2
)
Only concrete (ie non-abstract) classes produce output artifacts for deployment. To mark a class
as explicitly abstract, inherit from
abc.ABC
.
Note
The compiler will produce a warning if a Contract class is implicitly abstract, i.e. if any
abstract methods are unimplemented.
For more about inheritance and it’s role in code reuse, see the section
in
Code reuse
Contract class configuration
¶
When defining a contract subclass you can pass configuration options to the
algopy.Contract
base class
per the API documentation
.
Namely you can pass in:
name
- Which will affect the output TEAL file name if there are multiple non-abstract contracts
in the same file and will also be used as the contract name in the ARC-32 application.json instead of the class name.
scratch_slots
- Which allows you to mark a slot ID or range of slot IDs as “off limits” to Puya
so you can manually use them.
state_totals
- Which allows defining what values should be used for global and local uint and bytes storage values
when creating a contract and will appear in ARC-32 app spec.
Full example:
GLOBAL_UINTS
=
3
class
MyContract
(
algopy
.
Contract
,
name
=
"CustomName"
,
scratch_slots
=
[
5
,
25
,
algopy
.
urange
(
110
,
115
)],
state_totals
=
algopy
.
StateTotals
(
local_bytes
=
1
,
local_uints
=
2
,
global_bytes
=
4
,
global_uints
=
GLOBAL_UINTS
),
):
...
Example: Simplest possible
algopy.Contract
implementation
¶
For a non-ARC4 contract, the contract class must implement an
approval_program
and
a
clear_state_program
method.
As an example, this is a valid contract that always approves:
class
Contract
(
algopy
.
Contract
):
def
approval_program
(
self
)
->
bool
:
return
True
def
clear_state_program
(
self
)
->
bool
:
return
True
The return value of these methods can be either a
bool
that indicates whether the transaction
should approve or not, or a
algopy.UInt64
value, where
UInt64(0)
indicates that the transaction
should be rejected and any other value indicates that it should be approved.
Example: Simple call counter
¶
Here is a very simple example contract that maintains a counter of how many times it has
been called (including on create).
class
Counter
(
algopy
.
Contract
):
def
__init__
(
self
)
->
None
:
self
.
counter
=
algopy
.
UInt64
(
0
)
def
approval_program
(
self
)
->
bool
:
match
algopy
.
Txn
.
on_completion
:
case
algopy
.
OnCompleteAction
.
NoOp
:
self
.
increment_counter
()
return
True
case
_
:
# reject all OnCompletionAction's other than NoOp
return
False
def
clear_state_program
(
self
)
->
bool
:
return
True
@algopy
.
subroutine
def
increment_counter
(
self
)
->
None
:
self
.
counter
+=
1
Some things to note:
self.counter
will be stored in the application’s
Global State
.
The return type of
__init__
must be
None
, per standard typed Python.
Any methods other than
__init__
,
approval_program
or
clear_state_program
must be decorated
with
@subroutine
.
Example: Simplest possible
algopy.ARC4Contract
implementation
¶
And here is a valid ARC4 contract:
class
ABIContract
(
algopy
.
ARC4Contract
):
pass
A default
@algopy.arc4.baremethod
that allows contract creation is automatically inserted if no
other public method allows execution on create.
The approval program is always automatically generated, and consists of a router which delegates
based on the transaction application args to the correct public method.
A default
clear_state_program
is implemented which always approves, but this can be overridden.
Example: An ARC4 call counter
¶
import
algopy
class
ARC4Counter
(
algopy
.
ARC4Contract
):
def
__init__
(
self
)
->
None
:
self
.
counter
=
algopy
.
UInt64
(
0
)
@algopy
.
arc4
.
abimethod
(
create
=
"allow"
)
def
invoke
(
self
)
->
algopy
.
arc4
.
UInt64
:
self
.
increment_counter
()
return
algopy
.
arc4
.
UInt64
(
self
.
counter
)
@algopy
.
subroutine
def
increment_counter
(
self
)
->
None
:
self
.
counter
+=
1
This functions very similarly to the
simple example
.
Things to note here:
Since the
invoke
method has
create="allow"
, it can be called both as the method to create the
app and also to invoke it after creation. This also means that no default bare-method create will
be generated, so the only way to create the contract is through this method.
The default options for
abimethod
is to only allow
NoOp
as an on-completion-action, so we
don’t need to check this manually.
The current call count is returned from the
invoke
method.
Every method in an
AR4Contract
except for the optional
__init__
and
clear_state_program
methods must be decorated with one of
algopy.arc4.abimethod
,
alogpy.arc4.baremethod
, or
algopy.subroutine
.
subroutines
won’t be directly callable through the default router.
See the
ARC-4 section
of this language guide for more info on the above.
Logic signatures
¶
Logic signatures on Algorand
are stateless, and consist of a single program. As such, they are implemented as functions in Algorand Python
rather than classes.
@algopy
.
logicsig
def
my_log_sig
()
->
bool
:
...
Similar to
approval_program
or
clear_state_program
methods, the function must take no
arguments, and return either
bool
or
algopy.UInt64
. The meaning is the same: a
True
value or non-zero
UInt64
value indicates success,
False
or
UInt64(0)
indicates failure.
Logic signatures can make use of subroutines that are not nested in contract classes.
Next
Types
Previous
Language Guide
Copyright © 2024, Algorand Foundation
Made with
Sphinx
and
@pradyunsg
's
Furo |
|
Back to top
View this page
Toggle Light / Dark / Auto color theme
Toggle table of contents sidebar
Types
¶
Algorand Python exposes a number of types that provide a statically typed representation of the behaviour that is possible on the Algorand Virtual Machine.
Types
AVM types
UInt64
Bytes
String
BigUInt
bool
Account
Asset
Application
Python built-in types
bool
tuple
typing.NamedTuple
None
int, str, bytes, float
Template variables
ARC-4 types
AVM types
¶
The most basic
types on the AVM
are
uint64
and
bytes[]
, representing unsigned 64-bit integers and byte arrays respectively.
These are represented by
UInt64
and
Bytes
in Algorand Python.
There are further “bounded” types supported by the AVM, which are backed by these two simple primitives.
For example,
bigint
represents a variably sized (up to 512-bits), unsigned integer, but is actually
backed by a
bytes[]
. This is represented by
BigUInt
in Algorand Python.
UInt64
¶
algopy.UInt64
represents the underlying AVM
uint64
type.
It supports all the same operators as
int
, except for
/
, you must use
//
for truncating
division instead.
# you can instantiate with an integer literal
num
=
algopy
.
UInt64
(
1
)
# no arguments default to the zero value
zero
=
algopy
.
UInt64
()
# zero is False, any other value is True
assert
not
zero
assert
num
# Like Python's `int`, `UInt64` is immutable, so augmented assignment operators return new values
one
=
num
num
+=
1
assert
one
==
1
assert
num
==
2
# note that once you have a variable of type UInt64, you don't need to type any variables
# derived from that or wrap int literals
num2
=
num
+
200
//
3
Further examples available here
.
Bytes
¶
algopy.Bytes
represents the underlying AVM
bytes[]
type. It is intended
to represent binary data, for UTF-8 it might be preferable to use
String
.
# you can instantiate with a bytes literal
data
=
algopy
.
Bytes
(
b
"abc"
)
# no arguments defaults to an empty value
empty
=
algopy
.
Bytes
()
# empty is False, non-empty is True
assert
data
assert
not
empty
# Like Python's `bytes`, `Bytes` is immutable, augmented assignment operators return new values
abc
=
data
data
+=
b
"def"
assert
abc
==
b
"abc"
assert
data
==
b
"abcdef"
# indexing and slicing are supported, and both return a Bytes
assert
abc
[
0
]
==
b
"a"
assert
data
[:
3
]
==
abc
# check if a bytes sequence occurs within another
assert
abc
in
data
Hint
Indexing a
Bytes
returning a
Bytes
differs from the behaviour of Python’s bytes type, which
returns an
int
.
# you can iterate
for
i
in
abc
:
...
# construct from encoded values
base32_seq
=
algopy
.
Bytes
.
from_base32
(
'74======'
)
base64_seq
=
algopy
.
Bytes
.
from_base64
(
'RkY='
)
hex_seq
=
algopy
.
Bytes
.
from_hex
(
'FF'
)
# binary manipulations ^, &, |, and ~ are supported
data
^=
~
((
base32_seq
&
base64_seq
)
|
hex_seq
)
# access the length via the .length property
assert
abc
.
length
==
3
Note
See
Python builtins
for an explanation of why
len()
isn’t supported.
See a full example
.
String
¶
String
is a special Algorand Python type that represents a UTF8 encoded string.
It’s backed by
Bytes
, which can be accessed through the
.bytes
.
It works similarly to
Bytes
, except that it works with
str
literals rather than
bytes
literals. Additionally, due to a lack of AVM support for unicode data, indexing and length
operations are not currently supported (simply getting the length of a UTF8 string is an
O(N)
operation, which would be quite costly in a smart contract). If you are happy using the length as
the number of bytes, then you can call
.bytes.length
.
# you can instantiate with a string literal
data
=
algopy
.
String
(
"abc"
)
# no arguments defaults to an empty value
empty
=
algopy
.
String
()
# empty is False, non-empty is True
assert
data
assert
not
empty
# Like Python's `str`, `String` is immutable, augmented assignment operators return new values
abc
=
data
data
+=
"def"
assert
abc
==
"abc"
assert
data
==
"abcdef"
# whilst indexing and slicing are not supported, the following tests are:
assert
abc
.
startswith
(
"ab"
)
assert
abc
.
endswith
(
"bc"
)
assert
abc
in
data
# you can also join multiple Strings together with a seperator:
assert
algopy
.
String
(
", "
)
.
join
((
abc
,
abc
))
==
"abc, abc"
# access the underlying bytes
assert
abc
.
bytes
==
b
"abc"
See a full example
.
BigUInt
¶
algopy.BigUInt
represents a variable length (max 512-bit) unsigned integer stored
as
bytes[]
in the AVM.
It supports all the same operators as
int
, except for power (
**
), left and right shift (
<<
and
>>
) and
/
(as with
UInt64
, you must use
//
for truncating division instead).
Note that the op code costs for
bigint
math are an order of magnitude higher than those for
uint64
math. If you just need to handle overflow, take a look at the wide ops such as
addw
,
mulw
, etc - all of which are exposed through the
algopy.op
module.
Another contrast between
bigint
and
uint64
math is that
bigint
math ops don’t immediately
error on overflow - if the result exceeds 512-bits, then you can still access the value via
.bytes
, but any further math operations will fail.
# you can instantiate with an integer literal
num
=
algopy
.
BigUInt
(
1
)
# no arguments default to the zero value
zero
=
algopy
.
BigUInt
()
# zero is False, any other value is True
assert
not
zero
assert
num
# Like Python's `int`, `BigUInt` is immutable, so augmented assignment operators return new values
one
=
num
num
+=
1
assert
one
==
1
assert
num
==
UInt64
(
2
)
# note that once you have a variable of type BigUInt, you don't need to type any variables
# derived from that or wrap int literals
num2
=
num
+
200
//
3
Further examples available here
.
bool
¶
The semantics of the AVM
bool
bounded type exactly match the semantics of Python’s built-in
bool
type
and thus Algorand Python uses the in-built
bool
type from Python.
Per the behaviour in normal Python, Algorand Python automatically converts various types to
bool
when they
appear in statements that expect a
bool
e.g.
if
/
while
/
assert
statements, appear in Boolean expressions
(e.g. next to
and
or
or
keywords) or are explicitly casted to a bool.
The semantics of
not
,
and
and
or
are special
per how these keywords work in Python
(e.g. short circuiting).
a
=
UInt64
(
1
)
b
=
UInt64
(
2
)
c
=
a
or
b
d
=
b
and
a
e
=
self
.
expensive_op
(
UInt64
(
0
))
or
self
.
side_effecting_op
(
UInt64
(
1
))
f
=
self
.
expensive_op
(
UInt64
(
3
))
or
self
.
side_effecting_op
(
UInt64
(
42
))
g
=
self
.
side_effecting_op
(
UInt64
(
0
))
and
self
.
expensive_op
(
UInt64
(
42
))
h
=
self
.
side_effecting_op
(
UInt64
(
2
))
and
self
.
expensive_op
(
UInt64
(
3
))
i
=
a
if
b
<
c
else
d
+
e
if
a
:
log
(
"a is True"
)
Further examples available here
.
Account
¶
Account
represents a logical Account, backed by a
bytes[32]
representing the
bytes of the public key (without the checksum). It has various account related methods that can be called from the type.
Also see
algopy.arc4.Address
if needing to represent the address as a distinct type.
Asset
¶
Asset
represents a logical Asset, backed by a
uint64
ID.
It has various asset related methods that can be called from the type.
Application
¶
Application
represents a logical Application, backed by a
uint64
ID.
It has various application related methods that can be called from the type.
Python built-in types
¶
Unfortunately, the
AVM types
don’t map to standard Python primitives. For instance,
in Python, an
int
is unsigned, and effectively unbounded. A
bytes
similarly is limited only by
the memory available, whereas an AVM
bytes[]
has a maximum length of 4096. In order to both maintain
semantic compatibility and allow for a framework implementation in plain Python that will fail under the
same conditions as when deployed to the AVM, support for Python primitives is limited.
In saying that, there are many places where built-in Python types can be used and over time the places these types can be used are expected to increase.
bool
¶
Per above
Algorand Python has full support for
bool
.
tuple
¶
Python tuples are supported as arguments to subroutines, local variables, return types.
typing.NamedTuple
¶
Python named tuples are also supported using
typing.NamedTuple
.
Note
Default field values and subclassing a NamedTuple are not supported
import
typing
import
algopy
class
Pair
(
typing
.
NamedTuple
):
foo
:
algopy
.
Bytes
bar
:
algopy
.
Bytes
None
¶
None
is not supported as a value, but is supported as a type annotation to indicate a function or subroutine
returns no value.
int, str, bytes, float
¶
The
int
,
str
and
bytes
built-in types are currently only supported as
module-level constants
or literals.
They can be passed as arguments to various Algorand Python methods that support them or
when interacting with certain
AVM types
e.g. adding a number to a
UInt64
.
float
is not supported.
Template variables
¶
Template variables can be used to represent a placeholder for a deploy-time provided
value. This can be declared using the
TemplateVar[TYPE]
type where
TYPE
is the
Algorand Python type that it will be interpreted as.
from
algopy
import
BigUInt
,
Bytes
,
TemplateVar
,
UInt64
,
arc4
from
algopy.arc4
import
UInt512
class
TemplateVariablesContract
(
arc4
.
ARC4Contract
):
@arc4
.
abimethod
()
def
get_bytes
(
self
)
->
Bytes
:
return
TemplateVar
[
Bytes
](
"SOME_BYTES"
)
@arc4
.
abimethod
()
def
get_big_uint
(
self
)
->
UInt512
:
x
=
TemplateVar
[
BigUInt
](
"SOME_BIG_UINT"
)
return
UInt512
(
x
)
@arc4
.
baremethod
(
allow_actions
=
[
"UpdateApplication"
])
def
on_update
(
self
)
->
None
:
assert
TemplateVar
[
bool
](
"UPDATABLE"
)
@arc4
.
baremethod
(
allow_actions
=
[
"DeleteApplication"
])
def
on_delete
(
self
)
->
None
:
assert
TemplateVar
[
UInt64
](
"DELETABLE"
)
The resulting TEAL code that PuyaPy emits has placeholders with
TMPL_{template
variable
name}
that expects either an integer value or an encoded bytes value. This behaviour exactly
matches what
AlgoKit Utils expects
.
For more information look at the API reference for
TemplateVar
.
ARC-4 types
¶
ARC-4 data types are a first class concept in Algorand Python. They can be passed into ARC-4
methods (which will translate to the relevant ARC-4 method signature), passed into subroutines, or
instantiated into local variables. A limited set of operations are exposed on some ARC-4 types, but
often it may make sense to convert the ARC-4 value to a native AVM type, in which case you can use
the
native
property to retrieve the value. Most of the ARC-4 types also allow for mutation e.g.
you can edit values in arrays by index.
Please see the
reference documentation
for the different classes that can
be used to represent ARC-4 values or the
ARC-4 documentation
for more information
about ARC-4.
Next
Control flow structures
Previous
Program structure
Copyright © 2024, Algorand Foundation
Made with
Sphinx
and
@pradyunsg
's
Furo |
|
Back to top
View this page
Toggle Light / Dark / Auto color theme
Toggle table of contents sidebar
Control flow structures
¶
Control flow in Algorand Python is similar to standard Python control flow, with support for if statements, while loops, for loops, and match statements.
If statements
¶
If statements work the same as Python. The conditions must be an expression that evaluates to bool, which can include a
String or Uint64
among others.
if
condition
:
# block of code to execute if condition is True
elif
condition2
:
# block of code to execute if condition is False and condition2 is True
else
:
# block of code to execute if condition and condition2 are both False
See full example
.
Ternary conditions
¶
Ternary conditions work the same as Python. The condition must be an expression that evaluates to bool, which can include a
String or Uint64
among others.
value1
=
UInt64
(
5
)
value2
=
String
(
">6"
)
if
value1
>
6
else
String
(
"<=6"
)
While loops
¶
While loops work the same as Python. The condition must be an expression that evaluates to bool, which can include a
String or Uint64
among others.
You can use
break
and
continue
.
while
condition
:
# block of code to execute if condition is True
See full example
.
For Loops
¶
For loops are used to iterate over sequences, ranges and
ARC-4 arrays
. They work the same as Python.
Algorand Python provides functions like
uenumerate
and
urange
to facilitate creating sequences and ranges; in-built Python
reversed
method works with these.
uenumerate
is similar to Python’s built-in enumerate function, but for UInt64 numbers; it allows you to loop over a sequence and have an automatic counter.
urange
is a function that generates a sequence of Uint64 numbers, which you can iterate over.
reversed
returns a reversed iterator of a sequence.
Here is an example of how you can use these functions in a contract:
test_array
=
arc4
.
StaticArray
(
arc4
.
UInt8
(),
arc4
.
UInt8
(),
arc4
.
UInt8
(),
arc4
.
UInt8
())
# urange: reversed items, forward index
for
index
,
item
in
uenumerate
(
reversed
(
urange
(
4
))):
test_array
[
index
]
=
arc4
.
UInt8
(
item
)
assert
test_array
.
bytes
==
Bytes
.
from_hex
(
"03020100"
)
See full
examples
.
Match Statements
¶
Match statements work the same as Python and work for […]
match
value
:
case
pattern1
:
# block of code to execute if pattern1 matches
case
pattern2
:
# block of code to execute if pattern2 matches
case
_
:
# Fallback
Note: Captures and patterns are not supported. Currently, there is only support for basic case/switch functionality; pattern matching and guard clauses are not currently supported.
See full example
.
Next
Module level constructs
Previous
Types
Copyright © 2024, Algorand Foundation
Made with
Sphinx
and
@pradyunsg
's
Furo |
|
Back to top
View this page
Toggle Light / Dark / Auto color theme
Toggle table of contents sidebar
Module level constructs
¶
You can write compile-time constant code at a module level and then use them in place of
Python built-in literal types
.
For a full example of what syntax is currently possible see the
test case example
.
Module constants
¶
Module constants are compile-time constant, and can contain
bool
,
int
,
str
and
bytes
.
You can use fstrings and other compile-time constant values in module constants too.
For example:
from
algopy
import
UInt64
,
subroutine
SCALE
=
100000
SCALED_PI
=
314159
@subroutine
def
circle_area
(
radius
:
UInt64
)
->
UInt64
:
scaled_result
=
SCALED_PI
*
radius
**
2
result
=
scaled_result
//
SCALE
return
result
@subroutine
def
circle_area_100
()
->
UInt64
:
return
circle_area
(
UInt64
(
100
))
If statements
¶
You can use if statements with compile-time constants in module constants.
For example:
FOO
=
42
if
FOO
>
12
:
BAR
=
123
else
:
BAR
=
456
Integer math
¶
Module constants can also be defined using common integer expressions.
For example:
SEVEN
=
7
TEN
=
7
+
3
FORTY_NINE
=
7
**
2
Strings
¶
Module
str
constants can use f-string formatting and other common string expressions.
For example:
NAME
=
"There"
MY_FORMATTED_STRING
=
f
"Hello
{
NAME
}
"
# Hello There
PADDED
=
f
"
{
123
:
05
}
"
# "00123"
DUPLICATED
=
"5"
*
3
# "555"
Type aliases
¶
You can create type aliases to make your contract terser and more expressive.
For example:
import
typing
from
algopy
import
arc4
VoteIndexArray
:
typing
.
TypeAlias
=
arc4
.
DynamicArray
[
arc4
.
UInt8
]
Row
:
typing
.
TypeAlias
=
arc4
.
StaticArray
[
arc4
.
UInt8
,
typing
.
Literal
[
3
]]
Game
:
typing
.
TypeAlias
=
arc4
.
StaticArray
[
Row
,
typing
.
Literal
[
3
]]
Move
:
typing
.
TypeAlias
=
tuple
[
arc4
.
UInt64
,
arc4
.
UInt64
]
Bytes32
:
typing
.
TypeAlias
=
arc4
.
StaticArray
[
arc4
.
Byte
,
typing
.
Literal
[
32
]]
Proof
:
typing
.
TypeAlias
=
arc4
.
DynamicArray
[
Bytes32
]
Next
Python builtins
Previous
Control flow structures
Copyright © 2024, Algorand Foundation
Made with
Sphinx
and
@pradyunsg
's
Furo |
|
Back to top
View this page
Toggle Light / Dark / Auto color theme
Toggle table of contents sidebar
Python builtins
¶
Some common python builtins have equivalent
algopy
versions, that use an
UInt64
instead of a native
int
.
len
¶
The
len()
builtin is not supported, instead
algopy
types that have a length have a
.length
property of type
UInt64
. This is primarily
due to
len()
always returning
int
and the CPython implementation enforcing that it returns
exactly
int
.
range
¶
The
range()
builtin has an equivalent
algopy.urange
this behaves the same as the python builtin except that it returns
an iteration of
UInt64
values instead of
int
.
enumerate
¶
The
enumerate()
builtin has an equivalent
algopy.uenumerate
this behaves the same as the python builtin except that it returns
an iteration of
UInt64
index values and the corresponding item.
reversed
¶
The
reversed()
builtin is supported when iterating within a
for
loop and behaves the same as the python builtin.
types
¶
See
here
Next
Error handling and assertions
Previous
Module level constructs
Copyright © 2024, Algorand Foundation
Made with
Sphinx
and
@pradyunsg
's
Furo |
|
Back to top
View this page
Toggle Light / Dark / Auto color theme
Toggle table of contents sidebar
Error handling and assertions
¶
In Algorand Python, error handling and assertions play a crucial role in ensuring the correctness and robustness of smart contracts.
Assertions
¶
Assertions allow you to immediately fail a smart contract if a
Boolean statement or value
evaluates to
False
. If an assertion fails, it immediately stops the execution of the contract and marks the call as a failure.
In Algorand Python, you can use the Python built-in
assert
statement to make assertions in your code.
For example:
@subroutine
def
set_value
(
value
:
UInt64
):
assert
value
>
4
,
"Value must be > 4"
Assertion error handling
¶
The (optional) string value provided with an assertion, if provided, will be added as a TEAL comment on the end of the assertion line. This works in concert with default AlgoKit Utils app client behaviour to show a TEAL stack trace of an error and thus show the error message to the caller (when source maps have been loaded).
Explicit failure
¶
For scenarios where you need to fail a contract explicitly, you can use
the
op.err()
operation. This operation causes the TEAL program to immediately
and unconditionally fail.
Alternatively
op.exit(0)
will achieve the same result. A non-zero value will
do the opposite and immediately succeed.
Exception handling
¶
The AVM doesn’t provide error trapping semantics so it’s not possible to implement
raise
and
catch
.
For more details see
Unsupported Python features
.
Next
Storing data on-chain
Previous
Python builtins
Copyright © 2024, Algorand Foundation
Made with
Sphinx
and
@pradyunsg
's
Furo |
|
Back to top
View this page
Toggle Light / Dark / Auto color theme
Toggle table of contents sidebar
Storing data on-chain
¶
Algorand smart contracts have
three different types of on-chain storage
they can utilise:
Global storage
,
Local storage
,
Box Storage
, and
Scratch storage
.
The life-cycle of a smart contract matches the semantics of Python classes when you consider
deploying a smart contract as “instantiating” the class. Any calls to that smart contract are made
to that instance of the smart contract, and any state assigned to
self.
variables will persist
across different invocations (provided the transaction it was a part of succeeds, of course). You can
deploy the same contract class multiple times, each will become a distinct and isolated instance.
During a single smart contract execution there is also the ability to use “temporary” storage
either global to the contract execution via
Scratch storage
, or local to
the current method via
local variables and subroutine params
.
Global storage
¶
Global storage is state that is stored against the contract instance and can be retrieved
by key. There are
AVM limits to the amount of global storage that can be allocated to a contract
.
This is represented in Algorand Python by either:
Assigning any
Algorand Python typed
value to an instance variable (e.g.
self.value
=
UInt64(3)
).
Use this approach if you just require a terse API for getting and setting a state value
Using an instance of
GlobalState
, which gives
some extra features
to understand
and control the value and the metadata of it (which propagates to the ARC-32 app spec file)
Use this approach if you need to:
Omit a default/initial value
Delete the stored value
Check if a value exists
Specify the exact key bytes
Include a description to be included in App Spec files (ARC32/ARC56)
For example:
self
.
global_int_full
=
GlobalState
(
UInt64
(
55
),
key
=
"gif"
,
description
=
"Global int full"
)
self
.
global_int_simplified
=
UInt64
(
33
)
self
.
global_int_no_default
=
GlobalState
(
UInt64
)
self
.
global_bytes_full
=
GlobalState
(
Bytes
(
b
"Hello"
))
self
.
global_bytes_simplified
=
Bytes
(
b
"Hello"
)
self
.
global_bytes_no_default
=
GlobalState
(
Bytes
)
global_int_full_set
=
bool
(
self
.
global_int_full
)
bytes_with_default_specified
=
self
.
global_bytes_no_default
.
get
(
b
"Default if no value set"
)
error_if_not_set
=
self
.
global_int_no_default
.
value
These values can be assigned anywhere you have access to
self
i.e. any instance methods/subroutines. The information about
global storage is automatically included in the ARC-32 app spec file and thus will automatically appear within
any
generated typed clients
.
Local storage
¶
Local storage is state that is stored against the contract instance for a specific account and can be retrieved
by key and account address. There are
AVM limits to the amount of local storage that can be allocated to a contract
.
This is represented in Algorand Python by using an instance of
LocalState
.
For example:
def
__init__
(
self
)
->
None
:
self
.
local
=
LocalState
(
Bytes
)
self
.
local_with_metadata
=
LocalState
(
UInt64
,
key
=
"lwm"
,
description
=
"Local with metadata"
)
@subroutine
def
get_guaranteed_data
(
self
,
for_account
:
Account
)
->
Bytes
:
return
self
.
local
[
for_account
]
@subroutine
def
get_data_with_default
(
self
,
for_account
:
Account
,
default
:
Bytes
)
->
Bytes
:
return
self
.
local
.
get
(
for_account
,
default
)
@subroutine
def
get_data_or_assert
(
self
,
for_account
:
Account
)
->
Bytes
:
result
,
exists
=
self
.
local
.
maybe
(
for_account
)
assert
exists
,
"no data for account"
return
result
@subroutine
def
set_data
(
self
,
for_account
:
Account
,
value
:
Bytes
)
->
None
:
self
.
local
[
for_account
]
=
value
@subroutine
def
delete_data
(
self
,
for_account
:
Account
)
->
None
:
del
self
.
local
[
for_account
]
These values can be assigned anywhere you have access to
self
i.e. any instance methods/subroutines. The information about
local storage is automatically included in the ARC-32 app spec file and thus will automatically appear within
any
generated typed clients
.
Box storage
¶
We provide 3 different types for accessing box storage:
Box
,
BoxMap
, and
BoxRef
. We also expose raw operations via the
AVM ops
module.
Before using box storage, be sure to familiarise yourself with the
requirements and restrictions
of the underlying API.
The
Box
type provides an abstraction over storing a single value in a single box. A box can be declared against
self
in an
__init__
method (in which case the key must be a compile time constant); or as a local variable within any
subroutine.
Box
proxy instances can be passed around like any other value.
Once declared, you can interact with the box via its instance methods.
import
typing
as
t
from
algopy
import
Box
,
arc4
,
Contract
,
op
class
MyContract
(
Contract
):
def
__init__
(
self
)
->
None
:
self
.
box_a
=
Box
(
arc4
.
StaticArray
[
arc4
.
UInt32
,
t
.
Literal
[
20
]],
key
=
b
"a"
)
def
approval_program
(
self
)
->
bool
:
box_b
=
Box
(
arc4
.
String
,
key
=
b
"b"
)
box_b
.
value
=
arc4
.
String
(
"Hello"
)
# Check if the box exists
if
self
.
box_a
:
# Reassign the value
self
.
box_a
.
value
[
2
]
=
arc4
.
UInt32
(
40
)
else
:
# Assign a new value
self
.
box_a
.
value
=
arc4
.
StaticArray
[
arc4
.
UInt32
,
t
.
Literal
[
20
]]
.
from_bytes
(
op
.
bzero
(
20
*
4
))
# Read a value
return
self
.
box_a
.
value
[
4
]
==
arc4
.
UInt32
(
2
)
BoxMap
is similar to the
Box
type, but allows for grouping a set of boxes with a common key and content type.
A custom
key_prefix
can optionally be provided, with the default being to use the variable name as the prefix.
The key can be a
Bytes
value, or anything that can be converted to
Bytes
. The final box name is the combination of
key_prefix
+
key
.
from
algopy
import
BoxMap
,
Contract
,
Account
,
Txn
,
String
class
MyContract
(
Contract
):
def
__init__
(
self
)
->
None
:
self
.
my_map
=
BoxMap
(
Account
,
String
,
key_prefix
=
b
"a_"
)
def
approval_program
(
self
)
->
bool
:
# Check if the box exists
if
Txn
.
sender
in
self
.
my_map
:
# Reassign the value
self
.
my_map
[
Txn
.
sender
]
=
String
(
" World"
)
else
:
# Assign a new value
self
.
my_map
[
Txn
.
sender
]
=
String
(
"Hello"
)
# Read a value
return
self
.
my_map
[
Txn
.
sender
]
==
String
(
"Hello World"
)
BoxRef
is a specialised type for interacting with boxes which contain binary data. In addition to being able to set and read the box value, there are operations for extracting and replacing just a portion of the box data which
is useful for minimizing the amount of reads and writes required, but also allows you to interact with byte arrays which are longer than the AVM can support (currently 4096).
from
algopy
import
BoxRef
,
Contract
,
Global
,
Txn
class
MyContract
(
Contract
):
def
approval_program
(
self
)
->
bool
:
my_blob
=
BoxRef
(
key
=
b
"blob"
)
sender_bytes
=
Txn
.
sender
.
bytes
app_address
=
Global
.
current_application_address
.
bytes
assert
my_blob
.
create
(
8000
)
my_blob
.
replace
(
0
,
sender_bytes
)
my_blob
.
splice
(
0
,
0
,
app_address
)
first_64
=
my_blob
.
extract
(
0
,
32
*
2
)
assert
first_64
==
app_address
+
sender_bytes
assert
my_blob
.
delete
()
value
,
exists
=
my_blob
.
maybe
()
assert
not
exists
assert
my_blob
.
get
(
default
=
sender_bytes
)
==
sender_bytes
my_blob
.
create
(
sender_bytes
+
app_address
)
assert
my_blob
,
"Blob exists"
assert
my_blob
.
length
==
64
return
True
If none of these abstractions suit your needs, you can use the box storage
AVM ops
to interact with box storage. These ops match closely to the opcodes available on the AVM.
For example:
op
.
Box
.
create
(
b
"key"
,
size
)
op
.
Box
.
put
(
Txn
.
sender
.
bytes
,
answer_ids
.
bytes
)
(
votes
,
exists
)
=
op
.
Box
.
get
(
Txn
.
sender
.
bytes
)
op
.
Box
.
replace
(
TALLY_BOX_KEY
,
index
,
op
.
itob
(
current_vote
+
1
))
See the
voting contract example
for a real-world example that uses box storage.
Scratch storage
¶
To use stratch storage you need to
register the scratch storage that you want to use
and then you can use the scratch storage
AVM ops
.
For example:
from
algopy
import
Bytes
,
Contract
,
UInt64
,
op
,
urange
TWO
=
2
TWENTY
=
20
class
MyContract
(
Contract
,
scratch_slots
=
(
1
,
TWO
,
urange
(
3
,
TWENTY
))):
def
approval_program
(
self
)
->
bool
:
op
.
Scratch
.
store
(
1
,
UInt64
(
5
))
op
.
Scratch
.
store
(
2
,
Bytes
(
b
"Hello World"
))
for
i
in
urange
(
3
,
20
):
op
.
Scratch
.
store
(
i
,
i
)
assert
op
.
Scratch
.
load_uint64
(
1
)
==
UInt64
(
5
)
assert
op
.
Scratch
.
load_bytes
(
2
)
==
b
"Hello World"
assert
op
.
Scratch
.
load_uint64
(
5
)
==
UInt64
(
5
)
return
True
def
clear_state_program
(
self
)
->
bool
:
return
True
Next
Logging
Previous
Error handling and assertions
Copyright © 2024, Algorand Foundation
Made with
Sphinx
and
@pradyunsg
's
Furo |
|
Back to top
View this page
Toggle Light / Dark / Auto color theme
Toggle table of contents sidebar
Logging
¶
Algorand Python provides a
log
method
that allows you to emit debugging and event information as well as return values from your contracts to the caller.
This
log
method is a superset of the
AVM
log
method
that adds extra functionality:
You can log multiple items rather than a single item
Items are concatenated together with an optional separator (which defaults to:
""
)
Items are automatically converted to bytes for you
Support for:
int
literals / module variables (encoded as raw bytes, not ASCII)
UInt64
values (encoded as raw bytes, not ASCII)
str
literals / module variables (encoded as UTF-8)
bytes
literals / module variables (encoded as is)
Bytes
values (encoded as is)
BytesBacked
values, which includes
String
,
BigUInt
,
Account
and all of the
ARC-4 types
(encoded as their underlying bytes values)
Logged values are
available to the calling client
and attached to the transaction record stored on the blockchain ledger.
If you want to emit ARC-28 events in the logs then there is a
purpose-built function for that
.
Here’s an example contract that uses the log method in various ways:
from
algopy
import
BigUInt
,
Bytes
,
Contract
,
log
,
op
class
MyContract
(
Contract
):
def
approval_program
(
self
)
->
bool
:
log
(
0
)
log
(
b
"1"
)
log
(
"2"
)
log
(
op
.
Txn
.
num_app_args
+
3
)
log
(
Bytes
(
b
"4"
)
if
op
.
Txn
.
num_app_args
else
Bytes
())
log
(
b
"5"
,
6
,
op
.
Txn
.
num_app_args
+
7
,
BigUInt
(
8
),
Bytes
(
b
"9"
)
if
op
.
Txn
.
num_app_args
else
Bytes
(),
sep
=
"_"
,
)
return
True
def
clear_state_program
(
self
)
->
bool
:
return
True
Next
Transactions
Previous
Storing data on-chain
Copyright © 2024, Algorand Foundation
Made with
Sphinx
and
@pradyunsg
's
Furo |
|
Back to top
View this page
Toggle Light / Dark / Auto color theme
Toggle table of contents sidebar
Transactions
¶
Algorand Python provides types for accessing fields of other transactions in a group, as well as
creating and submitting inner transactions from your smart contract.
The following types are available:
Group Transactions
Inner Transaction Field sets
Inner Transaction
PaymentTransaction
Payment
PaymentInnerTransaction
KeyRegistrationTransaction
KeyRegistration
KeyRegistrationInnerTransaction
AssetConfigTransaction
AssetConfig
AssetConfigInnerTransaction
AssetTransferTransaction
AssetTransfer
AssetTransferInnerTransaction
AssetFreezeTransaction
AssetFreeze
AssetFreezeInnerTransaction
ApplicationCallTransaction
ApplicationCall
ApplicationCallInnerTransaction
Transaction
InnerTransaction
InnerTransactionResult
Group Transactions
¶
Group transactions can be used as ARC4 parameters or instantiated from a group index.
ARC4 parameter
¶
Group transactions can be used as parameters in ARC4 method
For example to require a payment transaction in an ARC4 ABI method:
import
algopy
class
MyContract
(
algopy
.
ARC4Contract
):
@algopy
.
arc4
.
abimethod
()
def
process_payment
(
self
:
algopy
.
gtxn
.
PaymentTransaction
)
->
None
:
...
Group Index
¶
Group transactions can also be created using the group index of the transaction.
If instantiating one of the type specific transactions they will be checked to ensure the transaction is of the expected type.
Transaction
is not checked for a specific type and provides access to all transaction fields
For example, to obtain a reference to a payment transaction:
import
algopy
@algopy
.
subroutine
()
def
process_payment
(
group_index
:
algopy
.
UInt64
)
->
None
:
pay_txn
=
algopy
.
gtxn
.
PaymentTransaction
(
group_index
)
...
Inner Transactions
¶
Inner transactions are defined using the parameter types, and can then be submitted individually by calling the
.submit()
method, or as a group by calling
submit_txns
Examples
¶
Create and submit an inner transaction
¶
from
algopy
import
Account
,
UInt64
,
itxn
,
subroutine
@subroutine
def
example
(
amount
:
UInt64
,
receiver
:
Account
)
->
None
:
itxn
.
Payment
(
amount
=
amount
,
receiver
=
receiver
,
fee
=
0
,
)
.
submit
()
Accessing result of a submitted inner transaction
¶
from
algopy
import
Asset
,
itxn
,
subroutine
@subroutine
def
example
()
->
Asset
:
asset_txn
=
itxn
.
AssetConfig
(
asset_name
=
b
"Puya"
,
unit_name
=
b
"PYA"
,
total
=
1000
,
decimals
=
3
,
fee
=
0
,
)
.
submit
()
return
asset_txn
.
created_asset
Submitting multiple transactions
¶
from
algopy
import
Asset
,
Bytes
,
itxn
,
log
,
subroutine
@subroutine
def
example
()
->
tuple
[
Asset
,
Bytes
]:
asset1_params
=
itxn
.
AssetConfig
(
asset_name
=
b
"Puya"
,
unit_name
=
b
"PYA"
,
total
=
1000
,
decimals
=
3
,
fee
=
0
,
)
app_params
=
itxn
.
ApplicationCall
(
app_id
=
1234
,
app_args
=
(
Bytes
(
b
"arg1"
),
Bytes
(
b
"arg1"
))
)
asset1_txn
,
app_txn
=
itxn
.
submit_txns
(
asset1_params
,
app_params
)
# log some details
log
(
app_txn
.
logs
(
0
))
log
(
asset1_txn
.
txn_id
)
log
(
app_txn
.
txn_id
)
return
asset1_txn
.
created_asset
,
app_txn
.
logs
(
1
)
Create an ARC4 application, and then call it
¶
from
algopy
import
Bytes
,
arc4
,
itxn
,
subroutine
HELLO_WORLD_APPROVAL
:
bytes
=
...
HELLO_WORLD_CLEAR
:
bytes
=
...
@subroutine
def
example
()
->
None
:
# create an application
application_txn
=
itxn
.
ApplicationCall
(
approval_program
=
HELLO_WORLD_APPROVAL
,
clear_state_program
=
HELLO_WORLD_CLEAR
,
fee
=
0
,
)
.
submit
()
app
=
application_txn
.
created_app
# invoke an ABI method
call_txn
=
itxn
.
ApplicationCall
(
app_id
=
app
,
app_args
=
(
arc4
.
arc4_signature
(
"hello(string)string"
),
arc4
.
String
(
"World"
)),
fee
=
0
,
)
.
submit
()
# extract result
hello_world_result
=
arc4
.
String
.
from_log
(
call_txn
.
last_log
)
Create and submit transactions in a loop
¶
from
algopy
import
Account
,
UInt64
,
itxn
,
subroutine
@subroutine
def
example
(
receivers
:
tuple
[
Account
,
Account
,
Account
])
->
None
:
for
receiver
in
receivers
:
itxn
.
Payment
(
amount
=
UInt64
(
1_000_000
),
receiver
=
receiver
,
fee
=
0
,
)
.
submit
()
Limitations
¶
Inner transactions are powerful, but currently do have some restrictions in how they are used.
Inner transaction objects cannot be passed to or returned from subroutines
¶
from
algopy
import
Application
,
Bytes
,
itxn
,
subroutine
@subroutine
def
parameter_not_allowed
(
txn
:
itxn
.
PaymentInnerTransaction
)
->
None
:
# this is a compile error
...
@subroutine
def
return_not_allowed
()
->
itxn
.
PaymentInnerTransaction
:
# this is a compile error
...
@subroutine
def
passing_fields_allowed
()
->
Application
:
txn
=
itxn
.
ApplicationCall
(
...
)
.
submit
()
do_something
(
txn
.
txn_id
,
txn
.
logs
(
0
))
# this is ok
return
txn
.
created_app
# and this is ok
@subroutine
def
do_something
(
txn_id
:
Bytes
):
# this is just a regular subroutine
...
Inner transaction parameters cannot be reassigned without a
.copy()
¶
from
algopy
import
itxn
,
subroutine
@subroutine
def
example
()
->
None
:
payment
=
itxn
.
Payment
(
...
)
reassigned_payment
=
payment
# this is an error
copied_payment
=
payment
.
copy
()
# this is ok
Inner transactions cannot be reassigned
¶
from
algopy
import
itxn
,
subroutine
@subroutine
def
example
()
->
None
:
payment_txn
=
itxn
.
Payment
(
...
)
.
submit
()
reassigned_payment_txn
=
payment_txn
# this is an error
txn_id
=
payment_txn
.
txn_id
# this is ok
Inner transactions methods cannot be called if there is a subsequent inner transaction submitted or another subroutine is called.
¶
from
algopy
import
itxn
,
subroutine
@subroutine
def
example
()
->
None
:
app_1
=
itxn
.
ApplicationCall
(
...
)
.
submit
()
log_from_call1
=
app_1
.
logs
(
0
)
# this is ok
# another inner transaction is submitted
itxn
.
ApplicationCall
(
...
)
.
submit
()
# or another subroutine is called
call_some_other_subroutine
()
app1_txn_id
=
app_1
.
txn_id
# this is ok, properties are still available
another_log_from_call1
=
app_1
.
logs
(
1
)
# this is not allowed as the array results may no longer be available, instead assign to a variable before submitting another transaction
Next
AVM operations
Previous
Logging
Copyright © 2024, Algorand Foundation
Made with
Sphinx
and
@pradyunsg
's
Furo |
|
Back to top
View this page
Toggle Light / Dark / Auto color theme
Toggle table of contents sidebar
AVM operations
¶
Algorand Python allows you to do express
every op code the AVM has available
apart from ops that manipulate the stack (to avoid conflicts with the compiler), and
log
(to avoid confusion with the superior
Algorand Python log function
). These ops are exposed via the
algopy.op
submodule.
We generally recommend importing this entire submodule so you can use intellisense to discover the available methods:
from
algopy
import
UInt64
,
op
,
subroutine
@subroutine
def
sqrt_16
()
->
UInt64
:
return
op
.
sqrt
(
16
)
All ops are typed using Algorand Python types and have correct static type representations.
Many ops have higher-order functionality that Algorand Python exposes and would limit the need to reach for the underlying ops. For instance, there is first-class support for local and global storage so there is little need to use the likes of
app_local_get
et. al. But they are still exposed just in case you want to do something that Algorand Python’s abstractions don’t support.
Txn
¶
The
Txn
opcodes are so commonly used they have been exposed directly in the
algopy
module and can be easily imported to make it terser to access:
from
algopy
import
subroutine
,
Txn
@subroutine
def
has_no_app_args
()
->
bool
:
return
Txn
.
num_app_args
==
0
Global
¶
The
Global
opcodes are so commonly used they have been exposed directly in the
algopy
module and can be easily imported to make it terser to access:
from
algopy
import
subroutine
,
Global
,
Txn
@subroutine
def
only_allow_creator
()
->
None
:
assert
Txn
.
sender
==
Global
.
creator_address
,
"Only the contract creator can perform this operation"
Next
Opcode budgets
Previous
Transactions
Copyright © 2024, Algorand Foundation
Made with
Sphinx
and
@pradyunsg
's
Furo |
|
Back to top
View this page
Toggle Light / Dark / Auto color theme
Toggle table of contents sidebar
Opcode budgets
¶
Algorand Python provides a helper method for increasing the
available opcode budget
, see
algopy.ensure_budget
.
Next
ARC-4: Application Binary Interface
Previous
AVM operations
Copyright © 2024, Algorand Foundation
Made with
Sphinx
and
@pradyunsg
's
Furo |
|
Back to top
View this page
Toggle Light / Dark / Auto color theme
Toggle table of contents sidebar
ARC-4: Application Binary Interface
¶
ARC4
defines a set of encodings and behaviors for authoring and interacting with an Algorand Smart Contract. It is not the only way to author a smart contract, but adhering to it will make it easier for other clients and users to interop with your contract.
To author an arc4 contract you should extend the
ARC4Contract
base class.
from
algopy
import
ARC4Contract
class
HelloWorldContract
(
ARC4Contract
):
...
ARC-32 and ARC-56
¶
ARC32
extends the concepts in ARC4 to include an Application Specification which more holistically describes a smart contract and its associated state.
ARC-32/ARC-56 Application Specification files are automatically generated by the compiler for ARC4
contracts as
<ContractName>.arc32.json
or
<ContractName>.arc56.json
Methods
¶
Individual methods on a smart contract should be annotated with an
abimethod
decorator. This decorator is used to indicate a method which should be externally callable. The decorator itself includes properties to restrict when the method should be callable, for instance only when the application is being created or only when the OnComplete action is OptIn.
A method that should not be externally available should be annotated with a
subroutine
decorator.
Method docstrings will be used when outputting ARC-32 or ARC-56 application specifications, the following docstrings styles are supported ReST, Google, Numpydoc-style and Epydoc.
from
algopy
import
ARC4Contract
,
subroutine
,
arc4
class
HelloWorldContract
(
ARC4Contract
):
@arc4
.
abimethod
(
create
=
False
,
allow_actions
=
[
"NoOp"
,
"OptIn"
],
name
=
"external_name"
)
def
hello
(
self
,
name
:
arc4
.
String
)
->
arc4
.
String
:
return
self
.
internal_method
()
+
name
@subroutine
def
internal_method
(
self
)
->
arc4
.
String
:
return
arc4
.
String
(
"Hello, "
)
Router
¶
Algorand Smart Contracts only have two possible programs that are invoked when making an ApplicationCall Transaction (
appl
). The “clear state” program which is called when using an OnComplete action of
ClearState
or the “approval” program which is called for all other OnComplete actions.
Routing is required to dispatch calls handled by the approval program to the relevant ABI methods. When extending
ARC4Contract
, the routing code is automatically generated for you by the PuyaPy compiler.
Types
¶
ARC4 defines a number of
data types
which can be used in an ARC4 compatible contract and details how these types should be encoded in binary.
Algorand Python exposes these through a number of types which can be imported from the
algopy.arc4
module. These types represent binary encoded values following the rules prescribed in the ARC which can mean operations performed directly on these types are not as efficient as ones performed on natively supported types (such as
algopy.UInt64
or
algopy.Bytes
)
Where supported, the native equivalent of an ARC4 type can be obtained via the
.native
property. It is possible to use native types in an ABI method and the router will automatically encode and decode these types to their ARC4 equivalent.
Booleans
¶
Type:
algopy.arc4.Bool
Encoding:
A single byte where the most significant bit is
1
for
True
and
0
for
False
Native equivalent:
builtins.bool
Unsigned ints
¶
Types:
algopy.arc4.UIntN
(<= 64 bits)
algopy.arc4.BigUIntN
(> 64 bits)
Encoding:
A big endian byte array of N bits
Native equivalent:
algopy.UInt64
or
puya.py.BigUInt
Common bit sizes have also been aliased under
algopy.arc4.UInt8
,
algopy.arc4.UInt16
etc. A uint of any size between 8 and 512 bits (in intervals of 8bits) can be created using a generic parameter. It can be helpful to define your own alias for this type.
import
typing
as
t
from
algopy
import
arc4
UInt40
:
t
.
TypeAlias
=
arc4
.
UIntN
[
t
.
Literal
[
40
]]
Unsigned fixed point decimals
¶
Types:
algopy.arc4.UFixedNxM
(<= 64 bits)
algopy.arc4.BigUFixedNxM
(> 64 bits)
Encoding:
A big endian byte array of N bits where
encoded_value
=
value
/
(10^M)
Native equivalent:
none
import
typing
as
t
from
algopy
import
arc4
Decimal
:
t
.
TypeAlias
=
arc4
.
UFixedNxM
[
t
.
Literal
[
64
],
t
.
Literal
[
10
]]
Bytes and strings
¶
Types:
algopy.arc4.DynamicBytes
and
algopy.arc4.String
Encoding:
A variable length byte array prefixed with a 16-bit big endian header indicating the length of the data
Native equivalent:
algopy.Bytes
and
algopy.String
Strings are assumed to be utf-8 encoded and the length of a string is the total number of bytes,
not the total number of characters
.
Static arrays
¶
Type:
algopy.arc4.StaticArray
Encoding:
See
ARC4 Container Packing
Native equivalent:
none
An ARC4 StaticArray is an array of a fixed size. The item type is specified by the first generic parameter and the size is specified by the second.
import
typing
as
t
from
algopy
import
arc4
FourBytes
:
t
.
TypeAlias
=
arc4
.
StaticArray
[
arc4
.
Byte
,
t
.
Literal
[
4
]]
Address
¶
Type:
algopy.arc4.Address
Encoding:
A byte array 32 bytes long
Native equivalent:
algopy.Account
Address represents an Algorand address’s public key, and can be used instead of
algopy.Account
when needing to
reference an address in an ARC4 struct, tuple or return type. It is a subclass of
arc4.StaticArray[arc4.Byte,
typing.Literal[32]]
Dynamic arrays
¶
Type:
algopy.arc4.DynamicArray
Encoding:
See
ARC4 Container Packing
Native equivalent:
none
An ARC4 DynamicArray is an array of a variable size. The item type is specified by the first generic parameter. Items can be added and removed via
.pop
,
.append
, and
.extend
.
The current length of the array is encoded in a 16-bit prefix similar to the
arc4.DynamicBytes
and
arc4.String
types
import
typing
as
t
from
algopy
import
arc4
UInt64Array
:
t
.
TypeAlias
=
arc4
.
DynamicArray
[
arc4
.
UInt64
]
Tuples
¶
Type:
algopy.arc4.Tuple
Encoding:
See
ARC4 Container Packing
Native equivalent:
builtins.tuple
ARC4 Tuples are immutable statically sized arrays of mixed item types. Item types can be specified via generic parameters or inferred from constructor parameters.
Structs
¶
Type:
algopy.arc4.Struct
Encoding:
See
ARC4 Container Packing
Native equivalent:
typing.NamedTuple
ARC4 Structs are named tuples. The class keyword
frozen
can be used to indicate if a struct can be mutated.
Items can be accessed and mutated via names instead of indexes. Structs do not have a
.native
property,
but a NamedTuple can be used in ABI methods are will be encoded/decode to an ARC4 struct automatically.
import
typing
from
algopy
import
arc4
Decimal
:
typing
.
TypeAlias
=
arc4
.
UFixedNxM
[
typing
.
Literal
[
64
],
typing
.
Literal
[
9
]]
class
Vector
(
arc4
.
Struct
,
kw_only
=
True
,
frozen
=
True
):
x
:
Decimal
y
:
Decimal
ARC4 Container Packing
¶
ARC4 encoding rules are detailed explicitly in the
ARC
. A summary is included here.
Containers are composed of a head and tail portion.
For dynamic arrays, the head is prefixed with the length of the array encoded as a 16-bit number. This prefix is not included in offset calculation
For fixed sized items (eg. Bool, UIntN, or a StaticArray of UIntN), the item is included in the head
Consecutive Bool items are compressed into the minimum number of whole bytes possible by using a single bit to represent each Bool
For variable sized items (eg. DynamicArray, String etc), a pointer is included to the head and the data is added to the tail. This pointer represents the offset from the start of the head to the start of the item data in the tail.
Reference types
¶
Types:
algopy.Account
,
algopy.Application
,
algopy.Asset
,
algopy.gtxn.PaymentTransaction
,
algopy.gtxn.KeyRegistrationTransaction
,
algopy.gtxn.AssetConfigTransaction
,
algopy.gtxn.AssetTransferTransaction
,
algopy.gtxn.AssetFreezeTransaction
,
algopy.gtxn.ApplicationCallTransaction
The ARC4 specification allows for using a number of
reference types
in an ABI method signature where this reference type refers to…
another transaction in the group
an account in the accounts array (
apat
property of the transaction)
an asset in the foreign assets array (
apas
property of the transaction)
an application in the foreign apps array (
apfa
property of the transaction)
These types can only be used as parameters, and not as return types.
from
algopy
import
(
Account
,
Application
,
ARC4Contract
,
Asset
,
arc4
,
gtxn
,
)
class
Reference
(
ARC4Contract
):
@arc4
.
abimethod
def
with_transactions
(
self
,
asset
:
Asset
,
pay
:
gtxn
.
PaymentTransaction
,
account
:
Account
,
app
:
Application
,
axfr
:
gtxn
.
AssetTransferTransaction
)
->
None
:
...
Mutability
¶
To ensure semantic compatability the compiler will also check for any usages of mutable ARC4 types (arrays and structs) and ensure that any additional references are copied using the
.copy()
method.
Python values are passed by reference, and when an object (eg. an array or struct) is mutated in one place, all references to that object see the mutated version. In Python this is managed via the heap.
In Algorand Python these mutable values are instead stored on the stack, so when an additional reference is made (i.e. by assigning to another variable) a copy is added to the stack.
Which means if one reference is mutated, the other references would not see the change.
In order to keep the semantics the same, the compiler forces the addition of
.copy()
each time a new reference to the same object to match what will happen on the AVM.
Struct types can be indicated as
frozen
which will eliminate the need for a
.copy()
as long as the struct also contains no mutable fields (such as arrays or another mutable struct)
Next
ARC-28: Structured event logging
Previous
Opcode budgets
Copyright © 2024, Algorand Foundation
Made with
Sphinx
and
@pradyunsg
's
Furo |
|
Back to top
View this page
Toggle Light / Dark / Auto color theme
Toggle table of contents sidebar
ARC-28: Structured event logging
¶
ARC-28
provides a methodology for structured logging by Algorand smart contracts. It introduces the concept of Events, where data contained in logs may be categorized and structured.
Each Event is identified by a unique 4-byte identifier derived from its
Event
Signature
. The Event Signature is a UTF-8 string comprised of the event’s name, followed by the names of the
ARC-4
data types contained in the event, all enclosed in parentheses (
EventName(type1,type2,...)
) e.g.:
Swapped
(
uint64
,
uint64
)
Events are emitting by including them in the
log output
. The metadata that identifies the event should then be included in the ARC-4 contract output so that a calling client can parse the logs to parse the structured data out. This part of the ARC-28 spec isn’t yet implemented in Algorand Python, but it’s on the roadmap.
Emitting Events
¶
To emit an ARC-28 event in Algorand Python you can use the
emit
function, which appears in the
algopy.arc4
namespace for convenience since it heavily uses ARC-4 types and is essentially an extension of the ARC-4 specification. This function takes care of encoding the event payload to conform to the ARC-28 specification and there are 3 overloads:
An
ARC-4 struct
, from what the name of the struct will be used as a the event name and the struct parameters will be used as the event fields -
arc4.emit(Swapped(a,
b))
An event signature as a
string literal (or module variable)
, followed by the values -
arc4.emit("Swapped(uint64,uint64)",
a,
b)
An event name as a
string literal (or module variable)
, followed by the values -
arc4.emit("Swapped",
a,
b)
Here’s an example contract that emits events:
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
)
It’s worth noting that the ARC-28 event signature needs to be known at compile time so the event name can’t be a dynamic type and must be a static string literal or string module constant. If you want to emit dynamic events you can do so using the
log
method
, but you’d need to manually construct the correct series of bytes and the compiler won’t be able to emit the ARC-28 metadata so you’ll need to also manually parse the logs in your client.
Examples of manually constructing an event:
# This is essentially what the `emit` method is doing, noting that a,b need to be encoded
# as a tuple so below (simple concat) only works for static ARC-4 types
log
(
arc4
.
arc4_signature
(
"Swapped(uint64,uint64)"
),
a
,
b
)
# or, if you wanted it to be truly dynamic for some reason,
# (noting this has a non-trivial opcode cost) and assuming in this case
# that `event_suffix` is already defined as a `String`:
event_name
=
String
(
"Event"
)
+
event_suffix
event_selector
=
op
.
sha512_256
((
event_name
+
"(uint64)"
)
.
bytes
)[:
4
]
log
(
event_selector
,
UInt64
(
6
))
Next
Calling other applications
Previous
ARC-4: Application Binary Interface
Copyright © 2024, Algorand Foundation
Made with
Sphinx
and
@pradyunsg
's
Furo |
|
Back to top
View this page
Toggle Light / Dark / Auto color theme
Toggle table of contents sidebar
Calling other applications
¶
The preferred way to call other smart contracts is using
algopy.arc4.abi_call
,
algopy.arc4.arc4_create
or
algopy.arc4.arc4_update
. These methods support type checking and encoding of arguments, decoding of results, group transactions,
and in the case of
arc4_create
and
arc4_update
automatic inclusion of approval and clear state programs.
algopy.arc4.abi_call
¶
algopy.arc4.abi_call
can be used to call other ARC4 contracts, the first argument should refer to
an ARC4 method either by referencing an Algorand Python
algopy.arc4.ARC4Contract
method,
an
algopy.arc4.ARC4Client
method generated from an ARC-32 app spec, or a string representing
the ARC4 method signature or name.
The following arguments should then be the arguments required for the call, these arguments will be type checked and converted where appropriate.
Any other related transaction parameters such as
app_id
,
fee
etc. can also be provided as keyword arguments.
If the ARC4 method returns an ARC4 result then the result will be a tuple of the ARC4 result and the inner transaction.
If the ARC4 method does not return a result, or if the result type is not fully qualified then just the inner transaction is returned.
from
algopy
import
Application
,
ARC4Contract
,
String
,
arc4
,
subroutine
class
HelloWorld
(
ARC4Contract
):
@arc4
.
abimethod
()
def
greet
(
self
,
name
:
String
)
->
String
:
return
"Hello "
+
name
@subroutine
def
call_existing_application
(
app
:
Application
)
->
None
:
greeting
,
greet_txn
=
arc4
.
abi_call
(
HelloWorld
.
greet
,
"there"
,
app_id
=
app
)
assert
greeting
==
"Hello there"
assert
greet_txn
.
app_id
==
1234
Alternative ways to use
arc4.abi_call
¶
ARC4Client method
¶
A ARC4Client client represents the ARC4 abimethods of a smart contract and can be used to call abimethods in a type safe way
ARC4Client’s can be produced by using
puyapy
--output-client=True
when compiling a smart contract
(this would be useful if you wanted to publish a client for consumption by other smart contracts)
An ARC4Client can also be be generated from an ARC-32 application.json using
puyapy-clientgen
e.g.
puyapy-clientgen
examples/hello_world_arc4/out/HelloWorldContract.arc32.json
, this would be
the recommended approach for calling another smart contract that is not written in Algorand Python or does not provide the source
from
algopy
import
arc4
,
subroutine
class
HelloWorldClient
(
arc4
.
ARC4Client
):
def
hello
(
self
,
name
:
arc4
.
String
)
->
arc4
.
String
:
...
@subroutine
def
call_another_contract
()
->
None
:
# can reference another algopy contract method
result
,
txn
=
arc4
.
abi_call
(
HelloWorldClient
.
hello
,
arc4
.
String
(
"World"
),
app
=...
)
assert
result
==
"Hello, World"
Method signature or name
¶
An ARC4 method selector can be used e.g.
"hello(string)string
along with a type index to specify the return type.
Additionally just a name can be provided and the method signature will be inferred e.g.
from
algopy
import
arc4
,
subroutine
@subroutine
def
call_another_contract
()
->
None
:
# can reference a method selector
result
,
txn
=
arc4
.
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
=
arc4
.
abi_call
[
arc4
.
String
](
"hello"
,
"There"
,
app
=...
)
assert
result
==
"Hello, There"
algopy.arc4.arc4_create
¶
algopy.arc4.arc4_create
can be used to create ARC4 applications, and will automatically populate required fields for app creation (such as approval program, clear state program, and global/local state allocation).
Like
algopy.arc4.abi_call
it handles ARC4 arguments and provides ARC4 return values.
If the compiled programs and state allocation fields need to be customized (for example due to
template variables
),
this can be done by passing a
algopy.CompiledContract
via the
compiled
keyword argument.
from
algopy
import
ARC4Contract
,
String
,
arc4
,
subroutine
class
HelloWorld
(
ARC4Contract
):
@arc4
.
abimethod
()
def
greet
(
self
,
name
:
String
)
->
String
:
return
"Hello "
+
name
@subroutine
def
create_new_application
()
->
None
:
hello_world_app
=
arc4
.
arc4_create
(
HelloWorld
)
.
created_app
greeting
,
_txn
=
arc4
.
abi_call
(
HelloWorld
.
greet
,
"there"
,
app_id
=
hello_world_app
)
assert
greeting
==
"Hello there"
algopy.arc4.arc4_update
¶
algopy.arc4.arc4_update
is used to update an existing ARC4 application and will automatically populate the required approval and clear state program fields.
Like
algopy.arc4.abi_call
it handles ARC4 arguments and provides ARC4 return values.
If the compiled programs need to be customized (for example due to (for example due to
template variables
),
this can be done by passing a
algopy.CompiledContract
via the
compiled
keyword argument.
from
algopy
import
Application
,
ARC4Contract
,
String
,
arc4
,
subroutine
class
NewApp
(
ARC4Contract
):
@arc4
.
abimethod
()
def
greet
(
self
,
name
:
String
)
->
String
:
return
"Hello "
+
name
@subroutine
def
update_existing_application
(
existing_app
:
Application
)
->
None
:
hello_world_app
=
arc4
.
arc4_update
(
NewApp
,
app_id
=
existing_app
)
greeting
,
_txn
=
arc4
.
abi_call
(
NewApp
.
greet
,
"there"
,
app_id
=
hello_world_app
)
assert
greeting
==
"Hello there"
Using
itxn.ApplicationCall
¶
If the application being called is not an ARC4 contract, or an application specification is not available,
then
algopy.itxn.ApplicationCall
can be used. This approach is generally more verbose
than the above approaches, so should only be used if required. See
here
for an example
Next
Compiling to AVM bytecode
Previous
ARC-28: Structured event logging
Copyright © 2024, Algorand Foundation
Made with
Sphinx
and
@pradyunsg
's
Furo |
|
Back to top
View this page
Toggle Light / Dark / Auto color theme
Toggle table of contents sidebar
Compiling to AVM bytecode
¶
The PuyaPy compiler can compile Algorand Python smart contracts directly into AVM bytecode.
Once compiled, this bytecode can be utilized to construct AVM Application Call transactions both on and off chain.
Outputting AVM bytecode from CLI
¶
The
--output-bytecode
option can be used to generate
.bin
files for smart contracts and logic signatures, producing an approval and clear program for each smart contract.
Obtaining bytecode within other contracts
¶
The
compile_contract
function takes an Algorand Python smart contract class and returns a
CompiledContract
,
The global state, local state and program pages allocation parameters are derived from the contract by default, but can be overridden.
This compiled contract can then be used to create an
algopy.itxn.ApplicationCall
transaction or used with the
ARC4
functions.
The
compile_logicsig
takes an Algorand Python logic signature and returns a
CompiledLogicSig
, which can be used to
verify if a transaction has been signed by a particular logic signature.
Template variables
¶
Algorand Python supports defining
algopy.TemplateVar
variables that can be substituted during compilation.
For example, the following contract has
UInt64
and
Bytes
template variables.
templated_contract.py
¶
from
algopy
import
ARC4Contract
,
Bytes
,
TemplateVar
,
UInt64
,
arc4
class
TemplatedContract
(
ARC4Contract
):
@arc4
.
abimethod
def
my_method
(
self
)
->
UInt64
:
return
TemplateVar
[
UInt64
](
"SOME_UINT"
)
@arc4
.
abimethod
def
my_other_method
(
self
)
->
Bytes
:
return
TemplateVar
[
Bytes
](
"SOME_BYTES"
)
When compiling to bytecode, the values for these template variables must be provided. These values can be provided via the CLI,
or through the
template_vars
parameter of the
compile_contract
and
compile_logicsig
functions.
CLI
¶
The
--template-var
option can be used to
define
each variable.
For example to provide the values for the above example contract the following command could be used
puyapy
--template-var
SOME_UINT=123
--template-var
SOME_BYTES=0xABCD
templated_contract.py
Within other contracts
¶
The functions
compile_contract
and
compile_logicsig
both have an optional
template_vars
parameter
which can be used to define template variables. Variables defined in this manner take priority over variables defined on the CLI.
from
algopy
import
Bytes
,
UInt64
,
arc4
,
compile_contract
,
subroutine
from
templated_contract
import
TemplatedContract
@subroutine
def
create_templated_contract
()
->
None
:
compiled
=
compile_contract
(
TemplatedContract
,
global_uints
=
2
,
# customize allocated global uints
template_vars
=
{
# provide template vars
"SOME_UINT"
:
UInt64
(
123
),
"SOME_BYTES"
:
Bytes
(
b
"
\xAB\xCD
"
)
},
)
arc4
.
arc4_create
(
TemplatedContract
,
compiled
=
compiled
)
Next
Unsupported Python features
Previous
Calling other applications
Copyright © 2024, Algorand Foundation
Made with
Sphinx
and
@pradyunsg
's
Furo |
|
Back to top
View this page
Toggle Light / Dark / Auto color theme
Toggle table of contents sidebar
Unsupported Python features
¶
raise, try/except/finally
¶
Exception raising and exception handling constructs are not supported.
Supporting user exceptions would be costly to implement in terms of op codes.
Furthermore, AVM errors and exceptions are not “catch-able”, they immediately terminate the
program.
Therefore, there is very little to no benefit of supporting exceptions and exception handling.
The preferred method of raising an error that terminates is through the use of
assert statements
.
with
¶
Context managers are redundant without exception handling support.
async
¶
The AVM is not just single threaded, but all operations are effectively “blocking”, rendering
asynchronous programming effectively useless.
closures & lambdas
¶
Without the support of function pointers, or other methods of invoking an arbitrary function,
it’s not possible to return a function as a closure.
Nested functions/lambdas as a means of repeating common operations within a given function may be
supported in the future.
global keyword
¶
Module level values are only allowed to be
constants
. No
rebinding of module constants is allowed. It’s not clear what the meaning here would be, since
there’s no real arbitrary means of storing state without associating it with a particular contract.
If you do have need of such a thing, take a look at
gload_bytes
or
gload_uint64
if the contracts are within the same transaction,
otherwise
AppGlobal.get_ex_bytes
and
AppGlobal.get_ex_uint64
.
Inheritance (outside of contract classes)
¶
Polymorphism is also impossible to support without function pointers, so data classes (such as
arc4.Struct
) don’t currently allow for inheritance. Member functions there
are not supported because we’re not sure yet whether it’s better to not have inheritance but allow
functions on data classes, or to allow inheritance and disallow member functions.
Contract inheritance is a special case, since each concrete contract is compiled separately, true
polymorphism isn’t required as all references can be resolved at compile time.
Next
Principles & Background
Previous
Compiling to AVM bytecode
Copyright © 2024, Algorand Foundation
Made with
Sphinx
and
@pradyunsg
's
Furo |
|
Back to top
View this page
Toggle Light / Dark / Auto color theme
Toggle table of contents sidebar
Principles & Background
¶
Background
¶
Smart contracts
on the Algorand blockchain run on the Algorand Virtual Machine (
AVM
).
This is a stack based virtual machine, which executes AVM bytecode as part of an
Application Call transaction
.
The official mechanism for generating this bytecode is by submitting TEAL (Transaction Execution Approval Language) to
an Algorand Node to compile.
Smart signatures
have the same basis in the AVM and TEAL, but have a different execution model, one not involving
Application Call transactions. Our focus will primarily be on smart contracts, since they are strictly more powerful
in terms of available AVM functions.
TEAL is a
non-structured
imperative language
(albeit one with support for procedure calls that can isolate stack changes since v8 with
proto
). Writing TEAL is very
similar to writing assembly code. It goes without saying that this is a particularly common or well-practiced model for
programming these days.
As it stands today, developers wanting to write smart contracts specifically for Algorand have the option of writing
TEAL directly, or using some other mechanism of generating TEAL such as the officially supported
PyTEAL
or the community supported
tealish
.
PyTEAL follows a
generative programming
paradigm,
which is a form of metaprogramming. Naturally, writing programs to generate programs presents an additional hurdle for
developers looking to pick up smart contract development. Tooling support for this is also suboptimal, for example, many
classes of errors resulting from the interaction between the procedural elements of the Python language and the PyTEAL
expression-building framework go unnoticed until the point of TEAL generation, or worse go completely unnoticed, and even
when PyTEAL can/does provide an error it can be difficult to understand.
Tealish provides a higher level procedural language, bearing a passing resemblance to Python, than compiles down to TEAL.
However, it’s still lower level than most developers are used to.
For example, the expression
1
+
2
+
3
is
not valid in tealish
.
Another difference vs a higher level language such as Python is that
functions can only be declared after the program
entry point logic
.
In essence, tealish abstracts away many difficulties with writing plain TEAL,
but it is still essentially more of a transpiler than a compiler.
Furthermore, whilst appearing to have syntax inspired by Python, it both adds and removes many fundamental syntax elements,
presenting an additional learning curve to developers looking to learn blockchain development on Algorand.
Being a bespoke language also means it has a much smaller ecosystem of tooling built around it compared to languages like
Python or JavaScript.
To most developers, the Python programming language needs no introduction. First released in 1991, it’s popularity has
grown steadily over the decades, and as of June 2023 it is consistently ranked as either the most popular langauge,
or second most popular following JavaScript:
GitHub 2022
StackOverflow 2023
Tiobe
PYPL
The AlgoKit project is an Algorand Foundation initiative to improve the developer experience on Algorand. Within this
broad remit, two of the key
principles
are to “meet developers where they are” and “leverage existing ecosystem”.
Building a compiler that allows developers to write smart contracts using an idiomatic subset of a high level language
such as Python would make great strides towards both of these goals.
Wyvern was the original internal code name for just such a compiler (now called Puya), one that will transform Python code into valid TEAL
smart contracts. In line with the principle of meeting developers where they are, and recognising the popularity of
JavaScript and TypeScript, a parallel initiative to build a TypeScript to TEAL compiler is
also underway
.
Principles
¶
The principles listed here should form the basis of our decision-making, both in the design and implementation.
Least surprise
¶
Our primary objective is to assist developers in creating accurate smart contracts right from the
start. The often immutable nature of these contracts - although not always the case - and the
substantial financial value they frequently safeguard, underlines the importance of this goal.
This principle ensures that the code behaves as anticipated by the developer. Specifically, if
you’re a Python developer writing Python smart contract code, you can expect the code to behave
identically to its execution in a standard Python environment.
Furthermore, we believe in promoting explicitness and correctness in contract code and its
associated typing. This approach reduces potential errors and enhances the overall integrity of our
smart contracts. Our commitment is to provide a user-friendly platform that aligns with the
developer’s intuition and experience, ultimately simplifying their work and minimizing the
potential for mistakes.
Inherited from AlgoKit
¶
As a part of the AlgoKit project, the principles outlined
there
also apply - to the extent that this project is just one component of AlgoKit.
“Leverage existing ecosystem”
¶
AlgoKit functionality gets into the hands of Algorand developers quickly by building on top of the
existing ecosystem wherever possible and aligned to these principles.
In order to leverage as much existing Python tooling as possible, we should strive to maintain the highest level of
compatibility with the Python language (and the reference implementation: CPython).
“Meet developers where they are”
¶
Make Blockchain development mainstream by giving all developers an idiomatic development experience in the operating
system, IDE and language they are comfortable with so they can dive in quickly and have less they need to learn before
being productive.
Python is a very idiomatic language. We should embrace accepted patterns and practices as much as possible,
such as those listed in
PEP-20
(aka “The Zen of Python”).
“Extensible”
¶
Be extensible for community contribution rather than stifling innovation, bottle-necking all changes through the
Algorand Foundation and preventing the opportunity for other ecosystems being represented (e.g. Go, Rust, etc.).
This helps make developers feel welcome and is part of the developer experience, plus it makes it easier to add
features sustainably
One way to support this principle in the broader AlgoKit context is by building in a mechanism for reusing
common code between smart contracts, to allow the community to build their own Python packages.
“Sustainable”
¶
AlgoKit should be built in a flexible fashion with long-term maintenance in mind. Updates to latest patches in
dependencies, Algorand protocol development updates, and community contributions and feedback will all feed in to the
evolution of the software.
Taking this principle further, ensuring the compiler is well-designed (e.g. frontend backend separation,
with a well-thought-out IR) will help with maintaining and improving the implementation over time. For example,
adding in new TEAL language features will be easier, same for implementing new optimisation strategies.
Looking to the future, best practices for smart contract development are rapidly evolving. We shouldn’t tie the
implementation too tightly to a current standard such as ARC-4 - although in that specific example, we would still
aim for first class support, but it shouldn’t be assumed as the only way to write smart contracts.
“Modular components”
¶
Solution components should be modular and loosely coupled to facilitate efficient parallel development by small,
effective teams, reduced architectural complexity and allowing developers to pick and choose the specific tools and
capabilities they want to use based on their needs and what they are comfortable with.
We will focus on the language and compiler design itself.
An example of a very useful feature, that is strongly related but could be implemented separately instead,
is the ability to run the users code in a unit-testing context, without compilation+deployment first.
This would require implementing in Python some level of simulation of Algorand Nodes / AVM behaviour.
“Secure by default”
¶
Include defaults, patterns and tooling that help developers write secure code and reduce the likelihood of security
incidents in the Algorand ecosystem. This solution should help Algorand be the most secure Blockchain ecosystem.
Enforcing security (which is multi-faceted) at a compiler level is difficult, and is some cases impossible.
The best application of this principle here is to support auditing, which is important and nuanced enough to be
listed below as a separate principle.
“Cohesive developer tool suite” + “Seamless onramp”
¶
Cohesive developer tool suite: Using AlgoKit should feel professional and cohesive, like it was designed to work
together, for the developer; not against them. Developers are guided towards delivering end-to-end, high quality
outcomes on MainNet so they and Algorand are more likely to be successful.
Seamless onramp: New developers have a seamless experience to get started and they are guided into a pit of success
with best practices, supported by great training collateral; you should be able to go from nothing to debugging code
in 5 minutes.
These principles relate more to AlgoKit as a whole, so we can respect them by considering the impacts of our decisions
there more broadly.
Abstraction without obfuscation
¶
Algorand Python is a high level language, with support for things such as branching logic, operator precedence, etc.,
and not a set of “macros” for generating TEAL. As such, developers will not be able to directly influence specific TEAL
output, if this is desirable a language such as
Tealish
is more appropriate.
Whilst this will abstract away certain aspects of the underlying TEAL language, there are certain AVM concerns
(such as op code budgets) that should not be abstracted away. That said, we should strive to generate code this is
cost-effective and unsurprising. Python mechanisms such as dynamic (runtime) dispatch, and also many of its builtin
functions on types such as
str
that are taken for granted, would require large amounts of ops compared to the
Python code it represents.
Support auditing
¶
Auditing is a critical part of the security process for deploying smart contracts. We want to support this function,
and can do so in two ways:
By ensuring the same Python code as input generates identical output each time the compiler
is run regardless of the system it’s running on. This is what might be termed
Output stability
.
Ensuring a consistent output regardless of the system it’s run on (assuming the same compiler version), means that
auditing the lower level (ie TEAL) code is possible.
Although auditing the TEAL code should be possible, being able to easily identify and relate it back to the higher level
code can make auditing the contract logic simpler and easier.
Revolution, not evolution
¶
This is a new and groundbreaking way of developing for Algorand, and not a continuation of the PyTEAL/Beaker approach.
By allowing developers to write procedural code, as opposed to constructing an expression tree,
we can (among other things) significantly reduce the barrier to entry for developing smart contracts for the Algorand platform.
Since the programming paradigm will be fundamentally different, providing a smooth migration experience from PyTEAL
to this new world is not an intended goal, and shouldn’t be a factor in our decisions. For example, it is not a goal of
this project to produce a step-by-step “migrating from PyTEAL” document, as it is not a requirement for users to
switch to this new paradigm in the short to medium term - support for PyTEAL should continue in parallel.
Next
API Reference
Previous
Unsupported Python features
Copyright © 2024, Algorand Foundation
Made with
Sphinx
and
@pradyunsg
's
Furo |
|
Back to top
View this page
Toggle Light / Dark / Auto color theme
Toggle table of contents sidebar
API Reference
¶
algopy
Package Contents
Classes
Functions
Data
API
ARC4Contract
Account
Application
Asset
BigUInt
Box
BoxMap
BoxRef
Bytes
BytesBacked
CompiledContract
CompiledLogicSig
Contract
Global
GlobalState
LocalState
LogicSig
OnCompleteAction
OpUpFeeSource
StateTotals
String
TemplateVar
TransactionType
Txn
UInt64
compile_contract()
compile_logicsig()
ensure_budget()
log()
logicsig()
subroutine()
uenumerate
urange
algopy.arc4
Module Contents
Classes
Functions
Data
API
ARC4Client
ARC4Contract
Address
BigUFixedNxM
BigUIntN
Bool
Byte
DynamicArray
DynamicBytes
StaticArray
String
Struct
Tuple
UFixedNxM
UInt128
UInt16
UInt256
UInt32
UInt512
UInt64
UInt8
UIntN
abi_call
abimethod()
arc4_create()
arc4_signature()
arc4_update()
baremethod()
emit()
algopy.gtxn
Module Contents
Classes
API
ApplicationCallTransaction
AssetConfigTransaction
AssetFreezeTransaction
AssetTransferTransaction
KeyRegistrationTransaction
PaymentTransaction
Transaction
TransactionBase
algopy.itxn
Module Contents
Classes
Functions
API
ApplicationCall
ApplicationCallInnerTransaction
AssetConfig
AssetConfigInnerTransaction
AssetFreeze
AssetFreezeInnerTransaction
AssetTransfer
AssetTransferInnerTransaction
InnerTransaction
InnerTransactionResult
KeyRegistration
KeyRegistrationInnerTransaction
Payment
PaymentInnerTransaction
submit_txns()
algopy.op
Module Contents
Classes
Functions
API
AcctParamsGet
AppGlobal
AppLocal
AppParamsGet
AssetHoldingGet
AssetParamsGet
Base64
Block
Box
EC
ECDSA
EllipticCurve
GITxn
GTxn
Global
ITxn
ITxnCreate
JsonRef
MiMCConfigurations
Scratch
Txn
VoterParamsGet
VrfVerify
addw()
app_opted_in()
arg()
balance()
base64_decode()
bitlen()
bsqrt()
btoi()
bzero()
concat()
divmodw()
divw()
ecdsa_pk_decompress()
ecdsa_pk_recover()
ecdsa_verify()
ed25519verify()
ed25519verify_bare()
err()
exit()
exp()
expw()
extract()
extract_uint16()
extract_uint32()
extract_uint64()
falcon_verify()
gaid()
getbit()
getbyte()
gload_bytes()
gload_uint64()
itob()
keccak256()
mimc()
min_balance()
mulw()
online_stake()
replace()
select_bytes()
select_uint64()
setbit_bytes()
setbit_uint64()
setbyte()
sha256()
sha3_256()
sha512_256()
shl()
shr()
sqrt()
substring()
sumhash512()
vrf_verify()
Next
algopy
Previous
Principles & Background
Copyright © 2024, Algorand Foundation
Made with
Sphinx
and
@pradyunsg
's
Furo |
|
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 |
|
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 |
|
Back to top
View this page
Toggle Light / Dark / Auto color theme
Toggle table of contents sidebar
algopy.gtxn
¶
Module Contents
¶
Classes
¶
ApplicationCallTransaction
Application call group transaction
AssetConfigTransaction
Asset config group transaction
AssetFreezeTransaction
Asset freeze group transaction
AssetTransferTransaction
Asset transfer group transaction
KeyRegistrationTransaction
Key registration group transaction
PaymentTransaction
Payment group transaction
Transaction
Group Transaction of any type
TransactionBase
Shared transaction properties
API
¶
class
algopy.gtxn.
ApplicationCallTransaction
(
group_index
:
algopy.UInt64
|
int
)
¶
Application call group transaction
Initialization
accounts
(
index
:
algopy.UInt64
|
int
,
/
)
→
algopy.Account
¶
Accounts listed in the ApplicationCall transaction
app_args
(
index
:
algopy.UInt64
|
int
,
/
)
→
algopy.Bytes
¶
Arguments passed to the application in the ApplicationCall transaction
property
app_id
:
algopy.Application
¶
ApplicationID from ApplicationCall transaction
property
approval_program
:
algopy.Bytes
¶
Approval program
approval_program_pages
(
index
:
algopy.UInt64
|
int
,
/
)
→
algopy.Bytes
¶
Approval Program as an array of pages
apps
(
index
:
algopy.UInt64
|
int
,
/
)
→
algopy.Application
¶
Foreign Apps listed in the ApplicationCall transaction
assets
(
index
:
algopy.UInt64
|
int
,
/
)
→
algopy.Asset
¶
Foreign Assets listed in the ApplicationCall transaction
property
clear_state_program
:
algopy.Bytes
¶
Clear State program
clear_state_program_pages
(
index
:
algopy.UInt64
|
int
,
/
)
→
algopy.Bytes
¶
Clear State Program as an array of pages
property
created_app
:
algopy.Application
¶
ApplicationID allocated by the creation of an application
property
extra_program_pages
:
algopy.UInt64
¶
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.
property
fee
:
algopy.UInt64
¶
microalgos
property
first_valid
:
algopy.UInt64
¶
round number
property
first_valid_time
:
algopy.UInt64
¶
UNIX timestamp of block before txn.FirstValid. Fails if negative
property
global_num_bytes
:
algopy.UInt64
¶
Number of global state byteslices in ApplicationCall
property
global_num_uint
:
algopy.UInt64
¶
Number of global state integers in ApplicationCall
property
group_index
:
algopy.UInt64
¶
Position of this transaction within an atomic transaction group.
A stand-alone transaction is implicitly element 0 in a group of 1
property
last_log
:
algopy.Bytes
¶
The last message emitted. Empty bytes if none were emitted. Application mode only
property
last_valid
:
algopy.UInt64
¶
round number
property
lease
:
algopy.Bytes
¶
32 byte lease value
property
local_num_bytes
:
algopy.UInt64
¶
Number of local state byteslices in ApplicationCall
property
local_num_uint
:
algopy.UInt64
¶
Number of local state integers in ApplicationCall
logs
(
index
:
algopy.UInt64
|
int
)
→
algopy.Bytes
¶
Log messages emitted by an application call
property
note
:
algopy.Bytes
¶
Any data up to 1024 bytes
property
num_accounts
:
algopy.UInt64
¶
Number of ApplicationArgs
property
num_app_args
:
algopy.UInt64
¶
Number of ApplicationArgs
property
num_approval_program_pages
:
algopy.UInt64
¶
Number of Approval Program pages
property
num_apps
:
algopy.UInt64
¶
Number of Applications
property
num_assets
:
algopy.UInt64
¶
Number of Assets
property
num_clear_state_program_pages
:
algopy.UInt64
¶
Number of Clear State Program pages
property
num_logs
:
algopy.UInt64
¶
Number of logs
property
on_completion
:
algopy.OnCompleteAction
¶
ApplicationCall transaction on completion action
property
rekey_to
:
algopy.Account
¶
32 byte Sender’s new AuthAddr
property
sender
:
algopy.Account
¶
32 byte address
property
txn_id
:
algopy.Bytes
¶
The computed ID for this transaction. 32 bytes.
property
type
:
algopy.TransactionType
¶
Transaction type as integer
property
type_bytes
:
algopy.Bytes
¶
Transaction type as bytes
class
algopy.gtxn.
AssetConfigTransaction
(
group_index
:
algopy.UInt64
|
int
)
¶
Asset config group transaction
Initialization
property
asset_name
:
algopy.Bytes
¶
The asset name
property
clawback
:
algopy.Account
¶
32 byte address
property
config_asset
:
algopy.Asset
¶
Asset ID in asset config transaction
property
created_asset
:
algopy.Asset
¶
Asset ID allocated by the creation of an ASA
property
decimals
:
algopy.UInt64
¶
Number of digits to display after the decimal place when displaying the asset
property
default_frozen
:
bool
¶
Whether the asset’s slots are frozen by default or not, 0 or 1
property
fee
:
algopy.UInt64
¶
microalgos
property
first_valid
:
algopy.UInt64
¶
round number
property
first_valid_time
:
algopy.UInt64
¶
UNIX timestamp of block before txn.FirstValid. Fails if negative
property
freeze
:
algopy.Account
¶
32 byte address
property
group_index
:
algopy.UInt64
¶
Position of this transaction within an atomic transaction group.
A stand-alone transaction is implicitly element 0 in a group of 1
property
last_valid
:
algopy.UInt64
¶
round number
property
lease
:
algopy.Bytes
¶
32 byte lease value
property
manager
:
algopy.Account
¶
32 byte address
property
metadata_hash
:
algopy.Bytes
¶
32 byte commitment to unspecified asset metadata
property
note
:
algopy.Bytes
¶
Any data up to 1024 bytes
property
rekey_to
:
algopy.Account
¶
32 byte Sender’s new AuthAddr
property
reserve
:
algopy.Account
¶
32 byte address
property
sender
:
algopy.Account
¶
32 byte address
property
total
:
algopy.UInt64
¶
Total number of units of this asset created
property
txn_id
:
algopy.Bytes
¶
The computed ID for this transaction. 32 bytes.
property
type
:
algopy.TransactionType
¶
Transaction type as integer
property
type_bytes
:
algopy.Bytes
¶
Transaction type as bytes
property
unit_name
:
algopy.Bytes
¶
Unit name of the asset
property
url
:
algopy.Bytes
¶
URL
class
algopy.gtxn.
AssetFreezeTransaction
(
group_index
:
algopy.UInt64
|
int
)
¶
Asset freeze group transaction
Initialization
property
fee
:
algopy.UInt64
¶
microalgos
property
first_valid
:
algopy.UInt64
¶
round number
property
first_valid_time
:
algopy.UInt64
¶
UNIX timestamp of block before txn.FirstValid. Fails if negative
property
freeze_account
:
algopy.Account
¶
32 byte address of the account whose asset slot is being frozen or un-frozen
property
freeze_asset
:
algopy.Asset
¶
Asset ID being frozen or un-frozen
property
frozen
:
bool
¶
The new frozen value, 0 or 1
property
group_index
:
algopy.UInt64
¶
Position of this transaction within an atomic transaction group.
A stand-alone transaction is implicitly element 0 in a group of 1
property
last_valid
:
algopy.UInt64
¶
round number
property
lease
:
algopy.Bytes
¶
32 byte lease value
property
note
:
algopy.Bytes
¶
Any data up to 1024 bytes
property
rekey_to
:
algopy.Account
¶
32 byte Sender’s new AuthAddr
property
sender
:
algopy.Account
¶
32 byte address
property
txn_id
:
algopy.Bytes
¶
The computed ID for this transaction. 32 bytes.
property
type
:
algopy.TransactionType
¶
Transaction type as integer
property
type_bytes
:
algopy.Bytes
¶
Transaction type as bytes
class
algopy.gtxn.
AssetTransferTransaction
(
group_index
:
algopy.UInt64
|
int
)
¶
Asset transfer group transaction
Initialization
property
asset_amount
:
algopy.UInt64
¶
value in Asset’s units
property
asset_close_to
:
algopy.Account
¶
32 byte address
property
asset_receiver
:
algopy.Account
¶
32 byte address
property
asset_sender
:
algopy.Account
¶
32 byte address. Source of assets if Sender is the Asset’s Clawback address.
property
fee
:
algopy.UInt64
¶
microalgos
property
first_valid
:
algopy.UInt64
¶
round number
property
first_valid_time
:
algopy.UInt64
¶
UNIX timestamp of block before txn.FirstValid. Fails if negative
property
group_index
:
algopy.UInt64
¶
Position of this transaction within an atomic transaction group.
A stand-alone transaction is implicitly element 0 in a group of 1
property
last_valid
:
algopy.UInt64
¶
round number
property
lease
:
algopy.Bytes
¶
32 byte lease value
property
note
:
algopy.Bytes
¶
Any data up to 1024 bytes
property
rekey_to
:
algopy.Account
¶
32 byte Sender’s new AuthAddr
property
sender
:
algopy.Account
¶
32 byte address
property
txn_id
:
algopy.Bytes
¶
The computed ID for this transaction. 32 bytes.
property
type
:
algopy.TransactionType
¶
Transaction type as integer
property
type_bytes
:
algopy.Bytes
¶
Transaction type as bytes
property
xfer_asset
:
algopy.Asset
¶
Asset ID
class
algopy.gtxn.
KeyRegistrationTransaction
(
group_index
:
algopy.UInt64
|
int
)
¶
Key registration group transaction
Initialization
property
fee
:
algopy.UInt64
¶
microalgos
property
first_valid
:
algopy.UInt64
¶
round number
property
first_valid_time
:
algopy.UInt64
¶
UNIX timestamp of block before txn.FirstValid. Fails if negative
property
group_index
:
algopy.UInt64
¶
Position of this transaction within an atomic transaction group.
A stand-alone transaction is implicitly element 0 in a group of 1
property
last_valid
:
algopy.UInt64
¶
round number
property
lease
:
algopy.Bytes
¶
32 byte lease value
property
non_participation
:
bool
¶
Marks an account nonparticipating for rewards
property
note
:
algopy.Bytes
¶
Any data up to 1024 bytes
property
rekey_to
:
algopy.Account
¶
32 byte Sender’s new AuthAddr
property
selection_key
:
algopy.Bytes
¶
32 byte address
property
sender
:
algopy.Account
¶
32 byte address
property
state_proof_key
:
algopy.Bytes
¶
64 byte state proof public key
property
txn_id
:
algopy.Bytes
¶
The computed ID for this transaction. 32 bytes.
property
type
:
algopy.TransactionType
¶
Transaction type as integer
property
type_bytes
:
algopy.Bytes
¶
Transaction type as bytes
property
vote_first
:
algopy.UInt64
¶
The first round that the participation key is valid.
property
vote_key
:
algopy.Bytes
¶
32 byte address
property
vote_key_dilution
:
algopy.UInt64
¶
Dilution for the 2-level participation key
property
vote_last
:
algopy.UInt64
¶
The last round that the participation key is valid.
class
algopy.gtxn.
PaymentTransaction
(
group_index
:
algopy.UInt64
|
int
)
¶
Payment group transaction
Initialization
property
amount
:
algopy.UInt64
¶
microalgos
property
close_remainder_to
:
algopy.Account
¶
32 byte address
property
fee
:
algopy.UInt64
¶
microalgos
property
first_valid
:
algopy.UInt64
¶
round number
property
first_valid_time
:
algopy.UInt64
¶
UNIX timestamp of block before txn.FirstValid. Fails if negative
property
group_index
:
algopy.UInt64
¶
Position of this transaction within an atomic transaction group.
A stand-alone transaction is implicitly element 0 in a group of 1
property
last_valid
:
algopy.UInt64
¶
round number
property
lease
:
algopy.Bytes
¶
32 byte lease value
property
note
:
algopy.Bytes
¶
Any data up to 1024 bytes
property
receiver
:
algopy.Account
¶
32 byte address
property
rekey_to
:
algopy.Account
¶
32 byte Sender’s new AuthAddr
property
sender
:
algopy.Account
¶
32 byte address
property
txn_id
:
algopy.Bytes
¶
The computed ID for this transaction. 32 bytes.
property
type
:
algopy.TransactionType
¶
Transaction type as integer
property
type_bytes
:
algopy.Bytes
¶
Transaction type as bytes
class
algopy.gtxn.
Transaction
(
group_index
:
algopy.UInt64
|
int
)
¶
Group Transaction of any type
Initialization
accounts
(
index
:
algopy.UInt64
|
int
,
/
)
→
algopy.Account
¶
Accounts listed in the ApplicationCall transaction
property
amount
:
algopy.UInt64
¶
microalgos
app_args
(
index
:
algopy.UInt64
|
int
,
/
)
→
algopy.Bytes
¶
Arguments passed to the application in the ApplicationCall transaction
property
app_id
:
algopy.Application
¶
ApplicationID from ApplicationCall transaction
property
approval_program
:
algopy.Bytes
¶
Approval program
approval_program_pages
(
index
:
algopy.UInt64
|
int
,
/
)
→
algopy.Bytes
¶
Approval Program as an array of pages
apps
(
index
:
algopy.UInt64
|
int
,
/
)
→
algopy.Application
¶
Foreign Apps listed in the ApplicationCall transaction
property
asset_amount
:
algopy.UInt64
¶
value in Asset’s units
property
asset_close_to
:
algopy.Account
¶
32 byte address
property
asset_name
:
algopy.Bytes
¶
The asset name
property
asset_receiver
:
algopy.Account
¶
32 byte address
property
asset_sender
:
algopy.Account
¶
32 byte address. Source of assets if Sender is the Asset’s Clawback address.
assets
(
index
:
algopy.UInt64
|
int
,
/
)
→
algopy.Asset
¶
Foreign Assets listed in the ApplicationCall transaction
property
clawback
:
algopy.Account
¶
32 byte address
property
clear_state_program
:
algopy.Bytes
¶
Clear State program
clear_state_program_pages
(
index
:
algopy.UInt64
|
int
,
/
)
→
algopy.Bytes
¶
Clear State Program as an array of pages
property
close_remainder_to
:
algopy.Account
¶
32 byte address
property
config_asset
:
algopy.Asset
¶
Asset ID in asset config transaction
property
created_app
:
algopy.Application
¶
ApplicationID allocated by the creation of an application
property
created_asset
:
algopy.Asset
¶
Asset ID allocated by the creation of an ASA
property
decimals
:
algopy.UInt64
¶
Number of digits to display after the decimal place when displaying the asset
property
default_frozen
:
bool
¶
Whether the asset’s slots are frozen by default or not, 0 or 1
property
extra_program_pages
:
algopy.UInt64
¶
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.
property
fee
:
algopy.UInt64
¶
microalgos
property
first_valid
:
algopy.UInt64
¶
round number
property
first_valid_time
:
algopy.UInt64
¶
UNIX timestamp of block before txn.FirstValid. Fails if negative
property
freeze
:
algopy.Account
¶
32 byte address
property
freeze_account
:
algopy.Account
¶
32 byte address of the account whose asset slot is being frozen or un-frozen
property
freeze_asset
:
algopy.Asset
¶
Asset ID being frozen or un-frozen
property
frozen
:
bool
¶
The new frozen value, 0 or 1
property
global_num_bytes
:
algopy.UInt64
¶
Number of global state byteslices in ApplicationCall
property
global_num_uint
:
algopy.UInt64
¶
Number of global state integers in ApplicationCall
property
group_index
:
algopy.UInt64
¶
Position of this transaction within an atomic transaction group.
A stand-alone transaction is implicitly element 0 in a group of 1
property
last_log
:
algopy.Bytes
¶
The last message emitted. Empty bytes if none were emitted. Application mode only
property
last_valid
:
algopy.UInt64
¶
round number
property
lease
:
algopy.Bytes
¶
32 byte lease value
property
local_num_bytes
:
algopy.UInt64
¶
Number of local state byteslices in ApplicationCall
property
local_num_uint
:
algopy.UInt64
¶
Number of local state integers in ApplicationCall
logs
(
index
:
algopy.UInt64
|
int
)
→
algopy.Bytes
¶
Log messages emitted by an application call
property
manager
:
algopy.Account
¶
32 byte address
property
metadata_hash
:
algopy.Bytes
¶
32 byte commitment to unspecified asset metadata
property
non_participation
:
bool
¶
Marks an account nonparticipating for rewards
property
note
:
algopy.Bytes
¶
Any data up to 1024 bytes
property
num_accounts
:
algopy.UInt64
¶
Number of ApplicationArgs
property
num_app_args
:
algopy.UInt64
¶
Number of ApplicationArgs
property
num_approval_program_pages
:
algopy.UInt64
¶
Number of Approval Program pages
property
num_apps
:
algopy.UInt64
¶
Number of Applications
property
num_assets
:
algopy.UInt64
¶
Number of Assets
property
num_clear_state_program_pages
:
algopy.UInt64
¶
Number of Clear State Program pages
property
num_logs
:
algopy.UInt64
¶
Number of logs
property
on_completion
:
algopy.OnCompleteAction
¶
ApplicationCall transaction on completion action
property
receiver
:
algopy.Account
¶
32 byte address
property
rekey_to
:
algopy.Account
¶
32 byte Sender’s new AuthAddr
property
reserve
:
algopy.Account
¶
32 byte address
property
selection_key
:
algopy.Bytes
¶
32 byte address
property
sender
:
algopy.Account
¶
32 byte address
property
state_proof_key
:
algopy.Bytes
¶
64 byte state proof public key
property
total
:
algopy.UInt64
¶
Total number of units of this asset created
property
txn_id
:
algopy.Bytes
¶
The computed ID for this transaction. 32 bytes.
property
type
:
algopy.TransactionType
¶
Transaction type as integer
property
type_bytes
:
algopy.Bytes
¶
Transaction type as bytes
property
unit_name
:
algopy.Bytes
¶
Unit name of the asset
property
url
:
algopy.Bytes
¶
URL
property
vote_first
:
algopy.UInt64
¶
The first round that the participation key is valid.
property
vote_key
:
algopy.Bytes
¶
32 byte address
property
vote_key_dilution
:
algopy.UInt64
¶
Dilution for the 2-level participation key
property
vote_last
:
algopy.UInt64
¶
The last round that the participation key is valid.
property
xfer_asset
:
algopy.Asset
¶
Asset ID
class
algopy.gtxn.
TransactionBase
¶
Shared transaction properties
property
fee
:
algopy.UInt64
¶
microalgos
property
first_valid
:
algopy.UInt64
¶
round number
property
first_valid_time
:
algopy.UInt64
¶
UNIX timestamp of block before txn.FirstValid. Fails if negative
property
group_index
:
algopy.UInt64
¶
Position of this transaction within an atomic transaction group.
A stand-alone transaction is implicitly element 0 in a group of 1
property
last_valid
:
algopy.UInt64
¶
round number
property
lease
:
algopy.Bytes
¶
32 byte lease value
property
note
:
algopy.Bytes
¶
Any data up to 1024 bytes
property
rekey_to
:
algopy.Account
¶
32 byte Sender’s new AuthAddr
property
sender
:
algopy.Account
¶
32 byte address
property
txn_id
:
algopy.Bytes
¶
The computed ID for this transaction. 32 bytes.
property
type
:
algopy.TransactionType
¶
Transaction type as integer
property
type_bytes
:
algopy.Bytes
¶
Transaction type as bytes
Next
algopy.itxn
Previous
algopy.arc4
Copyright © 2024, Algorand Foundation
Made with
Sphinx
and
@pradyunsg
's
Furo |
|
Back to top
View this page
Toggle Light / Dark / Auto color theme
Toggle table of contents sidebar
algopy.itxn
¶
Module Contents
¶
Classes
¶
ApplicationCall
Creates a set of fields used to submit an Application Call inner transaction
ApplicationCallInnerTransaction
Application Call inner transaction
AssetConfig
Creates a set of fields used to submit an Asset Config inner transaction
AssetConfigInnerTransaction
Asset Config inner transaction
AssetFreeze
Creates a set of fields used to submit a Asset Freeze inner transaction
AssetFreezeInnerTransaction
Asset Freeze inner transaction
AssetTransfer
Creates a set of fields used to submit an Asset Transfer inner transaction
AssetTransferInnerTransaction
Asset Transfer inner transaction
InnerTransaction
Creates a set of fields used to submit an inner transaction of any type
InnerTransactionResult
An inner transaction of any type
KeyRegistration
Creates a set of fields used to submit a Key Registration inner transaction
KeyRegistrationInnerTransaction
Key Registration inner transaction
Payment
Creates a set of fields used to submit a Payment inner transaction
PaymentInnerTransaction
Payment inner transaction
Functions
¶
submit_txns
Submits a group of up to 16 inner transactions parameters
API
¶
class
algopy.itxn.
ApplicationCall
(
*
,
app_id
:
algopy.Application
|
algopy.UInt64
|
int
=
...
,
approval_program
:
algopy.Bytes
|
bytes
|
tuple
[
algopy.Bytes
,
...
]
=
...
,
clear_state_program
:
algopy.Bytes
|
bytes
|
tuple
[
algopy.Bytes
,
...
]
=
...
,
on_completion
:
algopy.OnCompleteAction
|
algopy.UInt64
|
int
=
...
,
global_num_uint
:
algopy.UInt64
|
int
=
...
,
global_num_bytes
:
algopy.UInt64
|
int
=
...
,
local_num_uint
:
algopy.UInt64
|
int
=
...
,
local_num_bytes
:
algopy.UInt64
|
int
=
...
,
extra_program_pages
:
algopy.UInt64
|
int
=
...
,
app_args
:
tuple
[
object
,
...
]
=
...
,
accounts
:
tuple
[
algopy.Account
,
...
]
=
...
,
assets
:
tuple
[
algopy.Asset
,
...
]
=
...
,
apps
:
tuple
[
algopy.Application
,
...
]
=
...
,
sender
:
algopy.Account
|
str
=
...
,
fee
:
algopy.UInt64
|
int
=
0
,
note
:
algopy.String
|
algopy.Bytes
|
str
|
bytes
=
...
,
rekey_to
:
algopy.Account
|
str
=
...
,
)
¶
Creates a set of fields used to submit an Application Call inner transaction
Initialization
copy
(
)
→
Self
¶
Copies a set of inner transaction parameters
set
(
*
,
app_id
:
algopy.Application
|
algopy.UInt64
|
int
=
...
,
approval_program
:
algopy.Bytes
|
bytes
|
tuple
[
algopy.Bytes
,
...
]
=
...
,
clear_state_program
:
algopy.Bytes
|
bytes
|
tuple
[
algopy.Bytes
,
...
]
=
...
,
on_completion
:
algopy.OnCompleteAction
|
algopy.UInt64
|
int
=
...
,
global_num_uint
:
algopy.UInt64
|
int
=
...
,
global_num_bytes
:
algopy.UInt64
|
int
=
...
,
local_num_uint
:
algopy.UInt64
|
int
=
...
,
local_num_bytes
:
algopy.UInt64
|
int
=
...
,
extra_program_pages
:
algopy.UInt64
|
int
=
...
,
app_args
:
tuple
[
object
,
...
]
=
...
,
accounts
:
tuple
[
algopy.Account
,
...
]
=
...
,
assets
:
tuple
[
algopy.Asset
,
...
]
=
...
,
apps
:
tuple
[
algopy.Application
,
...
]
=
...
,
sender
:
algopy.Account
|
str
=
...
,
fee
:
algopy.UInt64
|
int
=
0
,
note
:
algopy.String
|
algopy.Bytes
|
str
|
bytes
=
...
,
rekey_to
:
algopy.Account
|
str
=
...
,
)
→
None
¶
Updates inner transaction parameter values
submit
(
)
→
algopy.itxn._TResult_co
¶
Submits inner transaction parameters and returns the resulting inner transaction
class
algopy.itxn.
ApplicationCallInnerTransaction
¶
Application Call inner transaction
accounts
(
index
:
algopy.UInt64
|
int
,
/
)
→
algopy.Account
¶
Accounts listed in the ApplicationCall transaction
app_args
(
index
:
algopy.UInt64
|
int
,
/
)
→
algopy.Bytes
¶
Arguments passed to the application in the ApplicationCall transaction
property
app_id
:
algopy.Application
¶
ApplicationID from ApplicationCall transaction
property
approval_program
:
algopy.Bytes
¶
Approval program
approval_program_pages
(
index
:
algopy.UInt64
|
int
,
/
)
→
algopy.Bytes
¶
Approval Program as an array of pages
apps
(
index
:
algopy.UInt64
|
int
,
/
)
→
algopy.Application
¶
Foreign Apps listed in the ApplicationCall transaction
assets
(
index
:
algopy.UInt64
|
int
,
/
)
→
algopy.Asset
¶
Foreign Assets listed in the ApplicationCall transaction
property
clear_state_program
:
algopy.Bytes
¶
Clear State program
clear_state_program_pages
(
index
:
algopy.UInt64
|
int
,
/
)
→
algopy.Bytes
¶
Clear State Program as an array of pages
property
created_app
:
algopy.Application
¶
ApplicationID allocated by the creation of an application
property
extra_program_pages
:
algopy.UInt64
¶
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.
property
fee
:
algopy.UInt64
¶
microalgos
property
first_valid
:
algopy.UInt64
¶
round number
property
first_valid_time
:
algopy.UInt64
¶
UNIX timestamp of block before txn.FirstValid. Fails if negative
property
global_num_bytes
:
algopy.UInt64
¶
Number of global state byteslices in ApplicationCall
property
global_num_uint
:
algopy.UInt64
¶
Number of global state integers in ApplicationCall
property
group_index
:
algopy.UInt64
¶
Position of this transaction within an atomic transaction group.
A stand-alone transaction is implicitly element 0 in a group of 1
property
last_log
:
algopy.Bytes
¶
The last message emitted. Empty bytes if none were emitted. Application mode only
property
last_valid
:
algopy.UInt64
¶
round number
property
lease
:
algopy.Bytes
¶
32 byte lease value
property
local_num_bytes
:
algopy.UInt64
¶
Number of local state byteslices in ApplicationCall
property
local_num_uint
:
algopy.UInt64
¶
Number of local state integers in ApplicationCall
logs
(
index
:
algopy.UInt64
|
int
)
→
algopy.Bytes
¶
Log messages emitted by an application call
property
note
:
algopy.Bytes
¶
Any data up to 1024 bytes
property
num_accounts
:
algopy.UInt64
¶
Number of ApplicationArgs
property
num_app_args
:
algopy.UInt64
¶
Number of ApplicationArgs
property
num_approval_program_pages
:
algopy.UInt64
¶
Number of Approval Program pages
property
num_apps
:
algopy.UInt64
¶
Number of Applications
property
num_assets
:
algopy.UInt64
¶
Number of Assets
property
num_clear_state_program_pages
:
algopy.UInt64
¶
Number of Clear State Program pages
property
num_logs
:
algopy.UInt64
¶
Number of logs
property
on_completion
:
algopy.OnCompleteAction
¶
ApplicationCall transaction on completion action
property
rekey_to
:
algopy.Account
¶
32 byte Sender’s new AuthAddr
property
sender
:
algopy.Account
¶
32 byte address
property
txn_id
:
algopy.Bytes
¶
The computed ID for this transaction. 32 bytes.
property
type
:
algopy.TransactionType
¶
Transaction type as integer
property
type_bytes
:
algopy.Bytes
¶
Transaction type as bytes
class
algopy.itxn.
AssetConfig
(
*
,
config_asset
:
algopy.Asset
|
algopy.UInt64
|
int
=
...
,
total
:
algopy.UInt64
|
int
=
...
,
unit_name
:
algopy.String
|
algopy.Bytes
|
str
|
bytes
=
...
,
asset_name
:
algopy.String
|
algopy.Bytes
|
str
|
bytes
=
...
,
decimals
:
algopy.UInt64
|
int
=
...
,
default_frozen
:
bool
=
...
,
url
:
algopy.String
|
algopy.Bytes
|
str
|
bytes
=
...
,
metadata_hash
:
algopy.Bytes
|
bytes
=
...
,
manager
:
algopy.Account
|
str
=
...
,
reserve
:
algopy.Account
|
str
=
...
,
freeze
:
algopy.Account
|
str
=
...
,
clawback
:
algopy.Account
|
str
=
...
,
sender
:
algopy.Account
|
str
=
...
,
fee
:
algopy.UInt64
|
int
=
0
,
note
:
algopy.String
|
algopy.Bytes
|
str
|
bytes
=
...
,
rekey_to
:
algopy.Account
|
str
=
...
,
)
¶
Creates a set of fields used to submit an Asset Config inner transaction
Initialization
copy
(
)
→
Self
¶
Copies a set of inner transaction parameters
set
(
*
,
config_asset
:
algopy.Asset
|
algopy.UInt64
|
int
=
...
,
total
:
algopy.UInt64
|
int
=
...
,
unit_name
:
algopy.String
|
algopy.Bytes
|
str
|
bytes
=
...
,
asset_name
:
algopy.String
|
algopy.Bytes
|
str
|
bytes
=
...
,
decimals
:
algopy.UInt64
|
int
=
...
,
default_frozen
:
bool
=
...
,
url
:
algopy.String
|
algopy.Bytes
|
str
|
bytes
=
...
,
metadata_hash
:
algopy.Bytes
|
bytes
=
...
,
manager
:
algopy.Account
|
str
=
...
,
reserve
:
algopy.Account
|
str
=
...
,
freeze
:
algopy.Account
|
str
=
...
,
clawback
:
algopy.Account
|
str
=
...
,
sender
:
algopy.Account
|
str
=
...
,
fee
:
algopy.UInt64
|
int
=
0
,
note
:
algopy.String
|
algopy.Bytes
|
str
|
bytes
=
...
,
rekey_to
:
algopy.Account
|
str
=
...
,
)
→
None
¶
Updates inner transaction parameter values
submit
(
)
→
algopy.itxn._TResult_co
¶
Submits inner transaction parameters and returns the resulting inner transaction
class
algopy.itxn.
AssetConfigInnerTransaction
¶
Asset Config inner transaction
property
asset_name
:
algopy.Bytes
¶
The asset name
property
clawback
:
algopy.Account
¶
32 byte address
property
config_asset
:
algopy.Asset
¶
Asset ID in asset config transaction
property
created_asset
:
algopy.Asset
¶
Asset ID allocated by the creation of an ASA
property
decimals
:
algopy.UInt64
¶
Number of digits to display after the decimal place when displaying the asset
property
default_frozen
:
bool
¶
Whether the asset’s slots are frozen by default or not, 0 or 1
property
fee
:
algopy.UInt64
¶
microalgos
property
first_valid
:
algopy.UInt64
¶
round number
property
first_valid_time
:
algopy.UInt64
¶
UNIX timestamp of block before txn.FirstValid. Fails if negative
property
freeze
:
algopy.Account
¶
32 byte address
property
group_index
:
algopy.UInt64
¶
Position of this transaction within an atomic transaction group.
A stand-alone transaction is implicitly element 0 in a group of 1
property
last_valid
:
algopy.UInt64
¶
round number
property
lease
:
algopy.Bytes
¶
32 byte lease value
property
manager
:
algopy.Account
¶
32 byte address
property
metadata_hash
:
algopy.Bytes
¶
32 byte commitment to unspecified asset metadata
property
note
:
algopy.Bytes
¶
Any data up to 1024 bytes
property
rekey_to
:
algopy.Account
¶
32 byte Sender’s new AuthAddr
property
reserve
:
algopy.Account
¶
32 byte address
property
sender
:
algopy.Account
¶
32 byte address
property
total
:
algopy.UInt64
¶
Total number of units of this asset created
property
txn_id
:
algopy.Bytes
¶
The computed ID for this transaction. 32 bytes.
property
type
:
algopy.TransactionType
¶
Transaction type as integer
property
type_bytes
:
algopy.Bytes
¶
Transaction type as bytes
property
unit_name
:
algopy.Bytes
¶
Unit name of the asset
property
url
:
algopy.Bytes
¶
URL
class
algopy.itxn.
AssetFreeze
(
*
,
freeze_asset
:
algopy.Asset
|
algopy.UInt64
|
int
,
freeze_account
:
algopy.Account
|
str
,
frozen
:
bool
,
sender
:
algopy.Account
|
str
=
...
,
fee
:
algopy.UInt64
|
int
=
0
,
note
:
algopy.String
|
algopy.Bytes
|
str
|
bytes
=
...
,
rekey_to
:
algopy.Account
|
str
=
...
,
)
¶
Creates a set of fields used to submit a Asset Freeze inner transaction
Initialization
copy
(
)
→
Self
¶
Copies a set of inner transaction parameters
set
(
*
,
freeze_asset
:
algopy.Asset
|
algopy.UInt64
|
int
=
...
,
freeze_account
:
algopy.Account
|
str
=
...
,
frozen
:
bool
=
...
,
sender
:
algopy.Account
|
str
=
...
,
fee
:
algopy.UInt64
|
int
=
0
,
note
:
algopy.String
|
algopy.Bytes
|
str
|
bytes
=
...
,
rekey_to
:
algopy.Account
|
str
=
...
,
)
→
None
¶
Updates inner transaction parameter values
submit
(
)
→
algopy.itxn._TResult_co
¶
Submits inner transaction parameters and returns the resulting inner transaction
class
algopy.itxn.
AssetFreezeInnerTransaction
¶
Asset Freeze inner transaction
property
fee
:
algopy.UInt64
¶
microalgos
property
first_valid
:
algopy.UInt64
¶
round number
property
first_valid_time
:
algopy.UInt64
¶
UNIX timestamp of block before txn.FirstValid. Fails if negative
property
freeze_account
:
algopy.Account
¶
32 byte address of the account whose asset slot is being frozen or un-frozen
property
freeze_asset
:
algopy.Asset
¶
Asset ID being frozen or un-frozen
property
frozen
:
bool
¶
The new frozen value, 0 or 1
property
group_index
:
algopy.UInt64
¶
Position of this transaction within an atomic transaction group.
A stand-alone transaction is implicitly element 0 in a group of 1
property
last_valid
:
algopy.UInt64
¶
round number
property
lease
:
algopy.Bytes
¶
32 byte lease value
property
note
:
algopy.Bytes
¶
Any data up to 1024 bytes
property
rekey_to
:
algopy.Account
¶
32 byte Sender’s new AuthAddr
property
sender
:
algopy.Account
¶
32 byte address
property
txn_id
:
algopy.Bytes
¶
The computed ID for this transaction. 32 bytes.
property
type
:
algopy.TransactionType
¶
Transaction type as integer
property
type_bytes
:
algopy.Bytes
¶
Transaction type as bytes
class
algopy.itxn.
AssetTransfer
(
*
,
xfer_asset
:
algopy.Asset
|
algopy.UInt64
|
int
,
asset_receiver
:
algopy.Account
|
str
,
asset_amount
:
algopy.UInt64
|
int
=
...
,
asset_sender
:
algopy.Account
|
str
=
...
,
asset_close_to
:
algopy.Account
|
str
=
...
,
sender
:
algopy.Account
|
str
=
...
,
fee
:
algopy.UInt64
|
int
=
0
,
note
:
algopy.String
|
algopy.Bytes
|
str
|
bytes
=
...
,
rekey_to
:
algopy.Account
|
str
=
...
,
)
¶
Creates a set of fields used to submit an Asset Transfer inner transaction
Initialization
copy
(
)
→
Self
¶
Copies a set of inner transaction parameters
set
(
*
,
xfer_asset
:
algopy.Asset
|
algopy.UInt64
|
int
=
...
,
asset_amount
:
algopy.UInt64
|
int
=
...
,
asset_sender
:
algopy.Account
|
str
=
...
,
asset_receiver
:
algopy.Account
|
str
=
...
,
asset_close_to
:
algopy.Account
|
str
=
...
,
sender
:
algopy.Account
|
str
=
...
,
fee
:
algopy.UInt64
|
int
=
0
,
note
:
algopy.String
|
algopy.Bytes
|
str
|
bytes
=
...
,
rekey_to
:
algopy.Account
|
str
=
...
,
)
→
None
¶
Updates transaction parameter values
submit
(
)
→
algopy.itxn._TResult_co
¶
Submits inner transaction parameters and returns the resulting inner transaction
class
algopy.itxn.
AssetTransferInnerTransaction
¶
Asset Transfer inner transaction
property
asset_amount
:
algopy.UInt64
¶
value in Asset’s units
property
asset_close_to
:
algopy.Account
¶
32 byte address
property
asset_receiver
:
algopy.Account
¶
32 byte address
property
asset_sender
:
algopy.Account
¶
32 byte address. Source of assets if Sender is the Asset’s Clawback address.
property
fee
:
algopy.UInt64
¶
microalgos
property
first_valid
:
algopy.UInt64
¶
round number
property
first_valid_time
:
algopy.UInt64
¶
UNIX timestamp of block before txn.FirstValid. Fails if negative
property
group_index
:
algopy.UInt64
¶
Position of this transaction within an atomic transaction group.
A stand-alone transaction is implicitly element 0 in a group of 1
property
last_valid
:
algopy.UInt64
¶
round number
property
lease
:
algopy.Bytes
¶
32 byte lease value
property
note
:
algopy.Bytes
¶
Any data up to 1024 bytes
property
rekey_to
:
algopy.Account
¶
32 byte Sender’s new AuthAddr
property
sender
:
algopy.Account
¶
32 byte address
property
txn_id
:
algopy.Bytes
¶
The computed ID for this transaction. 32 bytes.
property
type
:
algopy.TransactionType
¶
Transaction type as integer
property
type_bytes
:
algopy.Bytes
¶
Transaction type as bytes
property
xfer_asset
:
algopy.Asset
¶
Asset ID
class
algopy.itxn.
InnerTransaction
(
*
,
type
:
algopy.TransactionType
,
receiver
:
algopy.Account
|
str
=
...
,
amount
:
algopy.UInt64
|
int
=
...
,
close_remainder_to
:
algopy.Account
|
str
=
...
,
vote_key
:
algopy.Bytes
|
bytes
=
...
,
selection_key
:
algopy.Bytes
|
bytes
=
...
,
vote_first
:
algopy.UInt64
|
int
=
...
,
vote_last
:
algopy.UInt64
|
int
=
...
,
vote_key_dilution
:
algopy.UInt64
|
int
=
...
,
non_participation
:
algopy.UInt64
|
int
|
bool
=
...
,
state_proof_key
:
algopy.Bytes
|
bytes
=
...
,
config_asset
:
algopy.Asset
|
algopy.UInt64
|
int
=
...
,
total
:
algopy.UInt64
|
int
=
...
,
unit_name
:
algopy.String
|
algopy.Bytes
|
str
|
bytes
=
...
,
asset_name
:
algopy.String
|
algopy.Bytes
|
str
|
bytes
=
...
,
decimals
:
algopy.UInt64
|
int
=
...
,
default_frozen
:
bool
=
...
,
url
:
algopy.String
|
algopy.Bytes
|
bytes
|
str
=
...
,
metadata_hash
:
algopy.Bytes
|
bytes
=
...
,
manager
:
algopy.Account
|
str
=
...
,
reserve
:
algopy.Account
|
str
=
...
,
freeze
:
algopy.Account
|
str
=
...
,
clawback
:
algopy.Account
|
str
=
...
,
xfer_asset
:
algopy.Asset
|
algopy.UInt64
|
int
=
...
,
asset_amount
:
algopy.UInt64
|
int
=
...
,
asset_sender
:
algopy.Account
|
str
=
...
,
asset_receiver
:
algopy.Account
|
str
=
...
,
asset_close_to
:
algopy.Account
|
str
=
...
,
freeze_asset
:
algopy.Asset
|
algopy.UInt64
|
int
=
...
,
freeze_account
:
algopy.Account
|
str
=
...
,
frozen
:
bool
=
...
,
app_id
:
algopy.Application
|
algopy.UInt64
|
int
=
...
,
approval_program
:
algopy.Bytes
|
bytes
|
tuple
[
algopy.Bytes
,
...
]
=
...
,
clear_state_program
:
algopy.Bytes
|
bytes
|
tuple
[
algopy.Bytes
,
...
]
=
...
,
on_completion
:
algopy.OnCompleteAction
|
algopy.UInt64
|
int
=
...
,
global_num_uint
:
algopy.UInt64
|
int
=
...
,
global_num_bytes
:
algopy.UInt64
|
int
=
...
,
local_num_uint
:
algopy.UInt64
|
int
=
...
,
local_num_bytes
:
algopy.UInt64
|
int
=
...
,
extra_program_pages
:
algopy.UInt64
|
int
=
...
,
app_args
:
tuple
[
object
,
...
]
=
...
,
accounts
:
tuple
[
algopy.Account
,
...
]
=
...
,
assets
:
tuple
[
algopy.Asset
,
...
]
=
...
,
apps
:
tuple
[
algopy.Application
,
...
]
=
...
,
sender
:
algopy.Account
|
str
=
...
,
fee
:
algopy.UInt64
|
int
=
0
,
note
:
algopy.String
|
algopy.Bytes
|
str
|
bytes
=
...
,
rekey_to
:
algopy.Account
|
str
=
...
,
)
¶
Creates a set of fields used to submit an inner transaction of any type
Initialization
copy
(
)
→
Self
¶
Copies a set of inner transaction parameters
set
(
*
,
type
:
algopy.TransactionType
=
...
,
receiver
:
algopy.Account
|
str
=
...
,
amount
:
algopy.UInt64
|
int
=
...
,
close_remainder_to
:
algopy.Account
|
str
=
...
,
vote_key
:
algopy.Bytes
|
bytes
=
...
,
selection_key
:
algopy.Bytes
|
bytes
=
...
,
vote_first
:
algopy.UInt64
|
int
=
...
,
vote_last
:
algopy.UInt64
|
int
=
...
,
vote_key_dilution
:
algopy.UInt64
|
int
=
...
,
non_participation
:
algopy.UInt64
|
int
|
bool
=
...
,
state_proof_key
:
algopy.Bytes
|
bytes
=
...
,
config_asset
:
algopy.Asset
|
algopy.UInt64
|
int
=
...
,
total
:
algopy.UInt64
|
int
=
...
,
unit_name
:
algopy.String
|
algopy.Bytes
|
str
|
bytes
=
...
,
asset_name
:
algopy.String
|
algopy.Bytes
|
str
|
bytes
=
...
,
decimals
:
algopy.UInt64
|
int
=
...
,
default_frozen
:
bool
=
...
,
url
:
algopy.String
|
algopy.Bytes
|
bytes
|
str
=
...
,
metadata_hash
:
algopy.Bytes
|
bytes
=
...
,
manager
:
algopy.Account
|
str
=
...
,
reserve
:
algopy.Account
|
str
=
...
,
freeze
:
algopy.Account
|
str
=
...
,
clawback
:
algopy.Account
|
str
=
...
,
xfer_asset
:
algopy.Asset
|
algopy.UInt64
|
int
=
...
,
asset_amount
:
algopy.UInt64
|
int
=
...
,
asset_sender
:
algopy.Account
|
str
=
...
,
asset_receiver
:
algopy.Account
|
str
=
...
,
asset_close_to
:
algopy.Account
|
str
=
...
,
freeze_asset
:
algopy.Asset
|
algopy.UInt64
|
int
=
...
,
freeze_account
:
algopy.Account
|
str
=
...
,
frozen
:
bool
=
...
,
app_id
:
algopy.Application
|
algopy.UInt64
|
int
=
...
,
approval_program
:
algopy.Bytes
|
bytes
|
tuple
[
algopy.Bytes
,
...
]
=
...
,
clear_state_program
:
algopy.Bytes
|
bytes
|
tuple
[
algopy.Bytes
,
...
]
=
...
,
on_completion
:
algopy.OnCompleteAction
|
algopy.UInt64
|
int
=
...
,
global_num_uint
:
algopy.UInt64
|
int
=
...
,
global_num_bytes
:
algopy.UInt64
|
int
=
...
,
local_num_uint
:
algopy.UInt64
|
int
=
...
,
local_num_bytes
:
algopy.UInt64
|
int
=
...
,
extra_program_pages
:
algopy.UInt64
|
int
=
...
,
app_args
:
tuple
[
object
,
...
]
=
...
,
accounts
:
tuple
[
algopy.Account
,
...
]
=
...
,
assets
:
tuple
[
algopy.Asset
,
...
]
=
...
,
apps
:
tuple
[
algopy.Application
,
...
]
=
...
,
sender
:
algopy.Account
|
str
=
...
,
fee
:
algopy.UInt64
|
int
=
0
,
note
:
algopy.String
|
algopy.Bytes
|
str
|
bytes
=
...
,
rekey_to
:
algopy.Account
|
str
=
...
,
)
→
None
¶
Updates inner transaction parameter values
submit
(
)
→
algopy.itxn._TResult_co
¶
Submits inner transaction parameters and returns the resulting inner transaction
class
algopy.itxn.
InnerTransactionResult
¶
An inner transaction of any type
accounts
(
index
:
algopy.UInt64
|
int
,
/
)
→
algopy.Account
¶
Accounts listed in the ApplicationCall transaction
property
amount
:
algopy.UInt64
¶
microalgos
app_args
(
index
:
algopy.UInt64
|
int
,
/
)
→
algopy.Bytes
¶
Arguments passed to the application in the ApplicationCall transaction
property
app_id
:
algopy.Application
¶
ApplicationID from ApplicationCall transaction
property
approval_program
:
algopy.Bytes
¶
Approval program
approval_program_pages
(
index
:
algopy.UInt64
|
int
,
/
)
→
algopy.Bytes
¶
Approval Program as an array of pages
apps
(
index
:
algopy.UInt64
|
int
,
/
)
→
algopy.Application
¶
Foreign Apps listed in the ApplicationCall transaction
property
asset_amount
:
algopy.UInt64
¶
value in Asset’s units
property
asset_close_to
:
algopy.Account
¶
32 byte address
property
asset_name
:
algopy.Bytes
¶
The asset name
property
asset_receiver
:
algopy.Account
¶
32 byte address
property
asset_sender
:
algopy.Account
¶
32 byte address. Source of assets if Sender is the Asset’s Clawback address.
assets
(
index
:
algopy.UInt64
|
int
,
/
)
→
algopy.Asset
¶
Foreign Assets listed in the ApplicationCall transaction
property
clawback
:
algopy.Account
¶
32 byte address
property
clear_state_program
:
algopy.Bytes
¶
Clear State program
clear_state_program_pages
(
index
:
algopy.UInt64
|
int
,
/
)
→
algopy.Bytes
¶
Clear State Program as an array of pages
property
close_remainder_to
:
algopy.Account
¶
32 byte address
property
config_asset
:
algopy.Asset
¶
Asset ID in asset config transaction
property
created_app
:
algopy.Application
¶
ApplicationID allocated by the creation of an application
property
created_asset
:
algopy.Asset
¶
Asset ID allocated by the creation of an ASA
property
decimals
:
algopy.UInt64
¶
Number of digits to display after the decimal place when displaying the asset
property
default_frozen
:
bool
¶
Whether the asset’s slots are frozen by default or not, 0 or 1
property
extra_program_pages
:
algopy.UInt64
¶
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.
property
fee
:
algopy.UInt64
¶
microalgos
property
first_valid
:
algopy.UInt64
¶
round number
property
first_valid_time
:
algopy.UInt64
¶
UNIX timestamp of block before txn.FirstValid. Fails if negative
property
freeze
:
algopy.Account
¶
32 byte address
property
freeze_account
:
algopy.Account
¶
32 byte address of the account whose asset slot is being frozen or un-frozen
property
freeze_asset
:
algopy.Asset
¶
Asset ID being frozen or un-frozen
property
frozen
:
bool
¶
The new frozen value, 0 or 1
property
global_num_bytes
:
algopy.UInt64
¶
Number of global state byteslices in ApplicationCall
property
global_num_uint
:
algopy.UInt64
¶
Number of global state integers in ApplicationCall
property
group_index
:
algopy.UInt64
¶
Position of this transaction within an atomic transaction group.
A stand-alone transaction is implicitly element 0 in a group of 1
property
last_log
:
algopy.Bytes
¶
The last message emitted. Empty bytes if none were emitted. Application mode only
property
last_valid
:
algopy.UInt64
¶
round number
property
lease
:
algopy.Bytes
¶
32 byte lease value
property
local_num_bytes
:
algopy.UInt64
¶
Number of local state byteslices in ApplicationCall
property
local_num_uint
:
algopy.UInt64
¶
Number of local state integers in ApplicationCall
logs
(
index
:
algopy.UInt64
|
int
)
→
algopy.Bytes
¶
Log messages emitted by an application call
property
manager
:
algopy.Account
¶
32 byte address
property
metadata_hash
:
algopy.Bytes
¶
32 byte commitment to unspecified asset metadata
property
non_participation
:
bool
¶
Marks an account nonparticipating for rewards
property
note
:
algopy.Bytes
¶
Any data up to 1024 bytes
property
num_accounts
:
algopy.UInt64
¶
Number of ApplicationArgs
property
num_app_args
:
algopy.UInt64
¶
Number of ApplicationArgs
property
num_approval_program_pages
:
algopy.UInt64
¶
Number of Approval Program pages
property
num_apps
:
algopy.UInt64
¶
Number of Applications
property
num_assets
:
algopy.UInt64
¶
Number of Assets
property
num_clear_state_program_pages
:
algopy.UInt64
¶
Number of Clear State Program pages
property
num_logs
:
algopy.UInt64
¶
Number of logs
property
on_completion
:
algopy.OnCompleteAction
¶
ApplicationCall transaction on completion action
property
receiver
:
algopy.Account
¶
32 byte address
property
rekey_to
:
algopy.Account
¶
32 byte Sender’s new AuthAddr
property
reserve
:
algopy.Account
¶
32 byte address
property
selection_key
:
algopy.Bytes
¶
32 byte address
property
sender
:
algopy.Account
¶
32 byte address
property
state_proof_key
:
algopy.Bytes
¶
64 byte state proof public key
property
total
:
algopy.UInt64
¶
Total number of units of this asset created
property
txn_id
:
algopy.Bytes
¶
The computed ID for this transaction. 32 bytes.
property
type
:
algopy.TransactionType
¶
Transaction type as integer
property
type_bytes
:
algopy.Bytes
¶
Transaction type as bytes
property
unit_name
:
algopy.Bytes
¶
Unit name of the asset
property
url
:
algopy.Bytes
¶
URL
property
vote_first
:
algopy.UInt64
¶
The first round that the participation key is valid.
property
vote_key
:
algopy.Bytes
¶
32 byte address
property
vote_key_dilution
:
algopy.UInt64
¶
Dilution for the 2-level participation key
property
vote_last
:
algopy.UInt64
¶
The last round that the participation key is valid.
property
xfer_asset
:
algopy.Asset
¶
Asset ID
class
algopy.itxn.
KeyRegistration
(
*
,
vote_key
:
algopy.Bytes
|
bytes
,
selection_key
:
algopy.Bytes
|
bytes
,
vote_first
:
algopy.UInt64
|
int
,
vote_last
:
algopy.UInt64
|
int
,
vote_key_dilution
:
algopy.UInt64
|
int
,
non_participation
:
algopy.UInt64
|
int
|
bool
=
...
,
state_proof_key
:
algopy.Bytes
|
bytes
=
...
,
sender
:
algopy.Account
|
str
=
...
,
fee
:
algopy.UInt64
|
int
=
0
,
note
:
algopy.String
|
algopy.Bytes
|
str
|
bytes
=
...
,
rekey_to
:
algopy.Account
|
str
=
...
,
)
¶
Creates a set of fields used to submit a Key Registration inner transaction
Initialization
copy
(
)
→
Self
¶
Copies a set of inner transaction parameters
set
(
*
,
vote_key
:
algopy.Bytes
|
bytes
=
...
,
selection_key
:
algopy.Bytes
|
bytes
=
...
,
vote_first
:
algopy.UInt64
|
int
=
...
,
vote_last
:
algopy.UInt64
|
int
=
...
,
vote_key_dilution
:
algopy.UInt64
|
int
=
...
,
non_participation
:
algopy.UInt64
|
int
|
bool
=
...
,
state_proof_key
:
algopy.Bytes
|
bytes
=
...
,
sender
:
algopy.Account
|
str
=
...
,
fee
:
algopy.UInt64
|
int
=
0
,
note
:
algopy.String
|
algopy.Bytes
|
str
|
bytes
=
...
,
rekey_to
:
algopy.Account
|
str
=
...
,
)
→
None
¶
Updates inner transaction parameter values
submit
(
)
→
algopy.itxn._TResult_co
¶
Submits inner transaction parameters and returns the resulting inner transaction
class
algopy.itxn.
KeyRegistrationInnerTransaction
¶
Key Registration inner transaction
property
fee
:
algopy.UInt64
¶
microalgos
property
first_valid
:
algopy.UInt64
¶
round number
property
first_valid_time
:
algopy.UInt64
¶
UNIX timestamp of block before txn.FirstValid. Fails if negative
property
group_index
:
algopy.UInt64
¶
Position of this transaction within an atomic transaction group.
A stand-alone transaction is implicitly element 0 in a group of 1
property
last_valid
:
algopy.UInt64
¶
round number
property
lease
:
algopy.Bytes
¶
32 byte lease value
property
non_participation
:
bool
¶
Marks an account nonparticipating for rewards
property
note
:
algopy.Bytes
¶
Any data up to 1024 bytes
property
rekey_to
:
algopy.Account
¶
32 byte Sender’s new AuthAddr
property
selection_key
:
algopy.Bytes
¶
32 byte address
property
sender
:
algopy.Account
¶
32 byte address
property
state_proof_key
:
algopy.Bytes
¶
64 byte state proof public key
property
txn_id
:
algopy.Bytes
¶
The computed ID for this transaction. 32 bytes.
property
type
:
algopy.TransactionType
¶
Transaction type as integer
property
type_bytes
:
algopy.Bytes
¶
Transaction type as bytes
property
vote_first
:
algopy.UInt64
¶
The first round that the participation key is valid.
property
vote_key
:
algopy.Bytes
¶
32 byte address
property
vote_key_dilution
:
algopy.UInt64
¶
Dilution for the 2-level participation key
property
vote_last
:
algopy.UInt64
¶
The last round that the participation key is valid.
class
algopy.itxn.
Payment
(
*
,
receiver
:
algopy.Account
|
str
,
amount
:
algopy.UInt64
|
int
=
...
,
close_remainder_to
:
algopy.Account
|
str
=
...
,
sender
:
algopy.Account
|
str
=
...
,
fee
:
algopy.UInt64
|
int
=
0
,
note
:
algopy.String
|
algopy.Bytes
|
str
|
bytes
=
...
,
rekey_to
:
algopy.Account
|
str
=
...
,
)
¶
Creates a set of fields used to submit a Payment inner transaction
Initialization
copy
(
)
→
Self
¶
Copies a set of inner transaction parameters
set
(
*
,
receiver
:
algopy.Account
|
str
=
...
,
amount
:
algopy.UInt64
|
int
=
...
,
close_remainder_to
:
algopy.Account
|
str
=
...
,
sender
:
algopy.Account
|
str
=
...
,
fee
:
algopy.UInt64
|
int
=
0
,
note
:
algopy.String
|
algopy.Bytes
|
str
|
bytes
=
...
,
rekey_to
:
algopy.Account
|
str
=
...
,
)
→
None
¶
Updates inner transaction parameter values
submit
(
)
→
algopy.itxn._TResult_co
¶
Submits inner transaction parameters and returns the resulting inner transaction
class
algopy.itxn.
PaymentInnerTransaction
¶
Payment inner transaction
property
amount
:
algopy.UInt64
¶
microalgos
property
close_remainder_to
:
algopy.Account
¶
32 byte address
property
fee
:
algopy.UInt64
¶
microalgos
property
first_valid
:
algopy.UInt64
¶
round number
property
first_valid_time
:
algopy.UInt64
¶
UNIX timestamp of block before txn.FirstValid. Fails if negative
property
group_index
:
algopy.UInt64
¶
Position of this transaction within an atomic transaction group.
A stand-alone transaction is implicitly element 0 in a group of 1
property
last_valid
:
algopy.UInt64
¶
round number
property
lease
:
algopy.Bytes
¶
32 byte lease value
property
note
:
algopy.Bytes
¶
Any data up to 1024 bytes
property
receiver
:
algopy.Account
¶
32 byte address
property
rekey_to
:
algopy.Account
¶
32 byte Sender’s new AuthAddr
property
sender
:
algopy.Account
¶
32 byte address
property
txn_id
:
algopy.Bytes
¶
The computed ID for this transaction. 32 bytes.
property
type
:
algopy.TransactionType
¶
Transaction type as integer
property
type_bytes
:
algopy.Bytes
¶
Transaction type as bytes
algopy.itxn.
submit_txns
(
_t1
:
algopy.itxn._InnerTransaction
[
algopy.itxn._T1
]
,
_t2
:
algopy.itxn._InnerTransaction
[
algopy.itxn._T2
]
,
_t3
:
algopy.itxn._InnerTransaction
[
algopy.itxn._T3
]
,
_t4
:
algopy.itxn._InnerTransaction
[
algopy.itxn._T4
]
,
_t5
:
algopy.itxn._InnerTransaction
[
algopy.itxn._T5
]
,
_t6
:
algopy.itxn._InnerTransaction
[
algopy.itxn._T6
]
,
_t7
:
algopy.itxn._InnerTransaction
[
algopy.itxn._T7
]
,
_t8
:
algopy.itxn._InnerTransaction
[
algopy.itxn._T8
]
,
_t9
:
algopy.itxn._InnerTransaction
[
algopy.itxn._T9
]
,
_t10
:
algopy.itxn._InnerTransaction
[
algopy.itxn._T10
]
,
_t11
:
algopy.itxn._InnerTransaction
[
algopy.itxn._T11
]
,
_t12
:
algopy.itxn._InnerTransaction
[
algopy.itxn._T12
]
,
_t13
:
algopy.itxn._InnerTransaction
[
algopy.itxn._T13
]
,
_t14
:
algopy.itxn._InnerTransaction
[
algopy.itxn._T14
]
,
_t15
:
algopy.itxn._InnerTransaction
[
algopy.itxn._T15
]
,
_t16
:
algopy.itxn._InnerTransaction
[
algopy.itxn._T16
]
,
/
,
)
→
tuple
[
algopy.itxn._T1
,
algopy.itxn._T2
,
algopy.itxn._T3
,
algopy.itxn._T4
,
algopy.itxn._T5
,
algopy.itxn._T6
,
algopy.itxn._T7
,
algopy.itxn._T8
,
algopy.itxn._T9
,
algopy.itxn._T10
,
algopy.itxn._T11
,
algopy.itxn._T12
,
algopy.itxn._T13
,
algopy.itxn._T14
,
algopy.itxn._T15
,
algopy.itxn._T16
]
¶
Submits a group of up to 16 inner transactions parameters
Returns
:
A tuple of the resulting inner transactions
Next
algopy.op
Previous
algopy.gtxn
Copyright © 2024, Algorand Foundation
Made with
Sphinx
and
@pradyunsg
's
Furo |
|
Back to top
View this page
Toggle Light / Dark / Auto color theme
Toggle table of contents sidebar
algopy.op
¶
Module Contents
¶
Classes
¶
AcctParamsGet
X is field F from account A. Y is 1 if A owns positive algos, else 0
Native TEAL op:
acct_params_get
AppGlobal
Get or modify Global app state
Native TEAL ops:
app_global_del
,
app_global_get
,
app_global_get_ex
,
app_global_put
AppLocal
Get or modify Local app state
Native TEAL ops:
app_local_del
,
app_local_get
,
app_local_get_ex
,
app_local_put
AppParamsGet
X is field F from app A. Y is 1 if A exists, else 0 params: Txn.ForeignApps offset or an
available
app id. Return: did_exist flag (1 if the application existed and 0 otherwise), value.
Native TEAL op:
app_params_get
AssetHoldingGet
X is field F from account A’s holding of asset B. Y is 1 if A is opted into B, else 0 params: Txn.Accounts offset (or, since v4, an
available
address), asset id (or, since v4, a Txn.ForeignAssets offset). Return: did_exist flag (1 if the asset existed and 0 otherwise), value.
Native TEAL op:
asset_holding_get
AssetParamsGet
X is field F from asset A. Y is 1 if A exists, else 0 params: Txn.ForeignAssets offset (or, since v4, an
available
asset id. Return: did_exist flag (1 if the asset existed and 0 otherwise), value.
Native TEAL op:
asset_params_get
Base64
Available values for the
base64
enum
Block
field F of block A. Fail unless A falls between txn.LastValid-1002 and txn.FirstValid (exclusive)
Native TEAL op:
block
Box
Get or modify box state
Native TEAL ops:
box_create
,
box_del
,
box_extract
,
box_get
,
box_len
,
box_put
,
box_replace
,
box_resize
,
box_splice
EC
Available values for the
EC
enum
ECDSA
Available values for the
ECDSA
enum
EllipticCurve
Elliptic Curve functions
Native TEAL ops:
ec_add
,
ec_map_to
,
ec_multi_scalar_mul
,
ec_pairing_check
,
ec_scalar_mul
,
ec_subgroup_check
GITxn
Get values for inner transaction in the last group submitted
Native TEAL ops:
gitxn
,
gitxnas
GTxn
Get values for transactions in the current group
Native TEAL ops:
gtxns
,
gtxnsas
Global
Get Global values
Native TEAL op:
global
ITxn
Get values for the last inner transaction
Native TEAL ops:
itxn
,
itxnas
ITxnCreate
Create inner transactions
Native TEAL ops:
itxn_begin
,
itxn_field
,
itxn_next
,
itxn_submit
JsonRef
key B’s value, of type R, from a
valid
utf-8 encoded json object A
Warning
: Usage should be restricted to very rare use cases, as JSON decoding is expensive and quite limited. In addition, JSON objects are large and not optimized for size. Almost all smart contracts should use simpler and smaller methods (such as the
ABI
. This opcode should only be used in cases where JSON is only available option, e.g. when a third-party only signs JSON.
Native TEAL op:
json_ref
MiMCConfigurations
Available values for the
Mimc
Configurations
enum
Scratch
Load or store scratch values
Native TEAL ops:
loads
,
stores
Txn
Get values for the current executing transaction
Native TEAL ops:
txn
,
txnas
VoterParamsGet
X is field F from online account A as of the balance round: 320 rounds before the current round. Y is 1 if A had positive algos online in the agreement round, else Y is 0 and X is a type specific zero-value
Native TEAL op:
voter_params_get
VrfVerify
Available values for the
vrf_verify
enum
Functions
¶
addw
A plus B as a 128-bit result. X is the carry-bit, Y is the low-order 64 bits.
app_opted_in
1 if account A is opted in to application B, else 0
params: Txn.Accounts offset (or, since v4, an
available
account address),
available
application id (or, since v4, a Txn.ForeignApps offset). Return: 1 if opted in and 0 otherwise.
arg
Ath LogicSig argument
balance
balance for account A, in microalgos. The balance is observed after the effects of previous transactions in the group, and after the fee for the current transaction is deducted. Changes caused by inner transactions are observable immediately following
itxn_submit
params: Txn.Accounts offset (or, since v4, an
available
account address),
available
application id (or, since v4, a Txn.ForeignApps offset). Return: value.
base64_decode
decode A which was base64-encoded using
encoding
E. Fail if A is not base64 encoded with encoding E
Warning
: Usage should be restricted to very rare use cases. In almost all cases, smart contracts should directly handle non-encoded byte-strings. This opcode should only be used in cases where base64 is the only available option, e.g. interoperability with a third-party that only signs base64 strings.
bitlen
The highest set bit in A. If A is a byte-array, it is interpreted as a big-endian unsigned integer. bitlen of 0 is 0, bitlen of 8 is 4
bitlen interprets arrays as big-endian integers, unlike setbit/getbit
bsqrt
The largest integer I such that I^2 <= A. A and I are interpreted as big-endian unsigned integers
btoi
converts big-endian byte array A to uint64. Fails if len(A) > 8. Padded by leading 0s if len(A) < 8.
btoi
fails if the input is longer than 8 bytes.
bzero
zero filled byte-array of length A
concat
join A and B
concat
fails if the result would be greater than 4096 bytes.
divmodw
W,X = (A,B / C,D); Y,Z = (A,B modulo C,D)
The notation J,K indicates that two uint64 values J and K are interpreted as a uint128 value, with J as the high uint64 and K the low.
divw
A,B / C. Fail if C == 0 or if result overflows.
The notation A,B indicates that A and B are interpreted as a uint128 value, with A as the high uint64 and B the low.
ecdsa_pk_decompress
decompress pubkey A into components X, Y
The 33 byte public key in a compressed form to be decompressed into X and Y (top) components. All values are big-endian encoded.
ecdsa_pk_recover
for (data A, recovery id B, signature C, D) recover a public key
S (top) and R elements of a signature, recovery id and data (bottom) are expected on the stack and used to deriver a public key. All values are big-endian encoded. The signed data must be 32 bytes long.
ecdsa_verify
for (data A, signature B, C and pubkey D, E) verify the signature of the data against the pubkey => {0 or 1}
The 32 byte Y-component of a public key is the last element on the stack, preceded by X-component of a pubkey, preceded by S and R components of a signature, preceded by the data that is fifth element on the stack. All values are big-endian encoded. The signed data must be 32 bytes long, and signatures in lower-S form are only accepted.
ed25519verify
for (data A, signature B, pubkey C) verify the signature of (“ProgData” || program_hash || data) against the pubkey => {0 or 1}
The 32 byte public key is the last element on the stack, preceded by the 64 byte signature at the second-to-last element on the stack, preceded by the data which was signed at the third-to-last element on the stack.
ed25519verify_bare
for (data A, signature B, pubkey C) verify the signature of the data against the pubkey => {0 or 1}
err
Fail immediately.
exit
use A as success value; end
exp
A raised to the Bth power. Fail if A == B == 0 and on overflow
expw
A raised to the Bth power as a 128-bit result in two uint64s. X is the high 64 bits, Y is the low. Fail if A == B == 0 or if the results exceeds 2^128-1
extract
A range of bytes from A starting at B up to but not including B+C. If B+C is larger than the array length, the program fails
extract3
can be called using
extract
with no immediates.
extract_uint16
A uint16 formed from a range of big-endian bytes from A starting at B up to but not including B+2. If B+2 is larger than the array length, the program fails
extract_uint32
A uint32 formed from a range of big-endian bytes from A starting at B up to but not including B+4. If B+4 is larger than the array length, the program fails
extract_uint64
A uint64 formed from a range of big-endian bytes from A starting at B up to but not including B+8. If B+8 is larger than the array length, the program fails
falcon_verify
for (data A, compressed-format signature B, pubkey C) verify the signature of data against the pubkey
Min AVM version: 12
gaid
ID of the asset or application created in the Ath transaction of the current group
gaids
fails unless the requested transaction created an asset or application and A < GroupIndex.
getbit
Bth bit of (byte-array or integer) A. If B is greater than or equal to the bit length of the value (8*byte length), the program fails
see explanation of bit ordering in setbit
getbyte
Bth byte of A, as an integer. If B is greater than or equal to the array length, the program fails
gload_bytes
Bth scratch space value of the Ath transaction in the current group
gload_uint64
Bth scratch space value of the Ath transaction in the current group
itob
converts uint64 A to big-endian byte array, always of length 8
keccak256
Keccak256 hash of value A, yields [32]byte
mimc
MiMC hash of scalars A, using curve and parameters specified by configuration C
A is a list of concatenated 32 byte big-endian unsigned integer scalars. Fail if A’s length is not a multiple of 32 or any element exceeds the curve modulus.
min_balance
minimum required balance for account A, in microalgos. Required balance is affected by ASA, App, and Box usage. When creating or opting into an app, the minimum balance grows before the app code runs, therefore the increase is visible there. When deleting or closing out, the minimum balance decreases after the app executes. Changes caused by inner transactions or box usage are observable immediately following the opcode effecting the change.
params: Txn.Accounts offset (or, since v4, an
available
account address),
available
application id (or, since v4, a Txn.ForeignApps offset). Return: value.
mulw
A times B as a 128-bit result in two uint64s. X is the high 64 bits, Y is the low
online_stake
the total online stake in the agreement round
Min AVM version: 11
replace
Copy of A with the bytes starting at B replaced by the bytes of C. Fails if B+len(C) exceeds len(A)
replace3
can be called using
replace
with no immediates.
select_bytes
selects one of two values based on top-of-stack: B if C != 0, else A
select_uint64
selects one of two values based on top-of-stack: B if C != 0, else A
setbit_bytes
Copy of (byte-array or integer) A, with the Bth bit set to (0 or 1) C. If B is greater than or equal to the bit length of the value (8*byte length), the program fails
When A is a uint64, index 0 is the least significant bit. Setting bit 3 to 1 on the integer 0 yields 8, or 2^3. When A is a byte array, index 0 is the leftmost bit of the leftmost byte. Setting bits 0 through 11 to 1 in a 4-byte-array of 0s yields the byte array 0xfff00000. Setting bit 3 to 1 on the 1-byte-array 0x00 yields the byte array 0x10.
setbit_uint64
Copy of (byte-array or integer) A, with the Bth bit set to (0 or 1) C. If B is greater than or equal to the bit length of the value (8*byte length), the program fails
When A is a uint64, index 0 is the least significant bit. Setting bit 3 to 1 on the integer 0 yields 8, or 2^3. When A is a byte array, index 0 is the leftmost bit of the leftmost byte. Setting bits 0 through 11 to 1 in a 4-byte-array of 0s yields the byte array 0xfff00000. Setting bit 3 to 1 on the 1-byte-array 0x00 yields the byte array 0x10.
setbyte
Copy of A with the Bth byte set to small integer (between 0..255) C. If B is greater than or equal to the array length, the program fails
sha256
SHA256 hash of value A, yields [32]byte
sha3_256
SHA3_256 hash of value A, yields [32]byte
sha512_256
SHA512_256 hash of value A, yields [32]byte
shl
A times 2^B, modulo 2^64
shr
A divided by 2^B
sqrt
The largest integer I such that I^2 <= A
substring
A range of bytes from A starting at B up to but not including C. If C < B, or either is larger than the array length, the program fails
sumhash512
sumhash512 of value A, yields [64]byte
Min AVM version: 12
vrf_verify
Verify the proof B of message A against pubkey C. Returns vrf output and verification flag.
VrfAlgorand
is the VRF used in Algorand. It is ECVRF-ED25519-SHA512-Elligator2, specified in the IETF internet draft
draft-irtf-cfrg-vrf-03
.
API
¶
class
algopy.op.
AcctParamsGet
¶
X is field F from account A. Y is 1 if A owns positive algos, else 0
Native TEAL op:
acct_params_get
static
acct_auth_addr
(
a
:
algopy.Account
|
algopy.UInt64
|
int
,
/
,
)
→
tuple
[
algopy.Account
,
bool
]
¶
Address the account is rekeyed to.
Native TEAL opcode:
acct_params_get
static
acct_balance
(
a
:
algopy.Account
|
algopy.UInt64
|
int
,
/
,
)
→
tuple
[
algopy.UInt64
,
bool
]
¶
Account balance in microalgos
Native TEAL opcode:
acct_params_get
static
acct_incentive_eligible
(
a
:
algopy.Account
|
algopy.UInt64
|
int
,
/
,
)
→
tuple
[
bool
,
bool
]
¶
Min AVM version: 11
Returns tuple[bool, bool]
:
Has this account opted into block payouts
Native TEAL opcode:
acct_params_get
static
acct_last_heartbeat
(
a
:
algopy.Account
|
algopy.UInt64
|
int
,
/
,
)
→
tuple
[
algopy.UInt64
,
bool
]
¶
Min AVM version: 11
Returns tuple[UInt64, bool]
:
The round number of the last block this account sent a heartbeat.
Native TEAL opcode:
acct_params_get
static
acct_last_proposed
(
a
:
algopy.Account
|
algopy.UInt64
|
int
,
/
,
)
→
tuple
[
algopy.UInt64
,
bool
]
¶
Min AVM version: 11
Returns tuple[UInt64, bool]
:
The round number of the last block this account proposed.
Native TEAL opcode:
acct_params_get
static
acct_min_balance
(
a
:
algopy.Account
|
algopy.UInt64
|
int
,
/
,
)
→
tuple
[
algopy.UInt64
,
bool
]
¶
Minimum required balance for account, in microalgos
Native TEAL opcode:
acct_params_get
static
acct_total_apps_created
(
a
:
algopy.Account
|
algopy.UInt64
|
int
,
/
,
)
→
tuple
[
algopy.UInt64
,
bool
]
¶
The number of existing apps created by this account.
Native TEAL opcode:
acct_params_get
static
acct_total_apps_opted_in
(
a
:
algopy.Account
|
algopy.UInt64
|
int
,
/
,
)
→
tuple
[
algopy.UInt64
,
bool
]
¶
The number of apps this account is opted into.
Native TEAL opcode:
acct_params_get
static
acct_total_assets
(
a
:
algopy.Account
|
algopy.UInt64
|
int
,
/
,
)
→
tuple
[
algopy.UInt64
,
bool
]
¶
The numbers of ASAs held by this account (including ASAs this account created).
Native TEAL opcode:
acct_params_get
static
acct_total_assets_created
(
a
:
algopy.Account
|
algopy.UInt64
|
int
,
/
,
)
→
tuple
[
algopy.UInt64
,
bool
]
¶
The number of existing ASAs created by this account.
Native TEAL opcode:
acct_params_get
static
acct_total_box_bytes
(
a
:
algopy.Account
|
algopy.UInt64
|
int
,
/
,
)
→
tuple
[
algopy.UInt64
,
bool
]
¶
The total number of bytes used by this account’s app’s box keys and values.
Native TEAL opcode:
acct_params_get
static
acct_total_boxes
(
a
:
algopy.Account
|
algopy.UInt64
|
int
,
/
,
)
→
tuple
[
algopy.UInt64
,
bool
]
¶
The number of existing boxes created by this account’s app.
Native TEAL opcode:
acct_params_get
static
acct_total_extra_app_pages
(
a
:
algopy.Account
|
algopy.UInt64
|
int
,
/
,
)
→
tuple
[
algopy.UInt64
,
bool
]
¶
The number of extra app code pages used by this account.
Native TEAL opcode:
acct_params_get
static
acct_total_num_byte_slice
(
a
:
algopy.Account
|
algopy.UInt64
|
int
,
/
,
)
→
tuple
[
algopy.UInt64
,
bool
]
¶
The total number of byte array values allocated by this account in Global and Local States.
Native TEAL opcode:
acct_params_get
static
acct_total_num_uint
(
a
:
algopy.Account
|
algopy.UInt64
|
int
,
/
,
)
→
tuple
[
algopy.UInt64
,
bool
]
¶
The total number of uint64 values allocated by this account in Global and Local States.
Native TEAL opcode:
acct_params_get
class
algopy.op.
AppGlobal
¶
Get or modify Global app state
Native TEAL ops:
app_global_del
,
app_global_get
,
app_global_get_ex
,
app_global_put
static
delete
(
a
:
algopy.Bytes
|
bytes
,
/
)
→
None
¶
delete key A from the global state of the current application
params: state key.
Deleting a key which is already absent has no effect on the application global state. (In particular, it does
not
cause the program to fail.)
Native TEAL opcode:
app_global_del
static
get_bytes
(
a
:
algopy.Bytes
|
bytes
,
/
)
→
algopy.Bytes
¶
global state of the key A in the current application
params: state key. Return: value. The value is zero (of type uint64) if the key does not exist.
Native TEAL opcode:
app_global_get
static
get_ex_bytes
(
a
:
algopy.Application
|
algopy.UInt64
|
int
,
b
:
algopy.Bytes
|
bytes
,
/
,
)
→
tuple
[
algopy.Bytes
,
bool
]
¶
X is the global state of application A, key B. Y is 1 if key existed, else 0
params: Txn.ForeignApps offset (or, since v4, an
available
application id), state key. Return: did_exist flag (top of the stack, 1 if the application and key existed and 0 otherwise), value. The value is zero (of type uint64) if the key does not exist.
Native TEAL opcode:
app_global_get_ex
static
get_ex_uint64
(
a
:
algopy.Application
|
algopy.UInt64
|
int
,
b
:
algopy.Bytes
|
bytes
,
/
,
)
→
tuple
[
algopy.UInt64
,
bool
]
¶
X is the global state of application A, key B. Y is 1 if key existed, else 0
params: Txn.ForeignApps offset (or, since v4, an
available
application id), state key. Return: did_exist flag (top of the stack, 1 if the application and key existed and 0 otherwise), value. The value is zero (of type uint64) if the key does not exist.
Native TEAL opcode:
app_global_get_ex
static
get_uint64
(
a
:
algopy.Bytes
|
bytes
,
/
)
→
algopy.UInt64
¶
global state of the key A in the current application
params: state key. Return: value. The value is zero (of type uint64) if the key does not exist.
Native TEAL opcode:
app_global_get
static
put
(
a
:
algopy.Bytes
|
bytes
,
b
:
algopy.Bytes
|
algopy.UInt64
|
bytes
|
int
,
/
,
)
→
None
¶
write B to key A in the global state of the current application
Native TEAL opcode:
app_global_put
class
algopy.op.
AppLocal
¶
Get or modify Local app state
Native TEAL ops:
app_local_del
,
app_local_get
,
app_local_get_ex
,
app_local_put
static
delete
(
a
:
algopy.Account
|
algopy.UInt64
|
int
,
b
:
algopy.Bytes
|
bytes
,
/
,
)
→
None
¶
delete key B from account A’s local state of the current application
params: Txn.Accounts offset (or, since v4, an
available
account address), state key.
Deleting a key which is already absent has no effect on the application local state. (In particular, it does
not
cause the program to fail.)
Native TEAL opcode:
app_local_del
static
get_bytes
(
a
:
algopy.Account
|
algopy.UInt64
|
int
,
b
:
algopy.Bytes
|
bytes
,
/
,
)
→
algopy.Bytes
¶
local state of the key B in the current application in account A
params: Txn.Accounts offset (or, since v4, an
available
account address), state key. Return: value. The value is zero (of type uint64) if the key does not exist.
Native TEAL opcode:
app_local_get
static
get_ex_bytes
(
a
:
algopy.Account
|
algopy.UInt64
|
int
,
b
:
algopy.Application
|
algopy.UInt64
|
int
,
c
:
algopy.Bytes
|
bytes
,
/
,
)
→
tuple
[
algopy.Bytes
,
bool
]
¶
X is the local state of application B, key C in account A. Y is 1 if key existed, else 0
params: Txn.Accounts offset (or, since v4, an
available
account address),
available
application id (or, since v4, a Txn.ForeignApps offset), state key. Return: did_exist flag (top of the stack, 1 if the application and key existed and 0 otherwise), value. The value is zero (of type uint64) if the key does not exist.
Native TEAL opcode:
app_local_get_ex
static
get_ex_uint64
(
a
:
algopy.Account
|
algopy.UInt64
|
int
,
b
:
algopy.Application
|
algopy.UInt64
|
int
,
c
:
algopy.Bytes
|
bytes
,
/
,
)
→
tuple
[
algopy.UInt64
,
bool
]
¶
X is the local state of application B, key C in account A. Y is 1 if key existed, else 0
params: Txn.Accounts offset (or, since v4, an
available
account address),
available
application id (or, since v4, a Txn.ForeignApps offset), state key. Return: did_exist flag (top of the stack, 1 if the application and key existed and 0 otherwise), value. The value is zero (of type uint64) if the key does not exist.
Native TEAL opcode:
app_local_get_ex
static
get_uint64
(
a
:
algopy.Account
|
algopy.UInt64
|
int
,
b
:
algopy.Bytes
|
bytes
,
/
,
)
→
algopy.UInt64
¶
local state of the key B in the current application in account A
params: Txn.Accounts offset (or, since v4, an
available
account address), state key. Return: value. The value is zero (of type uint64) if the key does not exist.
Native TEAL opcode:
app_local_get
static
put
(
a
:
algopy.Account
|
algopy.UInt64
|
int
,
b
:
algopy.Bytes
|
bytes
,
c
:
algopy.Bytes
|
algopy.UInt64
|
bytes
|
int
,
/
,
)
→
None
¶
write C to key B in account A’s local state of the current application
params: Txn.Accounts offset (or, since v4, an
available
account address), state key, value.
Native TEAL opcode:
app_local_put
class
algopy.op.
AppParamsGet
¶
X is field F from app A. Y is 1 if A exists, else 0 params: Txn.ForeignApps offset or an
available
app id. Return: did_exist flag (1 if the application existed and 0 otherwise), value.
Native TEAL op:
app_params_get
static
app_address
(
a
:
algopy.Application
|
algopy.UInt64
|
int
,
/
,
)
→
tuple
[
algopy.Account
,
bool
]
¶
Address for which this application has authority
Native TEAL opcode:
app_params_get
static
app_approval_program
(
a
:
algopy.Application
|
algopy.UInt64
|
int
,
/
,
)
→
tuple
[
algopy.Bytes
,
bool
]
¶
Bytecode of Approval Program
Native TEAL opcode:
app_params_get
static
app_clear_state_program
(
a
:
algopy.Application
|
algopy.UInt64
|
int
,
/
,
)
→
tuple
[
algopy.Bytes
,
bool
]
¶
Bytecode of Clear State Program
Native TEAL opcode:
app_params_get
static
app_creator
(
a
:
algopy.Application
|
algopy.UInt64
|
int
,
/
,
)
→
tuple
[
algopy.Account
,
bool
]
¶
Creator address
Native TEAL opcode:
app_params_get
static
app_extra_program_pages
(
a
:
algopy.Application
|
algopy.UInt64
|
int
,
/
,
)
→
tuple
[
algopy.UInt64
,
bool
]
¶
Number of Extra Program Pages of code space
Native TEAL opcode:
app_params_get
static
app_global_num_byte_slice
(
a
:
algopy.Application
|
algopy.UInt64
|
int
,
/
,
)
→
tuple
[
algopy.UInt64
,
bool
]
¶
Number of byte array values allowed in Global State
Native TEAL opcode:
app_params_get
static
app_global_num_uint
(
a
:
algopy.Application
|
algopy.UInt64
|
int
,
/
,
)
→
tuple
[
algopy.UInt64
,
bool
]
¶
Number of uint64 values allowed in Global State
Native TEAL opcode:
app_params_get
static
app_local_num_byte_slice
(
a
:
algopy.Application
|
algopy.UInt64
|
int
,
/
,
)
→
tuple
[
algopy.UInt64
,
bool
]
¶
Number of byte array values allowed in Local State
Native TEAL opcode:
app_params_get
static
app_local_num_uint
(
a
:
algopy.Application
|
algopy.UInt64
|
int
,
/
,
)
→
tuple
[
algopy.UInt64
,
bool
]
¶
Number of uint64 values allowed in Local State
Native TEAL opcode:
app_params_get
class
algopy.op.
AssetHoldingGet
¶
X is field F from account A’s holding of asset B. Y is 1 if A is opted into B, else 0 params: Txn.Accounts offset (or, since v4, an
available
address), asset id (or, since v4, a Txn.ForeignAssets offset). Return: did_exist flag (1 if the asset existed and 0 otherwise), value.
Native TEAL op:
asset_holding_get
static
asset_balance
(
a
:
algopy.Account
|
algopy.UInt64
|
int
,
b
:
algopy.Asset
|
algopy.UInt64
|
int
,
/
,
)
→
tuple
[
algopy.UInt64
,
bool
]
¶
Amount of the asset unit held by this account
Native TEAL opcode:
asset_holding_get
static
asset_frozen
(
a
:
algopy.Account
|
algopy.UInt64
|
int
,
b
:
algopy.Asset
|
algopy.UInt64
|
int
,
/
,
)
→
tuple
[
bool
,
bool
]
¶
Is the asset frozen or not
Native TEAL opcode:
asset_holding_get
class
algopy.op.
AssetParamsGet
¶
X is field F from asset A. Y is 1 if A exists, else 0 params: Txn.ForeignAssets offset (or, since v4, an
available
asset id. Return: did_exist flag (1 if the asset existed and 0 otherwise), value.
Native TEAL op:
asset_params_get
static
asset_clawback
(
a
:
algopy.Asset
|
algopy.UInt64
|
int
,
/
,
)
→
tuple
[
algopy.Account
,
bool
]
¶
Clawback address
Native TEAL opcode:
asset_params_get
static
asset_creator
(
a
:
algopy.Asset
|
algopy.UInt64
|
int
,
/
,
)
→
tuple
[
algopy.Account
,
bool
]
¶
Creator address
Native TEAL opcode:
asset_params_get
static
asset_decimals
(
a
:
algopy.Asset
|
algopy.UInt64
|
int
,
/
,
)
→
tuple
[
algopy.UInt64
,
bool
]
¶
See AssetParams.Decimals
Native TEAL opcode:
asset_params_get
static
asset_default_frozen
(
a
:
algopy.Asset
|
algopy.UInt64
|
int
,
/
,
)
→
tuple
[
bool
,
bool
]
¶
Frozen by default or not
Native TEAL opcode:
asset_params_get
static
asset_freeze
(
a
:
algopy.Asset
|
algopy.UInt64
|
int
,
/
,
)
→
tuple
[
algopy.Account
,
bool
]
¶
Freeze address
Native TEAL opcode:
asset_params_get
static
asset_manager
(
a
:
algopy.Asset
|
algopy.UInt64
|
int
,
/
,
)
→
tuple
[
algopy.Account
,
bool
]
¶
Manager address
Native TEAL opcode:
asset_params_get
static
asset_metadata_hash
(
a
:
algopy.Asset
|
algopy.UInt64
|
int
,
/
,
)
→
tuple
[
algopy.Bytes
,
bool
]
¶
Arbitrary commitment
Native TEAL opcode:
asset_params_get
static
asset_name
(
a
:
algopy.Asset
|
algopy.UInt64
|
int
,
/
,
)
→
tuple
[
algopy.Bytes
,
bool
]
¶
Asset name
Native TEAL opcode:
asset_params_get
static
asset_reserve
(
a
:
algopy.Asset
|
algopy.UInt64
|
int
,
/
,
)
→
tuple
[
algopy.Account
,
bool
]
¶
Reserve address
Native TEAL opcode:
asset_params_get
static
asset_total
(
a
:
algopy.Asset
|
algopy.UInt64
|
int
,
/
,
)
→
tuple
[
algopy.UInt64
,
bool
]
¶
Total number of units of this asset
Native TEAL opcode:
asset_params_get
static
asset_unit_name
(
a
:
algopy.Asset
|
algopy.UInt64
|
int
,
/
,
)
→
tuple
[
algopy.Bytes
,
bool
]
¶
Asset unit name
Native TEAL opcode:
asset_params_get
static
asset_url
(
a
:
algopy.Asset
|
algopy.UInt64
|
int
,
/
)
→
tuple
[
algopy.Bytes
,
bool
]
¶
URL with additional info about the asset
Native TEAL opcode:
asset_params_get
class
algopy.op.
Base64
¶
Available values for the
base64
enum
Initialization
Initialize self. See help(type(self)) for accurate signature.
__add__
(
)
¶
Return self+value.
__contains__
(
)
¶
Return bool(key in self).
__delattr__
(
)
¶
Implement delattr(self, name).
__dir__
(
)
¶
Default dir() implementation.
__eq__
(
)
¶
Return self==value.
__format__
(
)
¶
Return a formatted version of the string as described by format_spec.
__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.
__mod__
(
)
¶
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).
__rmod__
(
)
¶
Return value%self.
__rmul__
(
)
¶
Return value*self.
__setattr__
(
)
¶
Implement setattr(self, name, value).
__sizeof__
(
)
¶
Return the size of the string in memory, in bytes.
__str__
(
)
¶
Return str(self).
capitalize
(
)
¶
Return a capitalized version of the string.
More specifically, make the first character have upper case and the rest lower
case.
casefold
(
)
¶
Return a version of the string suitable for caseless comparisons.
center
(
)
¶
Return a centered string of length width.
Padding is done using the specified fill character (default is a space).
count
(
)
¶
S.count(sub[, start[, end]]) -> int
Return the number of non-overlapping occurrences of substring sub in
string S[start:end]. Optional arguments start and end are
interpreted as in slice notation.
encode
(
)
¶
Encode the string using the codec registered for encoding.
encoding
The encoding in which to encode the string.
errors
The error handling scheme to use for encoding errors.
The default is ‘strict’ meaning that encoding errors raise a
UnicodeEncodeError. Other possible values are ‘ignore’, ‘replace’ and
‘xmlcharrefreplace’ as well as any other name registered with
codecs.register_error that can handle UnicodeEncodeErrors.
endswith
(
)
¶
S.endswith(suffix[, start[, end]]) -> bool
Return True if S ends with the specified suffix, False otherwise.
With optional start, test S beginning at that position.
With optional end, stop comparing S at that position.
suffix can also be a tuple of strings to try.
expandtabs
(
)
¶
Return a copy where all tab characters are expanded using spaces.
If tabsize is not given, a tab size of 8 characters is assumed.
find
(
)
¶
S.find(sub[, start[, end]]) -> int
Return the lowest index in S where substring sub is found,
such that sub is contained within S[start:end]. Optional
arguments start and end are interpreted as in slice notation.
Return -1 on failure.
format
(
)
¶
S.format(*args, **kwargs) -> str
Return a formatted version of S, using substitutions from args and kwargs.
The substitutions are identified by braces (‘{’ and ‘}’).
format_map
(
)
¶
S.format_map(mapping) -> str
Return a formatted version of S, using substitutions from mapping.
The substitutions are identified by braces (‘{’ and ‘}’).
index
(
)
¶
S.index(sub[, start[, end]]) -> int
Return the lowest index in S where substring sub is found,
such that sub is contained within S[start:end]. Optional
arguments start and end are interpreted as in slice notation.
Raises ValueError when the substring is not found.
isalnum
(
)
¶
Return True if the string is an alpha-numeric string, False otherwise.
A string is alpha-numeric if all characters in the string are alpha-numeric and
there is at least one character in the string.
isalpha
(
)
¶
Return True if the string is an alphabetic string, False otherwise.
A string is alphabetic if all characters in the string are alphabetic and there
is at least one character in the string.
isascii
(
)
¶
Return True if all characters in the string are ASCII, False otherwise.
ASCII characters have code points in the range U+0000-U+007F.
Empty string is ASCII too.
isdecimal
(
)
¶
Return True if the string is a decimal string, False otherwise.
A string is a decimal string if all characters in the string are decimal and
there is at least one character in the string.
isdigit
(
)
¶
Return True if the string is a digit string, False otherwise.
A string is a digit string if all characters in the string are digits and there
is at least one character in the string.
isidentifier
(
)
¶
Return True if the string is a valid Python identifier, False otherwise.
Call keyword.iskeyword(s) to test whether string s is a reserved identifier,
such as “def” or “class”.
islower
(
)
¶
Return True if the string is a lowercase string, False otherwise.
A string is lowercase if all cased characters in the string are lowercase and
there is at least one cased character in the string.
isnumeric
(
)
¶
Return True if the string is a numeric string, False otherwise.
A string is numeric if all characters in the string are numeric and there is at
least one character in the string.
isprintable
(
)
¶
Return True if the string is printable, False otherwise.
A string is printable if all of its characters are considered printable in
repr() or if it is empty.
isspace
(
)
¶
Return True if the string is a whitespace string, False otherwise.
A string is whitespace if all characters in the string are whitespace and there
is at least one character in the string.
istitle
(
)
¶
Return True if the string is a title-cased string, False otherwise.
In a title-cased string, upper- and title-case characters may only
follow uncased characters and lowercase characters only cased ones.
isupper
(
)
¶
Return True if the string is an uppercase string, False otherwise.
A string is uppercase if all cased characters in the string are uppercase and
there is at least one cased character in the string.
join
(
)
¶
Concatenate any number of strings.
The string whose method is called is inserted in between each given string.
The result is returned as a new string.
Example: ‘.’.join([‘ab’, ‘pq’, ‘rs’]) -> ‘ab.pq.rs’
ljust
(
)
¶
Return a left-justified string of length width.
Padding is done using the specified fill character (default is a space).
lower
(
)
¶
Return a copy of the string converted to lowercase.
lstrip
(
)
¶
Return a copy of the string with leading whitespace removed.
If chars is given and not None, remove characters in chars instead.
partition
(
)
¶
Partition the string into three parts using the given separator.
This will search for the separator in the string. If the separator is found,
returns a 3-tuple containing the part before the separator, the separator
itself, and the part after it.
If the separator is not found, returns a 3-tuple containing the original string
and two empty strings.
removeprefix
(
)
¶
Return a str with the given prefix string removed if present.
If the string starts with the prefix string, return string[len(prefix):].
Otherwise, return a copy of the original string.
removesuffix
(
)
¶
Return a str with the given suffix string removed if present.
If the string ends with the suffix string and that suffix is not empty,
return string[:-len(suffix)]. Otherwise, return a copy of the original
string.
replace
(
)
¶
Return a copy with all occurrences of substring old replaced by new.
count
Maximum number of occurrences to replace.
-1 (the default value) means replace all occurrences.
If the optional argument count is given, only the first count occurrences are
replaced.
rfind
(
)
¶
S.rfind(sub[, start[, end]]) -> int
Return the highest index in S where substring sub is found,
such that sub is contained within S[start:end]. Optional
arguments start and end are interpreted as in slice notation.
Return -1 on failure.
rindex
(
)
¶
S.rindex(sub[, start[, end]]) -> int
Return the highest index in S where substring sub is found,
such that sub is contained within S[start:end]. Optional
arguments start and end are interpreted as in slice notation.
Raises ValueError when the substring is not found.
rjust
(
)
¶
Return a right-justified string of length width.
Padding is done using the specified fill character (default is a space).
rpartition
(
)
¶
Partition the string into three parts using the given separator.
This will search for the separator in the string, starting at the end. If
the separator is found, returns a 3-tuple containing the part before the
separator, the separator itself, and the part after it.
If the separator is not found, returns a 3-tuple containing two empty strings
and the original string.
rsplit
(
)
¶
Return a list of the substrings in the string, using sep as the separator string.
sep
The separator used to split the string.
When set to None (the default value), will split on any whitespace
character (including \n \r \t \f and spaces) and will discard
empty strings from the result.
maxsplit
Maximum number of splits.
-1 (the default value) means no limit.
Splitting starts at the end of the string and works to the front.
rstrip
(
)
¶
Return a copy of the string with trailing whitespace removed.
If chars is given and not None, remove characters in chars instead.
split
(
)
¶
Return a list of the substrings in the string, using sep as the separator string.
sep
The separator used to split the string.
When set to None (the default value), will split on any whitespace
character (including \n \r \t \f and spaces) and will discard
empty strings from the result.
maxsplit
Maximum number of splits.
-1 (the default value) means no limit.
Splitting starts at the front of the string and works to the end.
Note, str.split() is mainly useful for data that has been intentionally
delimited. With natural text that includes punctuation, consider using
the regular expression module.
splitlines
(
)
¶
Return a list of the lines in the string, breaking at line boundaries.
Line breaks are not included in the resulting list unless keepends is given and
true.
startswith
(
)
¶
S.startswith(prefix[, start[, end]]) -> bool
Return True if S starts with the specified prefix, False otherwise.
With optional start, test S beginning at that position.
With optional end, stop comparing S at that position.
prefix can also be a tuple of strings to try.
strip
(
)
¶
Return a copy of the string with leading and trailing whitespace removed.
If chars is given and not None, remove characters in chars instead.
swapcase
(
)
¶
Convert uppercase characters to lowercase and lowercase characters to uppercase.
title
(
)
¶
Return a version of the string where each word is titlecased.
More specifically, words start with uppercased characters and all remaining
cased characters have lower case.
translate
(
)
¶
Replace each character in the string using the given translation table.
table
Translation table, which must be a mapping of Unicode ordinals to
Unicode ordinals, strings, or None.
The table must implement lookup/indexing via
getitem
, for instance a
dictionary or list. If this operation raises LookupError, the character is
left untouched. Characters mapped to None are deleted.
upper
(
)
¶
Return a copy of the string converted to uppercase.
zfill
(
)
¶
Pad a numeric string with zeros on the left, to fill a field of the given width.
The string is never truncated.
class
algopy.op.
Block
¶
field F of block A. Fail unless A falls between txn.LastValid-1002 and txn.FirstValid (exclusive)
Native TEAL op:
block
static
blk_bonus
(
a
:
algopy.UInt64
|
int
,
/
)
→
algopy.UInt64
¶
Min AVM version: 11
Native TEAL opcode:
block
static
blk_branch
(
a
:
algopy.UInt64
|
int
,
/
)
→
algopy.Bytes
¶
Min AVM version: 11
Native TEAL opcode:
block
static
blk_fee_sink
(
a
:
algopy.UInt64
|
int
,
/
)
→
algopy.Account
¶
Min AVM version: 11
Native TEAL opcode:
block
static
blk_fees_collected
(
a
:
algopy.UInt64
|
int
,
/
)
→
algopy.UInt64
¶
Min AVM version: 11
Native TEAL opcode:
block
static
blk_proposer
(
a
:
algopy.UInt64
|
int
,
/
)
→
algopy.Account
¶
Min AVM version: 11
Native TEAL opcode:
block
static
blk_proposer_payout
(
a
:
algopy.UInt64
|
int
,
/
)
→
algopy.UInt64
¶
Min AVM version: 11
Native TEAL opcode:
block
static
blk_protocol
(
a
:
algopy.UInt64
|
int
,
/
)
→
algopy.Bytes
¶
Min AVM version: 11
Native TEAL opcode:
block
static
blk_seed
(
a
:
algopy.UInt64
|
int
,
/
)
→
algopy.Bytes
¶
Native TEAL opcode:
block
static
blk_timestamp
(
a
:
algopy.UInt64
|
int
,
/
)
→
algopy.UInt64
¶
Native TEAL opcode:
block
static
blk_txn_counter
(
a
:
algopy.UInt64
|
int
,
/
)
→
algopy.UInt64
¶
Min AVM version: 11
Native TEAL opcode:
block
class
algopy.op.
Box
¶
Get or modify box state
Native TEAL ops:
box_create
,
box_del
,
box_extract
,
box_get
,
box_len
,
box_put
,
box_replace
,
box_resize
,
box_splice
static
create
(
a
:
algopy.Bytes
|
bytes
,
b
:
algopy.UInt64
|
int
,
/
)
→
bool
¶
create a box named A, of length B. Fail if the name A is empty or B exceeds 32,768. Returns 0 if A already existed, else 1
Newly created boxes are filled with 0 bytes.
box_create
will fail if the referenced box already exists with a different size. Otherwise, existing boxes are unchanged by
box_create
.
Native TEAL opcode:
box_create
static
delete
(
a
:
algopy.Bytes
|
bytes
,
/
)
→
bool
¶
delete box named A if it exists. Return 1 if A existed, 0 otherwise
Native TEAL opcode:
box_del
static
extract
(
a
:
algopy.Bytes
|
bytes
,
b
:
algopy.UInt64
|
int
,
c
:
algopy.UInt64
|
int
,
/
,
)
→
algopy.Bytes
¶
read C bytes from box A, starting at offset B. Fail if A does not exist, or the byte range is outside A’s size.
Native TEAL opcode:
box_extract
static
get
(
a
:
algopy.Bytes
|
bytes
,
/
)
→
tuple
[
algopy.Bytes
,
bool
]
¶
X is the contents of box A if A exists, else ‘’. Y is 1 if A exists, else 0.
For boxes that exceed 4,096 bytes, consider
box_create
,
box_extract
, and
box_replace
Native TEAL opcode:
box_get
static
length
(
a
:
algopy.Bytes
|
bytes
,
/
)
→
tuple
[
algopy.UInt64
,
bool
]
¶
X is the length of box A if A exists, else 0. Y is 1 if A exists, else 0.
Native TEAL opcode:
box_len
static
put
(
a
:
algopy.Bytes
|
bytes
,
b
:
algopy.Bytes
|
bytes
,
/
)
→
None
¶
replaces the contents of box A with byte-array B. Fails if A exists and len(B) != len(box A). Creates A if it does not exist
For boxes that exceed 4,096 bytes, consider
box_create
,
box_extract
, and
box_replace
Native TEAL opcode:
box_put
static
replace
(
a
:
algopy.Bytes
|
bytes
,
b
:
algopy.UInt64
|
int
,
c
:
algopy.Bytes
|
bytes
,
/
,
)
→
None
¶
write byte-array C into box A, starting at offset B. Fail if A does not exist, or the byte range is outside A’s size.
Native TEAL opcode:
box_replace
static
resize
(
a
:
algopy.Bytes
|
bytes
,
b
:
algopy.UInt64
|
int
,
/
)
→
None
¶
change the size of box named A to be of length B, adding zero bytes to end or removing bytes from the end, as needed. Fail if the name A is empty, A is not an existing box, or B exceeds 32,768.
Native TEAL opcode:
box_resize
static
splice
(
a
:
algopy.Bytes
|
bytes
,
b
:
algopy.UInt64
|
int
,
c
:
algopy.UInt64
|
int
,
d
:
algopy.Bytes
|
bytes
,
/
,
)
→
None
¶
set box A to contain its previous bytes up to index B, followed by D, followed by the original bytes of A that began at index B+C.
Boxes are of constant length. If C < len(D), then len(D)-C bytes will be removed from the end. If C > len(D), zero bytes will be appended to the end to reach the box length.
Native TEAL opcode:
box_splice
class
algopy.op.
EC
¶
Available values for the
EC
enum
Initialization
Initialize self. See help(type(self)) for accurate signature.
BLS12_381g1
:
algopy.op.EC
¶
Ellipsis
G1 of the BLS 12-381 curve. Points encoded as 48 byte X following by 48 byte Y
BLS12_381g2
:
algopy.op.EC
¶
Ellipsis
G2 of the BLS 12-381 curve. Points encoded as 96 byte X following by 96 byte Y
BN254g1
:
algopy.op.EC
¶
Ellipsis
G1 of the BN254 curve. Points encoded as 32 byte X following by 32 byte Y
BN254g2
:
algopy.op.EC
¶
Ellipsis
G2 of the BN254 curve. Points encoded as 64 byte X following by 64 byte Y
__add__
(
)
¶
Return self+value.
__contains__
(
)
¶
Return bool(key in self).
__delattr__
(
)
¶
Implement delattr(self, name).
__dir__
(
)
¶
Default dir() implementation.
__eq__
(
)
¶
Return self==value.
__format__
(
)
¶
Return a formatted version of the string as described by format_spec.
__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.
__mod__
(
)
¶
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).
__rmod__
(
)
¶
Return value%self.
__rmul__
(
)
¶
Return value*self.
__setattr__
(
)
¶
Implement setattr(self, name, value).
__sizeof__
(
)
¶
Return the size of the string in memory, in bytes.
__str__
(
)
¶
Return str(self).
capitalize
(
)
¶
Return a capitalized version of the string.
More specifically, make the first character have upper case and the rest lower
case.
casefold
(
)
¶
Return a version of the string suitable for caseless comparisons.
center
(
)
¶
Return a centered string of length width.
Padding is done using the specified fill character (default is a space).
count
(
)
¶
S.count(sub[, start[, end]]) -> int
Return the number of non-overlapping occurrences of substring sub in
string S[start:end]. Optional arguments start and end are
interpreted as in slice notation.
encode
(
)
¶
Encode the string using the codec registered for encoding.
encoding
The encoding in which to encode the string.
errors
The error handling scheme to use for encoding errors.
The default is ‘strict’ meaning that encoding errors raise a
UnicodeEncodeError. Other possible values are ‘ignore’, ‘replace’ and
‘xmlcharrefreplace’ as well as any other name registered with
codecs.register_error that can handle UnicodeEncodeErrors.
endswith
(
)
¶
S.endswith(suffix[, start[, end]]) -> bool
Return True if S ends with the specified suffix, False otherwise.
With optional start, test S beginning at that position.
With optional end, stop comparing S at that position.
suffix can also be a tuple of strings to try.
expandtabs
(
)
¶
Return a copy where all tab characters are expanded using spaces.
If tabsize is not given, a tab size of 8 characters is assumed.
find
(
)
¶
S.find(sub[, start[, end]]) -> int
Return the lowest index in S where substring sub is found,
such that sub is contained within S[start:end]. Optional
arguments start and end are interpreted as in slice notation.
Return -1 on failure.
format
(
)
¶
S.format(*args, **kwargs) -> str
Return a formatted version of S, using substitutions from args and kwargs.
The substitutions are identified by braces (‘{’ and ‘}’).
format_map
(
)
¶
S.format_map(mapping) -> str
Return a formatted version of S, using substitutions from mapping.
The substitutions are identified by braces (‘{’ and ‘}’).
index
(
)
¶
S.index(sub[, start[, end]]) -> int
Return the lowest index in S where substring sub is found,
such that sub is contained within S[start:end]. Optional
arguments start and end are interpreted as in slice notation.
Raises ValueError when the substring is not found.
isalnum
(
)
¶
Return True if the string is an alpha-numeric string, False otherwise.
A string is alpha-numeric if all characters in the string are alpha-numeric and
there is at least one character in the string.
isalpha
(
)
¶
Return True if the string is an alphabetic string, False otherwise.
A string is alphabetic if all characters in the string are alphabetic and there
is at least one character in the string.
isascii
(
)
¶
Return True if all characters in the string are ASCII, False otherwise.
ASCII characters have code points in the range U+0000-U+007F.
Empty string is ASCII too.
isdecimal
(
)
¶
Return True if the string is a decimal string, False otherwise.
A string is a decimal string if all characters in the string are decimal and
there is at least one character in the string.
isdigit
(
)
¶
Return True if the string is a digit string, False otherwise.
A string is a digit string if all characters in the string are digits and there
is at least one character in the string.
isidentifier
(
)
¶
Return True if the string is a valid Python identifier, False otherwise.
Call keyword.iskeyword(s) to test whether string s is a reserved identifier,
such as “def” or “class”.
islower
(
)
¶
Return True if the string is a lowercase string, False otherwise.
A string is lowercase if all cased characters in the string are lowercase and
there is at least one cased character in the string.
isnumeric
(
)
¶
Return True if the string is a numeric string, False otherwise.
A string is numeric if all characters in the string are numeric and there is at
least one character in the string.
isprintable
(
)
¶
Return True if the string is printable, False otherwise.
A string is printable if all of its characters are considered printable in
repr() or if it is empty.
isspace
(
)
¶
Return True if the string is a whitespace string, False otherwise.
A string is whitespace if all characters in the string are whitespace and there
is at least one character in the string.
istitle
(
)
¶
Return True if the string is a title-cased string, False otherwise.
In a title-cased string, upper- and title-case characters may only
follow uncased characters and lowercase characters only cased ones.
isupper
(
)
¶
Return True if the string is an uppercase string, False otherwise.
A string is uppercase if all cased characters in the string are uppercase and
there is at least one cased character in the string.
join
(
)
¶
Concatenate any number of strings.
The string whose method is called is inserted in between each given string.
The result is returned as a new string.
Example: ‘.’.join([‘ab’, ‘pq’, ‘rs’]) -> ‘ab.pq.rs’
ljust
(
)
¶
Return a left-justified string of length width.
Padding is done using the specified fill character (default is a space).
lower
(
)
¶
Return a copy of the string converted to lowercase.
lstrip
(
)
¶
Return a copy of the string with leading whitespace removed.
If chars is given and not None, remove characters in chars instead.
partition
(
)
¶
Partition the string into three parts using the given separator.
This will search for the separator in the string. If the separator is found,
returns a 3-tuple containing the part before the separator, the separator
itself, and the part after it.
If the separator is not found, returns a 3-tuple containing the original string
and two empty strings.
removeprefix
(
)
¶
Return a str with the given prefix string removed if present.
If the string starts with the prefix string, return string[len(prefix):].
Otherwise, return a copy of the original string.
removesuffix
(
)
¶
Return a str with the given suffix string removed if present.
If the string ends with the suffix string and that suffix is not empty,
return string[:-len(suffix)]. Otherwise, return a copy of the original
string.
replace
(
)
¶
Return a copy with all occurrences of substring old replaced by new.
count
Maximum number of occurrences to replace.
-1 (the default value) means replace all occurrences.
If the optional argument count is given, only the first count occurrences are
replaced.
rfind
(
)
¶
S.rfind(sub[, start[, end]]) -> int
Return the highest index in S where substring sub is found,
such that sub is contained within S[start:end]. Optional
arguments start and end are interpreted as in slice notation.
Return -1 on failure.
rindex
(
)
¶
S.rindex(sub[, start[, end]]) -> int
Return the highest index in S where substring sub is found,
such that sub is contained within S[start:end]. Optional
arguments start and end are interpreted as in slice notation.
Raises ValueError when the substring is not found.
rjust
(
)
¶
Return a right-justified string of length width.
Padding is done using the specified fill character (default is a space).
rpartition
(
)
¶
Partition the string into three parts using the given separator.
This will search for the separator in the string, starting at the end. If
the separator is found, returns a 3-tuple containing the part before the
separator, the separator itself, and the part after it.
If the separator is not found, returns a 3-tuple containing two empty strings
and the original string.
rsplit
(
)
¶
Return a list of the substrings in the string, using sep as the separator string.
sep
The separator used to split the string.
When set to None (the default value), will split on any whitespace
character (including \n \r \t \f and spaces) and will discard
empty strings from the result.
maxsplit
Maximum number of splits.
-1 (the default value) means no limit.
Splitting starts at the end of the string and works to the front.
rstrip
(
)
¶
Return a copy of the string with trailing whitespace removed.
If chars is given and not None, remove characters in chars instead.
split
(
)
¶
Return a list of the substrings in the string, using sep as the separator string.
sep
The separator used to split the string.
When set to None (the default value), will split on any whitespace
character (including \n \r \t \f and spaces) and will discard
empty strings from the result.
maxsplit
Maximum number of splits.
-1 (the default value) means no limit.
Splitting starts at the front of the string and works to the end.
Note, str.split() is mainly useful for data that has been intentionally
delimited. With natural text that includes punctuation, consider using
the regular expression module.
splitlines
(
)
¶
Return a list of the lines in the string, breaking at line boundaries.
Line breaks are not included in the resulting list unless keepends is given and
true.
startswith
(
)
¶
S.startswith(prefix[, start[, end]]) -> bool
Return True if S starts with the specified prefix, False otherwise.
With optional start, test S beginning at that position.
With optional end, stop comparing S at that position.
prefix can also be a tuple of strings to try.
strip
(
)
¶
Return a copy of the string with leading and trailing whitespace removed.
If chars is given and not None, remove characters in chars instead.
swapcase
(
)
¶
Convert uppercase characters to lowercase and lowercase characters to uppercase.
title
(
)
¶
Return a version of the string where each word is titlecased.
More specifically, words start with uppercased characters and all remaining
cased characters have lower case.
translate
(
)
¶
Replace each character in the string using the given translation table.
table
Translation table, which must be a mapping of Unicode ordinals to
Unicode ordinals, strings, or None.
The table must implement lookup/indexing via
getitem
, for instance a
dictionary or list. If this operation raises LookupError, the character is
left untouched. Characters mapped to None are deleted.
upper
(
)
¶
Return a copy of the string converted to uppercase.
zfill
(
)
¶
Pad a numeric string with zeros on the left, to fill a field of the given width.
The string is never truncated.
class
algopy.op.
ECDSA
¶
Available values for the
ECDSA
enum
Initialization
Initialize self. See help(type(self)) for accurate signature.
Secp256k1
:
algopy.op.ECDSA
¶
Ellipsis
secp256k1 curve, used in Bitcoin
Secp256r1
:
algopy.op.ECDSA
¶
Ellipsis
secp256r1 curve, NIST standard
__add__
(
)
¶
Return self+value.
__contains__
(
)
¶
Return bool(key in self).
__delattr__
(
)
¶
Implement delattr(self, name).
__dir__
(
)
¶
Default dir() implementation.
__eq__
(
)
¶
Return self==value.
__format__
(
)
¶
Return a formatted version of the string as described by format_spec.
__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.
__mod__
(
)
¶
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).
__rmod__
(
)
¶
Return value%self.
__rmul__
(
)
¶
Return value*self.
__setattr__
(
)
¶
Implement setattr(self, name, value).
__sizeof__
(
)
¶
Return the size of the string in memory, in bytes.
__str__
(
)
¶
Return str(self).
capitalize
(
)
¶
Return a capitalized version of the string.
More specifically, make the first character have upper case and the rest lower
case.
casefold
(
)
¶
Return a version of the string suitable for caseless comparisons.
center
(
)
¶
Return a centered string of length width.
Padding is done using the specified fill character (default is a space).
count
(
)
¶
S.count(sub[, start[, end]]) -> int
Return the number of non-overlapping occurrences of substring sub in
string S[start:end]. Optional arguments start and end are
interpreted as in slice notation.
encode
(
)
¶
Encode the string using the codec registered for encoding.
encoding
The encoding in which to encode the string.
errors
The error handling scheme to use for encoding errors.
The default is ‘strict’ meaning that encoding errors raise a
UnicodeEncodeError. Other possible values are ‘ignore’, ‘replace’ and
‘xmlcharrefreplace’ as well as any other name registered with
codecs.register_error that can handle UnicodeEncodeErrors.
endswith
(
)
¶
S.endswith(suffix[, start[, end]]) -> bool
Return True if S ends with the specified suffix, False otherwise.
With optional start, test S beginning at that position.
With optional end, stop comparing S at that position.
suffix can also be a tuple of strings to try.
expandtabs
(
)
¶
Return a copy where all tab characters are expanded using spaces.
If tabsize is not given, a tab size of 8 characters is assumed.
find
(
)
¶
S.find(sub[, start[, end]]) -> int
Return the lowest index in S where substring sub is found,
such that sub is contained within S[start:end]. Optional
arguments start and end are interpreted as in slice notation.
Return -1 on failure.
format
(
)
¶
S.format(*args, **kwargs) -> str
Return a formatted version of S, using substitutions from args and kwargs.
The substitutions are identified by braces (‘{’ and ‘}’).
format_map
(
)
¶
S.format_map(mapping) -> str
Return a formatted version of S, using substitutions from mapping.
The substitutions are identified by braces (‘{’ and ‘}’).
index
(
)
¶
S.index(sub[, start[, end]]) -> int
Return the lowest index in S where substring sub is found,
such that sub is contained within S[start:end]. Optional
arguments start and end are interpreted as in slice notation.
Raises ValueError when the substring is not found.
isalnum
(
)
¶
Return True if the string is an alpha-numeric string, False otherwise.
A string is alpha-numeric if all characters in the string are alpha-numeric and
there is at least one character in the string.
isalpha
(
)
¶
Return True if the string is an alphabetic string, False otherwise.
A string is alphabetic if all characters in the string are alphabetic and there
is at least one character in the string.
isascii
(
)
¶
Return True if all characters in the string are ASCII, False otherwise.
ASCII characters have code points in the range U+0000-U+007F.
Empty string is ASCII too.
isdecimal
(
)
¶
Return True if the string is a decimal string, False otherwise.
A string is a decimal string if all characters in the string are decimal and
there is at least one character in the string.
isdigit
(
)
¶
Return True if the string is a digit string, False otherwise.
A string is a digit string if all characters in the string are digits and there
is at least one character in the string.
isidentifier
(
)
¶
Return True if the string is a valid Python identifier, False otherwise.
Call keyword.iskeyword(s) to test whether string s is a reserved identifier,
such as “def” or “class”.
islower
(
)
¶
Return True if the string is a lowercase string, False otherwise.
A string is lowercase if all cased characters in the string are lowercase and
there is at least one cased character in the string.
isnumeric
(
)
¶
Return True if the string is a numeric string, False otherwise.
A string is numeric if all characters in the string are numeric and there is at
least one character in the string.
isprintable
(
)
¶
Return True if the string is printable, False otherwise.
A string is printable if all of its characters are considered printable in
repr() or if it is empty.
isspace
(
)
¶
Return True if the string is a whitespace string, False otherwise.
A string is whitespace if all characters in the string are whitespace and there
is at least one character in the string.
istitle
(
)
¶
Return True if the string is a title-cased string, False otherwise.
In a title-cased string, upper- and title-case characters may only
follow uncased characters and lowercase characters only cased ones.
isupper
(
)
¶
Return True if the string is an uppercase string, False otherwise.
A string is uppercase if all cased characters in the string are uppercase and
there is at least one cased character in the string.
join
(
)
¶
Concatenate any number of strings.
The string whose method is called is inserted in between each given string.
The result is returned as a new string.
Example: ‘.’.join([‘ab’, ‘pq’, ‘rs’]) -> ‘ab.pq.rs’
ljust
(
)
¶
Return a left-justified string of length width.
Padding is done using the specified fill character (default is a space).
lower
(
)
¶
Return a copy of the string converted to lowercase.
lstrip
(
)
¶
Return a copy of the string with leading whitespace removed.
If chars is given and not None, remove characters in chars instead.
partition
(
)
¶
Partition the string into three parts using the given separator.
This will search for the separator in the string. If the separator is found,
returns a 3-tuple containing the part before the separator, the separator
itself, and the part after it.
If the separator is not found, returns a 3-tuple containing the original string
and two empty strings.
removeprefix
(
)
¶
Return a str with the given prefix string removed if present.
If the string starts with the prefix string, return string[len(prefix):].
Otherwise, return a copy of the original string.
removesuffix
(
)
¶
Return a str with the given suffix string removed if present.
If the string ends with the suffix string and that suffix is not empty,
return string[:-len(suffix)]. Otherwise, return a copy of the original
string.
replace
(
)
¶
Return a copy with all occurrences of substring old replaced by new.
count
Maximum number of occurrences to replace.
-1 (the default value) means replace all occurrences.
If the optional argument count is given, only the first count occurrences are
replaced.
rfind
(
)
¶
S.rfind(sub[, start[, end]]) -> int
Return the highest index in S where substring sub is found,
such that sub is contained within S[start:end]. Optional
arguments start and end are interpreted as in slice notation.
Return -1 on failure.
rindex
(
)
¶
S.rindex(sub[, start[, end]]) -> int
Return the highest index in S where substring sub is found,
such that sub is contained within S[start:end]. Optional
arguments start and end are interpreted as in slice notation.
Raises ValueError when the substring is not found.
rjust
(
)
¶
Return a right-justified string of length width.
Padding is done using the specified fill character (default is a space).
rpartition
(
)
¶
Partition the string into three parts using the given separator.
This will search for the separator in the string, starting at the end. If
the separator is found, returns a 3-tuple containing the part before the
separator, the separator itself, and the part after it.
If the separator is not found, returns a 3-tuple containing two empty strings
and the original string.
rsplit
(
)
¶
Return a list of the substrings in the string, using sep as the separator string.
sep
The separator used to split the string.
When set to None (the default value), will split on any whitespace
character (including \n \r \t \f and spaces) and will discard
empty strings from the result.
maxsplit
Maximum number of splits.
-1 (the default value) means no limit.
Splitting starts at the end of the string and works to the front.
rstrip
(
)
¶
Return a copy of the string with trailing whitespace removed.
If chars is given and not None, remove characters in chars instead.
split
(
)
¶
Return a list of the substrings in the string, using sep as the separator string.
sep
The separator used to split the string.
When set to None (the default value), will split on any whitespace
character (including \n \r \t \f and spaces) and will discard
empty strings from the result.
maxsplit
Maximum number of splits.
-1 (the default value) means no limit.
Splitting starts at the front of the string and works to the end.
Note, str.split() is mainly useful for data that has been intentionally
delimited. With natural text that includes punctuation, consider using
the regular expression module.
splitlines
(
)
¶
Return a list of the lines in the string, breaking at line boundaries.
Line breaks are not included in the resulting list unless keepends is given and
true.
startswith
(
)
¶
S.startswith(prefix[, start[, end]]) -> bool
Return True if S starts with the specified prefix, False otherwise.
With optional start, test S beginning at that position.
With optional end, stop comparing S at that position.
prefix can also be a tuple of strings to try.
strip
(
)
¶
Return a copy of the string with leading and trailing whitespace removed.
If chars is given and not None, remove characters in chars instead.
swapcase
(
)
¶
Convert uppercase characters to lowercase and lowercase characters to uppercase.
title
(
)
¶
Return a version of the string where each word is titlecased.
More specifically, words start with uppercased characters and all remaining
cased characters have lower case.
translate
(
)
¶
Replace each character in the string using the given translation table.
table
Translation table, which must be a mapping of Unicode ordinals to
Unicode ordinals, strings, or None.
The table must implement lookup/indexing via
getitem
, for instance a
dictionary or list. If this operation raises LookupError, the character is
left untouched. Characters mapped to None are deleted.
upper
(
)
¶
Return a copy of the string converted to uppercase.
zfill
(
)
¶
Pad a numeric string with zeros on the left, to fill a field of the given width.
The string is never truncated.
class
algopy.op.
EllipticCurve
¶
Elliptic Curve functions
Native TEAL ops:
ec_add
,
ec_map_to
,
ec_multi_scalar_mul
,
ec_pairing_check
,
ec_scalar_mul
,
ec_subgroup_check
static
add
(
g
:
algopy.op.EC
,
a
:
algopy.Bytes
|
bytes
,
b
:
algopy.Bytes
|
bytes
,
/
,
)
→
algopy.Bytes
¶
for curve points A and B, return the curve point A + B
A and B are curve points in affine representation: field element X concatenated with field element Y. Field element
Z
is encoded as follows.
For the base field elements (Fp),
Z
is encoded as a big-endian number and must be lower than the field modulus.
For the quadratic field extension (Fp2),
Z
is encoded as the concatenation of the individual encoding of the coefficients. For an Fp2 element of the form
Z
=
Z0
+
Z1
i
, where
i
is a formal quadratic non-residue, the encoding of Z is the concatenation of the encoding of
Z0
and
Z1
in this order. (
Z0
and
Z1
must be less than the field modulus).
The point at infinity is encoded as
(X,Y)
=
(0,0)
.
Groups G1 and G2 are denoted additively.
Fails if A or B is not in G.
A and/or B are allowed to be the point at infinity.
Does
not
check if A and B are in the main prime-order subgroup.
Parameters
:
g
(
EC
) – curve index
Native TEAL opcode:
ec_add
static
map_to
(
g
:
algopy.op.EC
,
a
:
algopy.Bytes
|
bytes
,
/
)
→
algopy.Bytes
¶
maps field element A to group G
BN254 points are mapped by the SVDW map. BLS12-381 points are mapped by the SSWU map.
G1 element inputs are base field elements and G2 element inputs are quadratic field elements, with nearly the same encoding rules (for field elements) as defined in
ec_add
. There is one difference of encoding rule: G1 element inputs do not need to be 0-padded if they fit in less than 32 bytes for BN254 and less than 48 bytes for BLS12-381. (As usual, the empty byte array represents 0.) G2 elements inputs need to be always have the required size.
Parameters
:
g
(
EC
) – curve index
Native TEAL opcode:
ec_map_to
static
pairing_check
(
g
:
algopy.op.EC
,
a
:
algopy.Bytes
|
bytes
,
b
:
algopy.Bytes
|
bytes
,
/
,
)
→
bool
¶
1 if the product of the pairing of each point in A with its respective point in B is equal to the identity element of the target group Gt, else 0
A and B are concatenated points, encoded and checked as described in
ec_add
. A contains points of the group G, B contains points of the associated group (G2 if G is G1, and vice versa). Fails if A and B have a different number of points, or if any point is not in its described group or outside the main prime-order subgroup - a stronger condition than other opcodes. AVM values are limited to 4096 bytes, so
ec_pairing_check
is limited by the size of the points in the groups being operated upon.
Parameters
:
g
(
EC
) – curve index
Native TEAL opcode:
ec_pairing_check
static
scalar_mul
(
g
:
algopy.op.EC
,
a
:
algopy.Bytes
|
bytes
,
b
:
algopy.Bytes
|
bytes
,
/
,
)
→
algopy.Bytes
¶
for curve point A and scalar B, return the curve point BA, the point A multiplied by the scalar B.
A is a curve point encoded and checked as described in
ec_add
. Scalar B is interpreted as a big-endian unsigned integer. Fails if B exceeds 32 bytes.
Parameters
:
g
(
EC
) – curve index
Native TEAL opcode:
ec_scalar_mul
static
scalar_mul_multi
(
g
:
algopy.op.EC
,
a
:
algopy.Bytes
|
bytes
,
b
:
algopy.Bytes
|
bytes
,
/
,
)
→
algopy.Bytes
¶
for curve points A and scalars B, return curve point B0A0 + B1A1 + B2A2 + … + BnAn
A is a list of concatenated points, encoded and checked as described in
ec_add
. B is a list of concatenated scalars which, unlike ec_scalar_mul, must all be exactly 32 bytes long.
The name
ec_multi_scalar_mul
was chosen to reflect common usage, but a more consistent name would be
ec_multi_scalar_mul
. AVM values are limited to 4096 bytes, so
ec_multi_scalar_mul
is limited by the size of the points in the group being operated upon.
Parameters
:
g
(
EC
) – curve index
Native TEAL opcode:
ec_multi_scalar_mul
static
subgroup_check
(
g
:
algopy.op.EC
,
a
:
algopy.Bytes
|
bytes
,
/
)
→
bool
¶
1 if A is in the main prime-order subgroup of G (including the point at infinity) else 0. Program fails if A is not in G at all.
Parameters
:
g
(
EC
) – curve index
Native TEAL opcode:
ec_subgroup_check
class
algopy.op.
GITxn
¶
Get values for inner transaction in the last group submitted
Native TEAL ops:
gitxn
,
gitxnas
static
accounts
(
t
:
int
,
a
:
algopy.UInt64
|
int
,
/
)
→
algopy.Account
¶
Parameters
:
t
(
int
) – transaction group index
Returns Account
:
Accounts listed in the ApplicationCall transaction
Native TEAL opcode:
gitxna
,
gitxnas
static
amount
(
t
:
int
,
/
)
→
algopy.UInt64
¶
Parameters
:
t
(
int
) – transaction group index
Returns UInt64
:
microalgos
Native TEAL opcode:
gitxn
static
application_args
(
t
:
int
,
a
:
algopy.UInt64
|
int
,
/
)
→
algopy.Bytes
¶
Parameters
:
t
(
int
) – transaction group index
Returns Bytes
:
Arguments passed to the application in the ApplicationCall transaction
Native TEAL opcode:
gitxna
,
gitxnas
static
application_id
(
t
:
int
,
/
)
→
algopy.Application
¶
Parameters
:
t
(
int
) – transaction group index
Returns Application
:
ApplicationID from ApplicationCall transaction
Native TEAL opcode:
gitxn
static
applications
(
t
:
int
,
a
:
algopy.UInt64
|
int
,
/
)
→
algopy.Application
¶
Parameters
:
t
(
int
) – transaction group index
Returns Application
:
Foreign Apps listed in the ApplicationCall transaction
Native TEAL opcode:
gitxna
,
gitxnas
static
approval_program
(
t
:
int
,
/
)
→
algopy.Bytes
¶
Parameters
:
t
(
int
) – transaction group index
Returns Bytes
:
Approval program
Native TEAL opcode:
gitxn
static
approval_program_pages
(
t
:
int
,
a
:
algopy.UInt64
|
int
,
/
)
→
algopy.Bytes
¶
Parameters
:
t
(
int
) – transaction group index
Returns Bytes
:
Approval Program as an array of pages
Native TEAL opcode:
gitxna
,
gitxnas
static
asset_amount
(
t
:
int
,
/
)
→
algopy.UInt64
¶
Parameters
:
t
(
int
) – transaction group index
Returns UInt64
:
value in Asset’s units
Native TEAL opcode:
gitxn
static
asset_close_to
(
t
:
int
,
/
)
→
algopy.Account
¶
Parameters
:
t
(
int
) – transaction group index
Returns Account
:
32 byte address
Native TEAL opcode:
gitxn
static
asset_receiver
(
t
:
int
,
/
)
→
algopy.Account
¶
Parameters
:
t
(
int
) – transaction group index
Returns Account
:
32 byte address
Native TEAL opcode:
gitxn
static
asset_sender
(
t
:
int
,
/
)
→
algopy.Account
¶
Parameters
:
t
(
int
) – transaction group index
Returns Account
:
32 byte address. Source of assets if Sender is the Asset’s Clawback address.
Native TEAL opcode:
gitxn
static
assets
(
t
:
int
,
a
:
algopy.UInt64
|
int
,
/
)
→
algopy.Asset
¶
Parameters
:
t
(
int
) – transaction group index
Returns Asset
:
Foreign Assets listed in the ApplicationCall transaction
Native TEAL opcode:
gitxna
,
gitxnas
static
clear_state_program
(
t
:
int
,
/
)
→
algopy.Bytes
¶
Parameters
:
t
(
int
) – transaction group index
Returns Bytes
:
Clear state program
Native TEAL opcode:
gitxn
static
clear_state_program_pages
(
t
:
int
,
a
:
algopy.UInt64
|
int
,
/
)
→
algopy.Bytes
¶
Parameters
:
t
(
int
) – transaction group index
Returns Bytes
:
ClearState Program as an array of pages
Native TEAL opcode:
gitxna
,
gitxnas
static
close_remainder_to
(
t
:
int
,
/
)
→
algopy.Account
¶
Parameters
:
t
(
int
) – transaction group index
Returns Account
:
32 byte address
Native TEAL opcode:
gitxn
static
config_asset
(
t
:
int
,
/
)
→
algopy.Asset
¶
Parameters
:
t
(
int
) – transaction group index
Returns Asset
:
Asset ID in asset config transaction
Native TEAL opcode:
gitxn
static
config_asset_clawback
(
t
:
int
,
/
)
→
algopy.Account
¶
Parameters
:
t
(
int
) – transaction group index
Returns Account
:
32 byte address
Native TEAL opcode:
gitxn
static
config_asset_decimals
(
t
:
int
,
/
)
→
algopy.UInt64
¶
Parameters
:
t
(
int
) – transaction group index
Returns UInt64
:
Number of digits to display after the decimal place when displaying the asset
Native TEAL opcode:
gitxn
static
config_asset_default_frozen
(
t
:
int
,
/
)
→
bool
¶
Parameters
:
t
(
int
) – transaction group index
Returns bool
:
Whether the asset’s slots are frozen by default or not, 0 or 1
Native TEAL opcode:
gitxn
static
config_asset_freeze
(
t
:
int
,
/
)
→
algopy.Account
¶
Parameters
:
t
(
int
) – transaction group index
Returns Account
:
32 byte address
Native TEAL opcode:
gitxn
static
config_asset_manager
(
t
:
int
,
/
)
→
algopy.Account
¶
Parameters
:
t
(
int
) – transaction group index
Returns Account
:
32 byte address
Native TEAL opcode:
gitxn
static
config_asset_metadata_hash
(
t
:
int
,
/
)
→
algopy.Bytes
¶
Parameters
:
t
(
int
) – transaction group index
Returns Bytes
:
32 byte commitment to unspecified asset metadata
Native TEAL opcode:
gitxn
static
config_asset_name
(
t
:
int
,
/
)
→
algopy.Bytes
¶
Parameters
:
t
(
int
) – transaction group index
Returns Bytes
:
The asset name
Native TEAL opcode:
gitxn
static
config_asset_reserve
(
t
:
int
,
/
)
→
algopy.Account
¶
Parameters
:
t
(
int
) – transaction group index
Returns Account
:
32 byte address
Native TEAL opcode:
gitxn
static
config_asset_total
(
t
:
int
,
/
)
→
algopy.UInt64
¶
Parameters
:
t
(
int
) – transaction group index
Returns UInt64
:
Total number of units of this asset created
Native TEAL opcode:
gitxn
static
config_asset_unit_name
(
t
:
int
,
/
)
→
algopy.Bytes
¶
Parameters
:
t
(
int
) – transaction group index
Returns Bytes
:
Unit name of the asset
Native TEAL opcode:
gitxn
static
config_asset_url
(
t
:
int
,
/
)
→
algopy.Bytes
¶
Parameters
:
t
(
int
) – transaction group index
Returns Bytes
:
URL
Native TEAL opcode:
gitxn
static
created_application_id
(
t
:
int
,
/
)
→
algopy.Application
¶
Parameters
:
t
(
int
) – transaction group index
Returns Application
:
ApplicationID allocated by the creation of an application (only with
itxn
in v5). Application mode only
Native TEAL opcode:
gitxn
static
created_asset_id
(
t
:
int
,
/
)
→
algopy.Asset
¶
Parameters
:
t
(
int
) – transaction group index
Returns Asset
:
Asset ID allocated by the creation of an ASA (only with
itxn
in v5). Application mode only
Native TEAL opcode:
gitxn
static
extra_program_pages
(
t
:
int
,
/
)
→
algopy.UInt64
¶
Parameters
:
t
(
int
) – transaction group index
Returns UInt64
:
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.
Native TEAL opcode:
gitxn
static
fee
(
t
:
int
,
/
)
→
algopy.UInt64
¶
Parameters
:
t
(
int
) – transaction group index
Returns UInt64
:
microalgos
Native TEAL opcode:
gitxn
static
first_valid
(
t
:
int
,
/
)
→
algopy.UInt64
¶
Parameters
:
t
(
int
) – transaction group index
Returns UInt64
:
round number
Native TEAL opcode:
gitxn
static
first_valid_time
(
t
:
int
,
/
)
→
algopy.UInt64
¶
Parameters
:
t
(
int
) – transaction group index
Returns UInt64
:
UNIX timestamp of block before txn.FirstValid. Fails if negative
Native TEAL opcode:
gitxn
static
freeze_asset
(
t
:
int
,
/
)
→
algopy.Asset
¶
Parameters
:
t
(
int
) – transaction group index
Returns Asset
:
Asset ID being frozen or un-frozen
Native TEAL opcode:
gitxn
static
freeze_asset_account
(
t
:
int
,
/
)
→
algopy.Account
¶
Parameters
:
t
(
int
) – transaction group index
Returns Account
:
32 byte address of the account whose asset slot is being frozen or un-frozen
Native TEAL opcode:
gitxn
static
freeze_asset_frozen
(
t
:
int
,
/
)
→
bool
¶
Parameters
:
t
(
int
) – transaction group index
Returns bool
:
The new frozen value, 0 or 1
Native TEAL opcode:
gitxn
static
global_num_byte_slice
(
t
:
int
,
/
)
→
algopy.UInt64
¶
Parameters
:
t
(
int
) – transaction group index
Returns UInt64
:
Number of global state byteslices in ApplicationCall
Native TEAL opcode:
gitxn
static
global_num_uint
(
t
:
int
,
/
)
→
algopy.UInt64
¶
Parameters
:
t
(
int
) – transaction group index
Returns UInt64
:
Number of global state integers in ApplicationCall
Native TEAL opcode:
gitxn
static
group_index
(
t
:
int
,
/
)
→
algopy.UInt64
¶
Parameters
:
t
(
int
) – transaction group index
Returns UInt64
:
Position of this transaction within an atomic transaction group. A stand-alone transaction is implicitly element 0 in a group of 1
Native TEAL opcode:
gitxn
static
last_log
(
t
:
int
,
/
)
→
algopy.Bytes
¶
Parameters
:
t
(
int
) – transaction group index
Returns Bytes
:
The last message emitted. Empty bytes if none were emitted. Application mode only
Native TEAL opcode:
gitxn
static
last_valid
(
t
:
int
,
/
)
→
algopy.UInt64
¶
Parameters
:
t
(
int
) – transaction group index
Returns UInt64
:
round number
Native TEAL opcode:
gitxn
static
lease
(
t
:
int
,
/
)
→
algopy.Bytes
¶
Parameters
:
t
(
int
) – transaction group index
Returns Bytes
:
32 byte lease value
Native TEAL opcode:
gitxn
static
local_num_byte_slice
(
t
:
int
,
/
)
→
algopy.UInt64
¶
Parameters
:
t
(
int
) – transaction group index
Returns UInt64
:
Number of local state byteslices in ApplicationCall
Native TEAL opcode:
gitxn
static
local_num_uint
(
t
:
int
,
/
)
→
algopy.UInt64
¶
Parameters
:
t
(
int
) – transaction group index
Returns UInt64
:
Number of local state integers in ApplicationCall
Native TEAL opcode:
gitxn
static
logs
(
t
:
int
,
a
:
algopy.UInt64
|
int
,
/
)
→
algopy.Bytes
¶
Parameters
:
t
(
int
) – transaction group index
Returns Bytes
:
Log messages emitted by an application call (only with
itxn
in v5). Application mode only
Native TEAL opcode:
gitxna
,
gitxnas
static
nonparticipation
(
t
:
int
,
/
)
→
bool
¶
Parameters
:
t
(
int
) – transaction group index
Returns bool
:
Marks an account nonparticipating for rewards
Native TEAL opcode:
gitxn
static
note
(
t
:
int
,
/
)
→
algopy.Bytes
¶
Parameters
:
t
(
int
) – transaction group index
Returns Bytes
:
Any data up to 1024 bytes
Native TEAL opcode:
gitxn
static
num_accounts
(
t
:
int
,
/
)
→
algopy.UInt64
¶
Parameters
:
t
(
int
) – transaction group index
Returns UInt64
:
Number of Accounts
Native TEAL opcode:
gitxn
static
num_app_args
(
t
:
int
,
/
)
→
algopy.UInt64
¶
Parameters
:
t
(
int
) – transaction group index
Returns UInt64
:
Number of ApplicationArgs
Native TEAL opcode:
gitxn
static
num_applications
(
t
:
int
,
/
)
→
algopy.UInt64
¶
Parameters
:
t
(
int
) – transaction group index
Returns UInt64
:
Number of Applications
Native TEAL opcode:
gitxn
static
num_approval_program_pages
(
t
:
int
,
/
)
→
algopy.UInt64
¶
Parameters
:
t
(
int
) – transaction group index
Returns UInt64
:
Number of Approval Program pages
Native TEAL opcode:
gitxn
static
num_assets
(
t
:
int
,
/
)
→
algopy.UInt64
¶
Parameters
:
t
(
int
) – transaction group index
Returns UInt64
:
Number of Assets
Native TEAL opcode:
gitxn
static
num_clear_state_program_pages
(
t
:
int
,
/
)
→
algopy.UInt64
¶
Parameters
:
t
(
int
) – transaction group index
Returns UInt64
:
Number of ClearState Program pages
Native TEAL opcode:
gitxn
static
num_logs
(
t
:
int
,
/
)
→
algopy.UInt64
¶
Parameters
:
t
(
int
) – transaction group index
Returns UInt64
:
Number of Logs (only with
itxn
in v5). Application mode only
Native TEAL opcode:
gitxn
static
on_completion
(
t
:
int
,
/
)
→
algopy.OnCompleteAction
¶
Parameters
:
t
(
int
) – transaction group index
Returns OnCompleteAction
:
ApplicationCall transaction on completion action
Native TEAL opcode:
gitxn
static
receiver
(
t
:
int
,
/
)
→
algopy.Account
¶
Parameters
:
t
(
int
) – transaction group index
Returns Account
:
32 byte address
Native TEAL opcode:
gitxn
static
rekey_to
(
t
:
int
,
/
)
→
algopy.Account
¶
Parameters
:
t
(
int
) – transaction group index
Returns Account
:
32 byte Sender’s new AuthAddr
Native TEAL opcode:
gitxn
static
selection_pk
(
t
:
int
,
/
)
→
algopy.Bytes
¶
Parameters
:
t
(
int
) – transaction group index
Returns Bytes
:
32 byte address
Native TEAL opcode:
gitxn
static
sender
(
t
:
int
,
/
)
→
algopy.Account
¶
Parameters
:
t
(
int
) – transaction group index
Returns Account
:
32 byte address
Native TEAL opcode:
gitxn
static
state_proof_pk
(
t
:
int
,
/
)
→
algopy.Bytes
¶
Parameters
:
t
(
int
) – transaction group index
Returns Bytes
:
64 byte state proof public key
Native TEAL opcode:
gitxn
static
tx_id
(
t
:
int
,
/
)
→
algopy.Bytes
¶
Parameters
:
t
(
int
) – transaction group index
Returns Bytes
:
The computed ID for this transaction. 32 bytes.
Native TEAL opcode:
gitxn
static
type
(
t
:
int
,
/
)
→
algopy.Bytes
¶
Parameters
:
t
(
int
) – transaction group index
Returns Bytes
:
Transaction type as bytes
Native TEAL opcode:
gitxn
static
type_enum
(
t
:
int
,
/
)
→
algopy.TransactionType
¶
Parameters
:
t
(
int
) – transaction group index
Returns TransactionType
:
Transaction type as integer
Native TEAL opcode:
gitxn
static
vote_first
(
t
:
int
,
/
)
→
algopy.UInt64
¶
Parameters
:
t
(
int
) – transaction group index
Returns UInt64
:
The first round that the participation key is valid.
Native TEAL opcode:
gitxn
static
vote_key_dilution
(
t
:
int
,
/
)
→
algopy.UInt64
¶
Parameters
:
t
(
int
) – transaction group index
Returns UInt64
:
Dilution for the 2-level participation key
Native TEAL opcode:
gitxn
static
vote_last
(
t
:
int
,
/
)
→
algopy.UInt64
¶
Parameters
:
t
(
int
) – transaction group index
Returns UInt64
:
The last round that the participation key is valid.
Native TEAL opcode:
gitxn
static
vote_pk
(
t
:
int
,
/
)
→
algopy.Bytes
¶
Parameters
:
t
(
int
) – transaction group index
Returns Bytes
:
32 byte address
Native TEAL opcode:
gitxn
static
xfer_asset
(
t
:
int
,
/
)
→
algopy.Asset
¶
Parameters
:
t
(
int
) – transaction group index
Returns Asset
:
Asset ID
Native TEAL opcode:
gitxn
class
algopy.op.
GTxn
¶
Get values for transactions in the current group
Native TEAL ops:
gtxns
,
gtxnsas
static
accounts
(
a
:
algopy.UInt64
|
int
,
b
:
algopy.UInt64
|
int
,
/
)
→
algopy.Account
¶
Accounts listed in the ApplicationCall transaction
Native TEAL opcode:
gtxna
,
gtxnas
,
gtxnsa
,
gtxnsas
static
amount
(
a
:
algopy.UInt64
|
int
,
/
)
→
algopy.UInt64
¶
microalgos
Native TEAL opcode:
gtxn
,
gtxns
static
application_args
(
a
:
algopy.UInt64
|
int
,
b
:
algopy.UInt64
|
int
,
/
,
)
→
algopy.Bytes
¶
Arguments passed to the application in the ApplicationCall transaction
Native TEAL opcode:
gtxna
,
gtxnas
,
gtxnsa
,
gtxnsas
static
application_id
(
a
:
algopy.UInt64
|
int
,
/
)
→
algopy.Application
¶
ApplicationID from ApplicationCall transaction
Native TEAL opcode:
gtxn
,
gtxns
static
applications
(
a
:
algopy.UInt64
|
int
,
b
:
algopy.UInt64
|
int
,
/
,
)
→
algopy.Application
¶
Foreign Apps listed in the ApplicationCall transaction
Native TEAL opcode:
gtxna
,
gtxnas
,
gtxnsa
,
gtxnsas
static
approval_program
(
a
:
algopy.UInt64
|
int
,
/
)
→
algopy.Bytes
¶
Approval program
Native TEAL opcode:
gtxn
,
gtxns
static
approval_program_pages
(
a
:
algopy.UInt64
|
int
,
b
:
algopy.UInt64
|
int
,
/
,
)
→
algopy.Bytes
¶
Approval Program as an array of pages
Native TEAL opcode:
gtxna
,
gtxnas
,
gtxnsa
,
gtxnsas
static
asset_amount
(
a
:
algopy.UInt64
|
int
,
/
)
→
algopy.UInt64
¶
value in Asset’s units
Native TEAL opcode:
gtxn
,
gtxns
static
asset_close_to
(
a
:
algopy.UInt64
|
int
,
/
)
→
algopy.Account
¶
32 byte address
Native TEAL opcode:
gtxn
,
gtxns
static
asset_receiver
(
a
:
algopy.UInt64
|
int
,
/
)
→
algopy.Account
¶
32 byte address
Native TEAL opcode:
gtxn
,
gtxns
static
asset_sender
(
a
:
algopy.UInt64
|
int
,
/
)
→
algopy.Account
¶
32 byte address. Source of assets if Sender is the Asset’s Clawback address.
Native TEAL opcode:
gtxn
,
gtxns
static
assets
(
a
:
algopy.UInt64
|
int
,
b
:
algopy.UInt64
|
int
,
/
)
→
algopy.Asset
¶
Foreign Assets listed in the ApplicationCall transaction
Native TEAL opcode:
gtxna
,
gtxnas
,
gtxnsa
,
gtxnsas
static
clear_state_program
(
a
:
algopy.UInt64
|
int
,
/
)
→
algopy.Bytes
¶
Clear state program
Native TEAL opcode:
gtxn
,
gtxns
static
clear_state_program_pages
(
a
:
algopy.UInt64
|
int
,
b
:
algopy.UInt64
|
int
,
/
,
)
→
algopy.Bytes
¶
ClearState Program as an array of pages
Native TEAL opcode:
gtxna
,
gtxnas
,
gtxnsa
,
gtxnsas
static
close_remainder_to
(
a
:
algopy.UInt64
|
int
,
/
)
→
algopy.Account
¶
32 byte address
Native TEAL opcode:
gtxn
,
gtxns
static
config_asset
(
a
:
algopy.UInt64
|
int
,
/
)
→
algopy.Asset
¶
Asset ID in asset config transaction
Native TEAL opcode:
gtxn
,
gtxns
static
config_asset_clawback
(
a
:
algopy.UInt64
|
int
,
/
)
→
algopy.Account
¶
32 byte address
Native TEAL opcode:
gtxn
,
gtxns
static
config_asset_decimals
(
a
:
algopy.UInt64
|
int
,
/
)
→
algopy.UInt64
¶
Number of digits to display after the decimal place when displaying the asset
Native TEAL opcode:
gtxn
,
gtxns
static
config_asset_default_frozen
(
a
:
algopy.UInt64
|
int
,
/
)
→
bool
¶
Whether the asset’s slots are frozen by default or not, 0 or 1
Native TEAL opcode:
gtxn
,
gtxns
static
config_asset_freeze
(
a
:
algopy.UInt64
|
int
,
/
)
→
algopy.Account
¶
32 byte address
Native TEAL opcode:
gtxn
,
gtxns
static
config_asset_manager
(
a
:
algopy.UInt64
|
int
,
/
)
→
algopy.Account
¶
32 byte address
Native TEAL opcode:
gtxn
,
gtxns
static
config_asset_metadata_hash
(
a
:
algopy.UInt64
|
int
,
/
)
→
algopy.Bytes
¶
32 byte commitment to unspecified asset metadata
Native TEAL opcode:
gtxn
,
gtxns
static
config_asset_name
(
a
:
algopy.UInt64
|
int
,
/
)
→
algopy.Bytes
¶
The asset name
Native TEAL opcode:
gtxn
,
gtxns
static
config_asset_reserve
(
a
:
algopy.UInt64
|
int
,
/
)
→
algopy.Account
¶
32 byte address
Native TEAL opcode:
gtxn
,
gtxns
static
config_asset_total
(
a
:
algopy.UInt64
|
int
,
/
)
→
algopy.UInt64
¶
Total number of units of this asset created
Native TEAL opcode:
gtxn
,
gtxns
static
config_asset_unit_name
(
a
:
algopy.UInt64
|
int
,
/
)
→
algopy.Bytes
¶
Unit name of the asset
Native TEAL opcode:
gtxn
,
gtxns
static
config_asset_url
(
a
:
algopy.UInt64
|
int
,
/
)
→
algopy.Bytes
¶
URL
Native TEAL opcode:
gtxn
,
gtxns
static
created_application_id
(
a
:
algopy.UInt64
|
int
,
/
)
→
algopy.Application
¶
ApplicationID allocated by the creation of an application (only with
itxn
in v5). Application mode only
Native TEAL opcode:
gtxn
,
gtxns
static
created_asset_id
(
a
:
algopy.UInt64
|
int
,
/
)
→
algopy.Asset
¶
Asset ID allocated by the creation of an ASA (only with
itxn
in v5). Application mode only
Native TEAL opcode:
gtxn
,
gtxns
static
extra_program_pages
(
a
:
algopy.UInt64
|
int
,
/
)
→
algopy.UInt64
¶
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.
Native TEAL opcode:
gtxn
,
gtxns
static
fee
(
a
:
algopy.UInt64
|
int
,
/
)
→
algopy.UInt64
¶
microalgos
Native TEAL opcode:
gtxn
,
gtxns
static
first_valid
(
a
:
algopy.UInt64
|
int
,
/
)
→
algopy.UInt64
¶
round number
Native TEAL opcode:
gtxn
,
gtxns
static
first_valid_time
(
a
:
algopy.UInt64
|
int
,
/
)
→
algopy.UInt64
¶
UNIX timestamp of block before txn.FirstValid. Fails if negative
Native TEAL opcode:
gtxn
,
gtxns
static
freeze_asset
(
a
:
algopy.UInt64
|
int
,
/
)
→
algopy.Asset
¶
Asset ID being frozen or un-frozen
Native TEAL opcode:
gtxn
,
gtxns
static
freeze_asset_account
(
a
:
algopy.UInt64
|
int
,
/
)
→
algopy.Account
¶
32 byte address of the account whose asset slot is being frozen or un-frozen
Native TEAL opcode:
gtxn
,
gtxns
static
freeze_asset_frozen
(
a
:
algopy.UInt64
|
int
,
/
)
→
bool
¶
The new frozen value, 0 or 1
Native TEAL opcode:
gtxn
,
gtxns
static
global_num_byte_slice
(
a
:
algopy.UInt64
|
int
,
/
)
→
algopy.UInt64
¶
Number of global state byteslices in ApplicationCall
Native TEAL opcode:
gtxn
,
gtxns
static
global_num_uint
(
a
:
algopy.UInt64
|
int
,
/
)
→
algopy.UInt64
¶
Number of global state integers in ApplicationCall
Native TEAL opcode:
gtxn
,
gtxns
static
group_index
(
a
:
algopy.UInt64
|
int
,
/
)
→
algopy.UInt64
¶
Position of this transaction within an atomic transaction group. A stand-alone transaction is implicitly element 0 in a group of 1
Native TEAL opcode:
gtxn
,
gtxns
static
last_log
(
a
:
algopy.UInt64
|
int
,
/
)
→
algopy.Bytes
¶
The last message emitted. Empty bytes if none were emitted. Application mode only
Native TEAL opcode:
gtxn
,
gtxns
static
last_valid
(
a
:
algopy.UInt64
|
int
,
/
)
→
algopy.UInt64
¶
round number
Native TEAL opcode:
gtxn
,
gtxns
static
lease
(
a
:
algopy.UInt64
|
int
,
/
)
→
algopy.Bytes
¶
32 byte lease value
Native TEAL opcode:
gtxn
,
gtxns
static
local_num_byte_slice
(
a
:
algopy.UInt64
|
int
,
/
)
→
algopy.UInt64
¶
Number of local state byteslices in ApplicationCall
Native TEAL opcode:
gtxn
,
gtxns
static
local_num_uint
(
a
:
algopy.UInt64
|
int
,
/
)
→
algopy.UInt64
¶
Number of local state integers in ApplicationCall
Native TEAL opcode:
gtxn
,
gtxns
static
logs
(
a
:
algopy.UInt64
|
int
,
b
:
algopy.UInt64
|
int
,
/
)
→
algopy.Bytes
¶
Log messages emitted by an application call (only with
itxn
in v5). Application mode only
Native TEAL opcode:
gtxna
,
gtxnas
,
gtxnsa
,
gtxnsas
static
nonparticipation
(
a
:
algopy.UInt64
|
int
,
/
)
→
bool
¶
Marks an account nonparticipating for rewards
Native TEAL opcode:
gtxn
,
gtxns
static
note
(
a
:
algopy.UInt64
|
int
,
/
)
→
algopy.Bytes
¶
Any data up to 1024 bytes
Native TEAL opcode:
gtxn
,
gtxns
static
num_accounts
(
a
:
algopy.UInt64
|
int
,
/
)
→
algopy.UInt64
¶
Number of Accounts
Native TEAL opcode:
gtxn
,
gtxns
static
num_app_args
(
a
:
algopy.UInt64
|
int
,
/
)
→
algopy.UInt64
¶
Number of ApplicationArgs
Native TEAL opcode:
gtxn
,
gtxns
static
num_applications
(
a
:
algopy.UInt64
|
int
,
/
)
→
algopy.UInt64
¶
Number of Applications
Native TEAL opcode:
gtxn
,
gtxns
static
num_approval_program_pages
(
a
:
algopy.UInt64
|
int
,
/
)
→
algopy.UInt64
¶
Number of Approval Program pages
Native TEAL opcode:
gtxn
,
gtxns
static
num_assets
(
a
:
algopy.UInt64
|
int
,
/
)
→
algopy.UInt64
¶
Number of Assets
Native TEAL opcode:
gtxn
,
gtxns
static
num_clear_state_program_pages
(
a
:
algopy.UInt64
|
int
,
/
)
→
algopy.UInt64
¶
Number of ClearState Program pages
Native TEAL opcode:
gtxn
,
gtxns
static
num_logs
(
a
:
algopy.UInt64
|
int
,
/
)
→
algopy.UInt64
¶
Number of Logs (only with
itxn
in v5). Application mode only
Native TEAL opcode:
gtxn
,
gtxns
static
on_completion
(
a
:
algopy.UInt64
|
int
,
/
)
→
algopy.OnCompleteAction
¶
ApplicationCall transaction on completion action
Native TEAL opcode:
gtxn
,
gtxns
static
receiver
(
a
:
algopy.UInt64
|
int
,
/
)
→
algopy.Account
¶
32 byte address
Native TEAL opcode:
gtxn
,
gtxns
static
rekey_to
(
a
:
algopy.UInt64
|
int
,
/
)
→
algopy.Account
¶
32 byte Sender’s new AuthAddr
Native TEAL opcode:
gtxn
,
gtxns
static
selection_pk
(
a
:
algopy.UInt64
|
int
,
/
)
→
algopy.Bytes
¶
32 byte address
Native TEAL opcode:
gtxn
,
gtxns
static
sender
(
a
:
algopy.UInt64
|
int
,
/
)
→
algopy.Account
¶
32 byte address
Native TEAL opcode:
gtxn
,
gtxns
static
state_proof_pk
(
a
:
algopy.UInt64
|
int
,
/
)
→
algopy.Bytes
¶
64 byte state proof public key
Native TEAL opcode:
gtxn
,
gtxns
static
tx_id
(
a
:
algopy.UInt64
|
int
,
/
)
→
algopy.Bytes
¶
The computed ID for this transaction. 32 bytes.
Native TEAL opcode:
gtxn
,
gtxns
static
type
(
a
:
algopy.UInt64
|
int
,
/
)
→
algopy.Bytes
¶
Transaction type as bytes
Native TEAL opcode:
gtxn
,
gtxns
static
type_enum
(
a
:
algopy.UInt64
|
int
,
/
)
→
algopy.TransactionType
¶
Transaction type as integer
Native TEAL opcode:
gtxn
,
gtxns
static
vote_first
(
a
:
algopy.UInt64
|
int
,
/
)
→
algopy.UInt64
¶
The first round that the participation key is valid.
Native TEAL opcode:
gtxn
,
gtxns
static
vote_key_dilution
(
a
:
algopy.UInt64
|
int
,
/
)
→
algopy.UInt64
¶
Dilution for the 2-level participation key
Native TEAL opcode:
gtxn
,
gtxns
static
vote_last
(
a
:
algopy.UInt64
|
int
,
/
)
→
algopy.UInt64
¶
The last round that the participation key is valid.
Native TEAL opcode:
gtxn
,
gtxns
static
vote_pk
(
a
:
algopy.UInt64
|
int
,
/
)
→
algopy.Bytes
¶
32 byte address
Native TEAL opcode:
gtxn
,
gtxns
static
xfer_asset
(
a
:
algopy.UInt64
|
int
,
/
)
→
algopy.Asset
¶
Asset ID
Native TEAL opcode:
gtxn
,
gtxns
class
algopy.op.
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.op.
ITxn
¶
Get values for the last inner transaction
Native TEAL ops:
itxn
,
itxnas
static
accounts
(
a
:
algopy.UInt64
|
int
,
/
)
→
algopy.Account
¶
Accounts listed in the ApplicationCall transaction
Native TEAL opcode:
itxna
,
itxnas
static
amount
(
)
→
algopy.UInt64
¶
microalgos
Native TEAL opcode:
itxn
static
application_args
(
a
:
algopy.UInt64
|
int
,
/
)
→
algopy.Bytes
¶
Arguments passed to the application in the ApplicationCall transaction
Native TEAL opcode:
itxna
,
itxnas
static
application_id
(
)
→
algopy.Application
¶
ApplicationID from ApplicationCall transaction
Native TEAL opcode:
itxn
static
applications
(
a
:
algopy.UInt64
|
int
,
/
)
→
algopy.Application
¶
Foreign Apps listed in the ApplicationCall transaction
Native TEAL opcode:
itxna
,
itxnas
static
approval_program
(
)
→
algopy.Bytes
¶
Approval program
Native TEAL opcode:
itxn
static
approval_program_pages
(
a
:
algopy.UInt64
|
int
,
/
)
→
algopy.Bytes
¶
Approval Program as an array of pages
Native TEAL opcode:
itxna
,
itxnas
static
asset_amount
(
)
→
algopy.UInt64
¶
value in Asset’s units
Native TEAL opcode:
itxn
static
asset_close_to
(
)
→
algopy.Account
¶
32 byte address
Native TEAL opcode:
itxn
static
asset_receiver
(
)
→
algopy.Account
¶
32 byte address
Native TEAL opcode:
itxn
static
asset_sender
(
)
→
algopy.Account
¶
32 byte address. Source of assets if Sender is the Asset’s Clawback address.
Native TEAL opcode:
itxn
static
assets
(
a
:
algopy.UInt64
|
int
,
/
)
→
algopy.Asset
¶
Foreign Assets listed in the ApplicationCall transaction
Native TEAL opcode:
itxna
,
itxnas
static
clear_state_program
(
)
→
algopy.Bytes
¶
Clear state program
Native TEAL opcode:
itxn
static
clear_state_program_pages
(
a
:
algopy.UInt64
|
int
,
/
)
→
algopy.Bytes
¶
ClearState Program as an array of pages
Native TEAL opcode:
itxna
,
itxnas
static
close_remainder_to
(
)
→
algopy.Account
¶
32 byte address
Native TEAL opcode:
itxn
static
config_asset
(
)
→
algopy.Asset
¶
Asset ID in asset config transaction
Native TEAL opcode:
itxn
static
config_asset_clawback
(
)
→
algopy.Account
¶
32 byte address
Native TEAL opcode:
itxn
static
config_asset_decimals
(
)
→
algopy.UInt64
¶
Number of digits to display after the decimal place when displaying the asset
Native TEAL opcode:
itxn
static
config_asset_default_frozen
(
)
→
bool
¶
Whether the asset’s slots are frozen by default or not, 0 or 1
Native TEAL opcode:
itxn
static
config_asset_freeze
(
)
→
algopy.Account
¶
32 byte address
Native TEAL opcode:
itxn
static
config_asset_manager
(
)
→
algopy.Account
¶
32 byte address
Native TEAL opcode:
itxn
static
config_asset_metadata_hash
(
)
→
algopy.Bytes
¶
32 byte commitment to unspecified asset metadata
Native TEAL opcode:
itxn
static
config_asset_name
(
)
→
algopy.Bytes
¶
The asset name
Native TEAL opcode:
itxn
static
config_asset_reserve
(
)
→
algopy.Account
¶
32 byte address
Native TEAL opcode:
itxn
static
config_asset_total
(
)
→
algopy.UInt64
¶
Total number of units of this asset created
Native TEAL opcode:
itxn
static
config_asset_unit_name
(
)
→
algopy.Bytes
¶
Unit name of the asset
Native TEAL opcode:
itxn
static
config_asset_url
(
)
→
algopy.Bytes
¶
URL
Native TEAL opcode:
itxn
static
created_application_id
(
)
→
algopy.Application
¶
ApplicationID allocated by the creation of an application (only with
itxn
in v5). Application mode only
Native TEAL opcode:
itxn
static
created_asset_id
(
)
→
algopy.Asset
¶
Asset ID allocated by the creation of an ASA (only with
itxn
in v5). Application mode only
Native TEAL opcode:
itxn
static
extra_program_pages
(
)
→
algopy.UInt64
¶
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.
Native TEAL opcode:
itxn
static
fee
(
)
→
algopy.UInt64
¶
microalgos
Native TEAL opcode:
itxn
static
first_valid
(
)
→
algopy.UInt64
¶
round number
Native TEAL opcode:
itxn
static
first_valid_time
(
)
→
algopy.UInt64
¶
UNIX timestamp of block before txn.FirstValid. Fails if negative
Native TEAL opcode:
itxn
static
freeze_asset
(
)
→
algopy.Asset
¶
Asset ID being frozen or un-frozen
Native TEAL opcode:
itxn
static
freeze_asset_account
(
)
→
algopy.Account
¶
32 byte address of the account whose asset slot is being frozen or un-frozen
Native TEAL opcode:
itxn
static
freeze_asset_frozen
(
)
→
bool
¶
The new frozen value, 0 or 1
Native TEAL opcode:
itxn
static
global_num_byte_slice
(
)
→
algopy.UInt64
¶
Number of global state byteslices in ApplicationCall
Native TEAL opcode:
itxn
static
global_num_uint
(
)
→
algopy.UInt64
¶
Number of global state integers in ApplicationCall
Native TEAL opcode:
itxn
static
group_index
(
)
→
algopy.UInt64
¶
Position of this transaction within an atomic transaction group. A stand-alone transaction is implicitly element 0 in a group of 1
Native TEAL opcode:
itxn
static
last_log
(
)
→
algopy.Bytes
¶
The last message emitted. Empty bytes if none were emitted. Application mode only
Native TEAL opcode:
itxn
static
last_valid
(
)
→
algopy.UInt64
¶
round number
Native TEAL opcode:
itxn
static
lease
(
)
→
algopy.Bytes
¶
32 byte lease value
Native TEAL opcode:
itxn
static
local_num_byte_slice
(
)
→
algopy.UInt64
¶
Number of local state byteslices in ApplicationCall
Native TEAL opcode:
itxn
static
local_num_uint
(
)
→
algopy.UInt64
¶
Number of local state integers in ApplicationCall
Native TEAL opcode:
itxn
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:
itxna
,
itxnas
static
nonparticipation
(
)
→
bool
¶
Marks an account nonparticipating for rewards
Native TEAL opcode:
itxn
static
note
(
)
→
algopy.Bytes
¶
Any data up to 1024 bytes
Native TEAL opcode:
itxn
static
num_accounts
(
)
→
algopy.UInt64
¶
Number of Accounts
Native TEAL opcode:
itxn
static
num_app_args
(
)
→
algopy.UInt64
¶
Number of ApplicationArgs
Native TEAL opcode:
itxn
static
num_applications
(
)
→
algopy.UInt64
¶
Number of Applications
Native TEAL opcode:
itxn
static
num_approval_program_pages
(
)
→
algopy.UInt64
¶
Number of Approval Program pages
Native TEAL opcode:
itxn
static
num_assets
(
)
→
algopy.UInt64
¶
Number of Assets
Native TEAL opcode:
itxn
static
num_clear_state_program_pages
(
)
→
algopy.UInt64
¶
Number of ClearState Program pages
Native TEAL opcode:
itxn
static
num_logs
(
)
→
algopy.UInt64
¶
Number of Logs (only with
itxn
in v5). Application mode only
Native TEAL opcode:
itxn
static
on_completion
(
)
→
algopy.OnCompleteAction
¶
ApplicationCall transaction on completion action
Native TEAL opcode:
itxn
static
receiver
(
)
→
algopy.Account
¶
32 byte address
Native TEAL opcode:
itxn
static
rekey_to
(
)
→
algopy.Account
¶
32 byte Sender’s new AuthAddr
Native TEAL opcode:
itxn
static
selection_pk
(
)
→
algopy.Bytes
¶
32 byte address
Native TEAL opcode:
itxn
static
sender
(
)
→
algopy.Account
¶
32 byte address
Native TEAL opcode:
itxn
static
state_proof_pk
(
)
→
algopy.Bytes
¶
64 byte state proof public key
Native TEAL opcode:
itxn
static
tx_id
(
)
→
algopy.Bytes
¶
The computed ID for this transaction. 32 bytes.
Native TEAL opcode:
itxn
static
type
(
)
→
algopy.Bytes
¶
Transaction type as bytes
Native TEAL opcode:
itxn
static
type_enum
(
)
→
algopy.TransactionType
¶
Transaction type as integer
Native TEAL opcode:
itxn
static
vote_first
(
)
→
algopy.UInt64
¶
The first round that the participation key is valid.
Native TEAL opcode:
itxn
static
vote_key_dilution
(
)
→
algopy.UInt64
¶
Dilution for the 2-level participation key
Native TEAL opcode:
itxn
static
vote_last
(
)
→
algopy.UInt64
¶
The last round that the participation key is valid.
Native TEAL opcode:
itxn
static
vote_pk
(
)
→
algopy.Bytes
¶
32 byte address
Native TEAL opcode:
itxn
static
xfer_asset
(
)
→
algopy.Asset
¶
Asset ID
Native TEAL opcode:
itxn
class
algopy.op.
ITxnCreate
¶
Create inner transactions
Native TEAL ops:
itxn_begin
,
itxn_field
,
itxn_next
,
itxn_submit
static
begin
(
)
→
None
¶
begin preparation of a new inner transaction in a new transaction group
itxn_begin
initializes Sender to the application address; Fee to the minimum allowable, taking into account MinTxnFee and credit from overpaying in earlier transactions; FirstValid/LastValid to the values in the invoking transaction, and all other fields to zero or empty values.
Native TEAL opcode:
itxn_begin
static
next
(
)
→
None
¶
begin preparation of a new inner transaction in the same transaction group
itxn_next
initializes the transaction exactly as
itxn_begin
does
Native TEAL opcode:
itxn_next
static
set_accounts
(
a
:
algopy.Account
,
/
)
→
None
¶
Parameters
:
a
(
Account
) – Accounts listed in the ApplicationCall transaction
Native TEAL opcode:
itxn_field
static
set_amount
(
a
:
algopy.UInt64
|
int
,
/
)
→
None
¶
Parameters
:
a
(
UInt64
|
int
) – microalgos
Native TEAL opcode:
itxn_field
static
set_application_args
(
a
:
algopy.Bytes
|
bytes
,
/
)
→
None
¶
Parameters
:
a
(
Bytes
|
bytes
) – Arguments passed to the application in the ApplicationCall transaction
Native TEAL opcode:
itxn_field
static
set_application_id
(
a
:
algopy.Application
|
algopy.UInt64
|
int
,
/
)
→
None
¶
Parameters
:
a
(
Application
|
UInt64
|
int
) – ApplicationID from ApplicationCall transaction
Native TEAL opcode:
itxn_field
static
set_applications
(
a
:
algopy.UInt64
|
int
,
/
)
→
None
¶
Parameters
:
a
(
UInt64
|
int
) – Foreign Apps listed in the ApplicationCall transaction
Native TEAL opcode:
itxn_field
static
set_approval_program
(
a
:
algopy.Bytes
|
bytes
,
/
)
→
None
¶
Parameters
:
a
(
Bytes
|
bytes
) – Approval program
Native TEAL opcode:
itxn_field
static
set_approval_program_pages
(
a
:
algopy.Bytes
|
bytes
,
/
)
→
None
¶
Parameters
:
a
(
Bytes
|
bytes
) – Approval Program as an array of pages
Native TEAL opcode:
itxn_field
static
set_asset_amount
(
a
:
algopy.UInt64
|
int
,
/
)
→
None
¶
Parameters
:
a
(
UInt64
|
int
) – value in Asset’s units
Native TEAL opcode:
itxn_field
static
set_asset_close_to
(
a
:
algopy.Account
,
/
)
→
None
¶
Parameters
:
a
(
Account
) – 32 byte address
Native TEAL opcode:
itxn_field
static
set_asset_receiver
(
a
:
algopy.Account
,
/
)
→
None
¶
Parameters
:
a
(
Account
) – 32 byte address
Native TEAL opcode:
itxn_field
static
set_asset_sender
(
a
:
algopy.Account
,
/
)
→
None
¶
Parameters
:
a
(
Account
) – 32 byte address. Source of assets if Sender is the Asset’s Clawback address.
Native TEAL opcode:
itxn_field
static
set_assets
(
a
:
algopy.UInt64
|
int
,
/
)
→
None
¶
Parameters
:
a
(
UInt64
|
int
) – Foreign Assets listed in the ApplicationCall transaction
Native TEAL opcode:
itxn_field
static
set_clear_state_program
(
a
:
algopy.Bytes
|
bytes
,
/
)
→
None
¶
Parameters
:
a
(
Bytes
|
bytes
) – Clear state program
Native TEAL opcode:
itxn_field
static
set_clear_state_program_pages
(
a
:
algopy.Bytes
|
bytes
,
/
)
→
None
¶
Parameters
:
a
(
Bytes
|
bytes
) – ClearState Program as an array of pages
Native TEAL opcode:
itxn_field
static
set_close_remainder_to
(
a
:
algopy.Account
,
/
)
→
None
¶
Parameters
:
a
(
Account
) – 32 byte address
Native TEAL opcode:
itxn_field
static
set_config_asset
(
a
:
algopy.Asset
|
algopy.UInt64
|
int
,
/
)
→
None
¶
Parameters
:
a
(
Asset
|
UInt64
|
int
) – Asset ID in asset config transaction
Native TEAL opcode:
itxn_field
static
set_config_asset_clawback
(
a
:
algopy.Account
,
/
)
→
None
¶
Parameters
:
a
(
Account
) – 32 byte address
Native TEAL opcode:
itxn_field
static
set_config_asset_decimals
(
a
:
algopy.UInt64
|
int
,
/
)
→
None
¶
Parameters
:
a
(
UInt64
|
int
) – Number of digits to display after the decimal place when displaying the asset
Native TEAL opcode:
itxn_field
static
set_config_asset_default_frozen
(
a
:
bool
|
algopy.UInt64
|
int
,
/
)
→
None
¶
Parameters
:
a
(
bool
|
UInt64
|
int
) – Whether the asset’s slots are frozen by default or not, 0 or 1
Native TEAL opcode:
itxn_field
static
set_config_asset_freeze
(
a
:
algopy.Account
,
/
)
→
None
¶
Parameters
:
a
(
Account
) – 32 byte address
Native TEAL opcode:
itxn_field
static
set_config_asset_manager
(
a
:
algopy.Account
,
/
)
→
None
¶
Parameters
:
a
(
Account
) – 32 byte address
Native TEAL opcode:
itxn_field
static
set_config_asset_metadata_hash
(
a
:
algopy.Bytes
|
bytes
,
/
)
→
None
¶
Parameters
:
a
(
Bytes
|
bytes
) – 32 byte commitment to unspecified asset metadata
Native TEAL opcode:
itxn_field
static
set_config_asset_name
(
a
:
algopy.Bytes
|
bytes
,
/
)
→
None
¶
Parameters
:
a
(
Bytes
|
bytes
) – The asset name
Native TEAL opcode:
itxn_field
static
set_config_asset_reserve
(
a
:
algopy.Account
,
/
)
→
None
¶
Parameters
:
a
(
Account
) – 32 byte address
Native TEAL opcode:
itxn_field
static
set_config_asset_total
(
a
:
algopy.UInt64
|
int
,
/
)
→
None
¶
Parameters
:
a
(
UInt64
|
int
) – Total number of units of this asset created
Native TEAL opcode:
itxn_field
static
set_config_asset_unit_name
(
a
:
algopy.Bytes
|
bytes
,
/
)
→
None
¶
Parameters
:
a
(
Bytes
|
bytes
) – Unit name of the asset
Native TEAL opcode:
itxn_field
static
set_config_asset_url
(
a
:
algopy.Bytes
|
bytes
,
/
)
→
None
¶
Parameters
:
a
(
Bytes
|
bytes
) – URL
Native TEAL opcode:
itxn_field
static
set_extra_program_pages
(
a
:
algopy.UInt64
|
int
,
/
)
→
None
¶
Parameters
:
a
(
UInt64
|
int
) – 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.
Native TEAL opcode:
itxn_field
static
set_fee
(
a
:
algopy.UInt64
|
int
,
/
)
→
None
¶
Parameters
:
a
(
UInt64
|
int
) – microalgos
Native TEAL opcode:
itxn_field
static
set_freeze_asset
(
a
:
algopy.Asset
|
algopy.UInt64
|
int
,
/
)
→
None
¶
Parameters
:
a
(
Asset
|
UInt64
|
int
) – Asset ID being frozen or un-frozen
Native TEAL opcode:
itxn_field
static
set_freeze_asset_account
(
a
:
algopy.Account
,
/
)
→
None
¶
Parameters
:
a
(
Account
) – 32 byte address of the account whose asset slot is being frozen or un-frozen
Native TEAL opcode:
itxn_field
static
set_freeze_asset_frozen
(
a
:
bool
|
algopy.UInt64
|
int
,
/
)
→
None
¶
Parameters
:
a
(
bool
|
UInt64
|
int
) – The new frozen value, 0 or 1
Native TEAL opcode:
itxn_field
static
set_global_num_byte_slice
(
a
:
algopy.UInt64
|
int
,
/
)
→
None
¶
Parameters
:
a
(
UInt64
|
int
) – Number of global state byteslices in ApplicationCall
Native TEAL opcode:
itxn_field
static
set_global_num_uint
(
a
:
algopy.UInt64
|
int
,
/
)
→
None
¶
Parameters
:
a
(
UInt64
|
int
) – Number of global state integers in ApplicationCall
Native TEAL opcode:
itxn_field
static
set_local_num_byte_slice
(
a
:
algopy.UInt64
|
int
,
/
)
→
None
¶
Parameters
:
a
(
UInt64
|
int
) – Number of local state byteslices in ApplicationCall
Native TEAL opcode:
itxn_field
static
set_local_num_uint
(
a
:
algopy.UInt64
|
int
,
/
)
→
None
¶
Parameters
:
a
(
UInt64
|
int
) – Number of local state integers in ApplicationCall
Native TEAL opcode:
itxn_field
static
set_nonparticipation
(
a
:
bool
|
algopy.UInt64
|
int
,
/
)
→
None
¶
Parameters
:
a
(
bool
|
UInt64
|
int
) – Marks an account nonparticipating for rewards
Native TEAL opcode:
itxn_field
static
set_note
(
a
:
algopy.Bytes
|
bytes
,
/
)
→
None
¶
Parameters
:
a
(
Bytes
|
bytes
) – Any data up to 1024 bytes
Native TEAL opcode:
itxn_field
static
set_on_completion
(
a
:
algopy.UInt64
|
int
,
/
)
→
None
¶
Parameters
:
a
(
UInt64
|
int
) – ApplicationCall transaction on completion action
Native TEAL opcode:
itxn_field
static
set_receiver
(
a
:
algopy.Account
,
/
)
→
None
¶
Parameters
:
a
(
Account
) – 32 byte address
Native TEAL opcode:
itxn_field
static
set_rekey_to
(
a
:
algopy.Account
,
/
)
→
None
¶
Parameters
:
a
(
Account
) – 32 byte Sender’s new AuthAddr
Native TEAL opcode:
itxn_field
static
set_selection_pk
(
a
:
algopy.Bytes
|
bytes
,
/
)
→
None
¶
Parameters
:
a
(
Bytes
|
bytes
) – 32 byte address
Native TEAL opcode:
itxn_field
static
set_sender
(
a
:
algopy.Account
,
/
)
→
None
¶
Parameters
:
a
(
Account
) – 32 byte address
Native TEAL opcode:
itxn_field
static
set_state_proof_pk
(
a
:
algopy.Bytes
|
bytes
,
/
)
→
None
¶
Parameters
:
a
(
Bytes
|
bytes
) – 64 byte state proof public key
Native TEAL opcode:
itxn_field
static
set_type
(
a
:
algopy.Bytes
|
bytes
,
/
)
→
None
¶
Parameters
:
a
(
Bytes
|
bytes
) – Transaction type as bytes
Native TEAL opcode:
itxn_field
static
set_type_enum
(
a
:
algopy.UInt64
|
int
,
/
)
→
None
¶
Parameters
:
a
(
UInt64
|
int
) – Transaction type as integer
Native TEAL opcode:
itxn_field
static
set_vote_first
(
a
:
algopy.UInt64
|
int
,
/
)
→
None
¶
Parameters
:
a
(
UInt64
|
int
) – The first round that the participation key is valid.
Native TEAL opcode:
itxn_field
static
set_vote_key_dilution
(
a
:
algopy.UInt64
|
int
,
/
)
→
None
¶
Parameters
:
a
(
UInt64
|
int
) – Dilution for the 2-level participation key
Native TEAL opcode:
itxn_field
static
set_vote_last
(
a
:
algopy.UInt64
|
int
,
/
)
→
None
¶
Parameters
:
a
(
UInt64
|
int
) – The last round that the participation key is valid.
Native TEAL opcode:
itxn_field
static
set_vote_pk
(
a
:
algopy.Bytes
|
bytes
,
/
)
→
None
¶
Parameters
:
a
(
Bytes
|
bytes
) – 32 byte address
Native TEAL opcode:
itxn_field
static
set_xfer_asset
(
a
:
algopy.Asset
|
algopy.UInt64
|
int
,
/
)
→
None
¶
Parameters
:
a
(
Asset
|
UInt64
|
int
) – Asset ID
Native TEAL opcode:
itxn_field
static
submit
(
)
→
None
¶
execute the current inner transaction group. Fail if executing this group would exceed the inner transaction limit, or if any transaction in the group fails.
itxn_submit
resets the current transaction so that it can not be resubmitted. A new
itxn_begin
is required to prepare another inner transaction.
Native TEAL opcode:
itxn_submit
class
algopy.op.
JsonRef
¶
key B’s value, of type R, from a
valid
utf-8 encoded json object A
Warning
: Usage should be restricted to very rare use cases, as JSON decoding is expensive and quite limited. In addition, JSON objects are large and not optimized for size. Almost all smart contracts should use simpler and smaller methods (such as the
ABI
. This opcode should only be used in cases where JSON is only available option, e.g. when a third-party only signs JSON.
Native TEAL op:
json_ref
static
json_object
(
a
:
algopy.Bytes
|
bytes
,
b
:
algopy.Bytes
|
bytes
,
/
)
→
algopy.Bytes
¶
Native TEAL opcode:
json_ref
static
json_string
(
a
:
algopy.Bytes
|
bytes
,
b
:
algopy.Bytes
|
bytes
,
/
)
→
algopy.Bytes
¶
Native TEAL opcode:
json_ref
static
json_uint64
(
a
:
algopy.Bytes
|
bytes
,
b
:
algopy.Bytes
|
bytes
,
/
,
)
→
algopy.UInt64
¶
Native TEAL opcode:
json_ref
class
algopy.op.
MiMCConfigurations
¶
Available values for the
Mimc
Configurations
enum
Initialization
Initialize self. See help(type(self)) for accurate signature.
BLS12_381Mp111
:
algopy.op.MiMCConfigurations
¶
Ellipsis
MiMC configuration for the BLS12-381 curve with Miyaguchi-Preneel mode, 111 rounds, exponent 5, seed “seed”
Min AVM version: 11
BN254Mp110
:
algopy.op.MiMCConfigurations
¶
Ellipsis
MiMC configuration for the BN254 curve with Miyaguchi-Preneel mode, 110 rounds, exponent 5, seed “seed”
Min AVM version: 11
__add__
(
)
¶
Return self+value.
__contains__
(
)
¶
Return bool(key in self).
__delattr__
(
)
¶
Implement delattr(self, name).
__dir__
(
)
¶
Default dir() implementation.
__eq__
(
)
¶
Return self==value.
__format__
(
)
¶
Return a formatted version of the string as described by format_spec.
__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.
__mod__
(
)
¶
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).
__rmod__
(
)
¶
Return value%self.
__rmul__
(
)
¶
Return value*self.
__setattr__
(
)
¶
Implement setattr(self, name, value).
__sizeof__
(
)
¶
Return the size of the string in memory, in bytes.
__str__
(
)
¶
Return str(self).
capitalize
(
)
¶
Return a capitalized version of the string.
More specifically, make the first character have upper case and the rest lower
case.
casefold
(
)
¶
Return a version of the string suitable for caseless comparisons.
center
(
)
¶
Return a centered string of length width.
Padding is done using the specified fill character (default is a space).
count
(
)
¶
S.count(sub[, start[, end]]) -> int
Return the number of non-overlapping occurrences of substring sub in
string S[start:end]. Optional arguments start and end are
interpreted as in slice notation.
encode
(
)
¶
Encode the string using the codec registered for encoding.
encoding
The encoding in which to encode the string.
errors
The error handling scheme to use for encoding errors.
The default is ‘strict’ meaning that encoding errors raise a
UnicodeEncodeError. Other possible values are ‘ignore’, ‘replace’ and
‘xmlcharrefreplace’ as well as any other name registered with
codecs.register_error that can handle UnicodeEncodeErrors.
endswith
(
)
¶
S.endswith(suffix[, start[, end]]) -> bool
Return True if S ends with the specified suffix, False otherwise.
With optional start, test S beginning at that position.
With optional end, stop comparing S at that position.
suffix can also be a tuple of strings to try.
expandtabs
(
)
¶
Return a copy where all tab characters are expanded using spaces.
If tabsize is not given, a tab size of 8 characters is assumed.
find
(
)
¶
S.find(sub[, start[, end]]) -> int
Return the lowest index in S where substring sub is found,
such that sub is contained within S[start:end]. Optional
arguments start and end are interpreted as in slice notation.
Return -1 on failure.
format
(
)
¶
S.format(*args, **kwargs) -> str
Return a formatted version of S, using substitutions from args and kwargs.
The substitutions are identified by braces (‘{’ and ‘}’).
format_map
(
)
¶
S.format_map(mapping) -> str
Return a formatted version of S, using substitutions from mapping.
The substitutions are identified by braces (‘{’ and ‘}’).
index
(
)
¶
S.index(sub[, start[, end]]) -> int
Return the lowest index in S where substring sub is found,
such that sub is contained within S[start:end]. Optional
arguments start and end are interpreted as in slice notation.
Raises ValueError when the substring is not found.
isalnum
(
)
¶
Return True if the string is an alpha-numeric string, False otherwise.
A string is alpha-numeric if all characters in the string are alpha-numeric and
there is at least one character in the string.
isalpha
(
)
¶
Return True if the string is an alphabetic string, False otherwise.
A string is alphabetic if all characters in the string are alphabetic and there
is at least one character in the string.
isascii
(
)
¶
Return True if all characters in the string are ASCII, False otherwise.
ASCII characters have code points in the range U+0000-U+007F.
Empty string is ASCII too.
isdecimal
(
)
¶
Return True if the string is a decimal string, False otherwise.
A string is a decimal string if all characters in the string are decimal and
there is at least one character in the string.
isdigit
(
)
¶
Return True if the string is a digit string, False otherwise.
A string is a digit string if all characters in the string are digits and there
is at least one character in the string.
isidentifier
(
)
¶
Return True if the string is a valid Python identifier, False otherwise.
Call keyword.iskeyword(s) to test whether string s is a reserved identifier,
such as “def” or “class”.
islower
(
)
¶
Return True if the string is a lowercase string, False otherwise.
A string is lowercase if all cased characters in the string are lowercase and
there is at least one cased character in the string.
isnumeric
(
)
¶
Return True if the string is a numeric string, False otherwise.
A string is numeric if all characters in the string are numeric and there is at
least one character in the string.
isprintable
(
)
¶
Return True if the string is printable, False otherwise.
A string is printable if all of its characters are considered printable in
repr() or if it is empty.
isspace
(
)
¶
Return True if the string is a whitespace string, False otherwise.
A string is whitespace if all characters in the string are whitespace and there
is at least one character in the string.
istitle
(
)
¶
Return True if the string is a title-cased string, False otherwise.
In a title-cased string, upper- and title-case characters may only
follow uncased characters and lowercase characters only cased ones.
isupper
(
)
¶
Return True if the string is an uppercase string, False otherwise.
A string is uppercase if all cased characters in the string are uppercase and
there is at least one cased character in the string.
join
(
)
¶
Concatenate any number of strings.
The string whose method is called is inserted in between each given string.
The result is returned as a new string.
Example: ‘.’.join([‘ab’, ‘pq’, ‘rs’]) -> ‘ab.pq.rs’
ljust
(
)
¶
Return a left-justified string of length width.
Padding is done using the specified fill character (default is a space).
lower
(
)
¶
Return a copy of the string converted to lowercase.
lstrip
(
)
¶
Return a copy of the string with leading whitespace removed.
If chars is given and not None, remove characters in chars instead.
partition
(
)
¶
Partition the string into three parts using the given separator.
This will search for the separator in the string. If the separator is found,
returns a 3-tuple containing the part before the separator, the separator
itself, and the part after it.
If the separator is not found, returns a 3-tuple containing the original string
and two empty strings.
removeprefix
(
)
¶
Return a str with the given prefix string removed if present.
If the string starts with the prefix string, return string[len(prefix):].
Otherwise, return a copy of the original string.
removesuffix
(
)
¶
Return a str with the given suffix string removed if present.
If the string ends with the suffix string and that suffix is not empty,
return string[:-len(suffix)]. Otherwise, return a copy of the original
string.
replace
(
)
¶
Return a copy with all occurrences of substring old replaced by new.
count
Maximum number of occurrences to replace.
-1 (the default value) means replace all occurrences.
If the optional argument count is given, only the first count occurrences are
replaced.
rfind
(
)
¶
S.rfind(sub[, start[, end]]) -> int
Return the highest index in S where substring sub is found,
such that sub is contained within S[start:end]. Optional
arguments start and end are interpreted as in slice notation.
Return -1 on failure.
rindex
(
)
¶
S.rindex(sub[, start[, end]]) -> int
Return the highest index in S where substring sub is found,
such that sub is contained within S[start:end]. Optional
arguments start and end are interpreted as in slice notation.
Raises ValueError when the substring is not found.
rjust
(
)
¶
Return a right-justified string of length width.
Padding is done using the specified fill character (default is a space).
rpartition
(
)
¶
Partition the string into three parts using the given separator.
This will search for the separator in the string, starting at the end. If
the separator is found, returns a 3-tuple containing the part before the
separator, the separator itself, and the part after it.
If the separator is not found, returns a 3-tuple containing two empty strings
and the original string.
rsplit
(
)
¶
Return a list of the substrings in the string, using sep as the separator string.
sep
The separator used to split the string.
When set to None (the default value), will split on any whitespace
character (including \n \r \t \f and spaces) and will discard
empty strings from the result.
maxsplit
Maximum number of splits.
-1 (the default value) means no limit.
Splitting starts at the end of the string and works to the front.
rstrip
(
)
¶
Return a copy of the string with trailing whitespace removed.
If chars is given and not None, remove characters in chars instead.
split
(
)
¶
Return a list of the substrings in the string, using sep as the separator string.
sep
The separator used to split the string.
When set to None (the default value), will split on any whitespace
character (including \n \r \t \f and spaces) and will discard
empty strings from the result.
maxsplit
Maximum number of splits.
-1 (the default value) means no limit.
Splitting starts at the front of the string and works to the end.
Note, str.split() is mainly useful for data that has been intentionally
delimited. With natural text that includes punctuation, consider using
the regular expression module.
splitlines
(
)
¶
Return a list of the lines in the string, breaking at line boundaries.
Line breaks are not included in the resulting list unless keepends is given and
true.
startswith
(
)
¶
S.startswith(prefix[, start[, end]]) -> bool
Return True if S starts with the specified prefix, False otherwise.
With optional start, test S beginning at that position.
With optional end, stop comparing S at that position.
prefix can also be a tuple of strings to try.
strip
(
)
¶
Return a copy of the string with leading and trailing whitespace removed.
If chars is given and not None, remove characters in chars instead.
swapcase
(
)
¶
Convert uppercase characters to lowercase and lowercase characters to uppercase.
title
(
)
¶
Return a version of the string where each word is titlecased.
More specifically, words start with uppercased characters and all remaining
cased characters have lower case.
translate
(
)
¶
Replace each character in the string using the given translation table.
table
Translation table, which must be a mapping of Unicode ordinals to
Unicode ordinals, strings, or None.
The table must implement lookup/indexing via
getitem
, for instance a
dictionary or list. If this operation raises LookupError, the character is
left untouched. Characters mapped to None are deleted.
upper
(
)
¶
Return a copy of the string converted to uppercase.
zfill
(
)
¶
Pad a numeric string with zeros on the left, to fill a field of the given width.
The string is never truncated.
class
algopy.op.
Scratch
¶
Load or store scratch values
Native TEAL ops:
loads
,
stores
static
load_bytes
(
a
:
algopy.UInt64
|
int
,
/
)
→
algopy.Bytes
¶
Ath scratch space value. All scratch spaces are 0 at program start.
Native TEAL opcode:
loads
static
load_uint64
(
a
:
algopy.UInt64
|
int
,
/
)
→
algopy.UInt64
¶
Ath scratch space value. All scratch spaces are 0 at program start.
Native TEAL opcode:
loads
static
store
(
a
:
algopy.UInt64
|
int
,
b
:
algopy.Bytes
|
algopy.UInt64
|
bytes
|
int
,
/
,
)
→
None
¶
store B to the Ath scratch space
Native TEAL opcode:
stores
class
algopy.op.
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.op.
VoterParamsGet
¶
X is field F from online account A as of the balance round: 320 rounds before the current round. Y is 1 if A had positive algos online in the agreement round, else Y is 0 and X is a type specific zero-value
Native TEAL op:
voter_params_get
static
voter_balance
(
a
:
algopy.Account
|
algopy.UInt64
|
int
,
/
,
)
→
tuple
[
algopy.UInt64
,
bool
]
¶
Min AVM version: 11
Returns tuple[UInt64, bool]
:
Online stake in microalgos
Native TEAL opcode:
voter_params_get
static
voter_incentive_eligible
(
a
:
algopy.Account
|
algopy.UInt64
|
int
,
/
,
)
→
tuple
[
bool
,
bool
]
¶
Min AVM version: 11
Returns tuple[bool, bool]
:
Had this account opted into block payouts
Native TEAL opcode:
voter_params_get
class
algopy.op.
VrfVerify
¶
Available values for the
vrf_verify
enum
Initialization
Initialize self. See help(type(self)) for accurate signature.
__add__
(
)
¶
Return self+value.
__contains__
(
)
¶
Return bool(key in self).
__delattr__
(
)
¶
Implement delattr(self, name).
__dir__
(
)
¶
Default dir() implementation.
__eq__
(
)
¶
Return self==value.
__format__
(
)
¶
Return a formatted version of the string as described by format_spec.
__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.
__mod__
(
)
¶
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).
__rmod__
(
)
¶
Return value%self.
__rmul__
(
)
¶
Return value*self.
__setattr__
(
)
¶
Implement setattr(self, name, value).
__sizeof__
(
)
¶
Return the size of the string in memory, in bytes.
__str__
(
)
¶
Return str(self).
capitalize
(
)
¶
Return a capitalized version of the string.
More specifically, make the first character have upper case and the rest lower
case.
casefold
(
)
¶
Return a version of the string suitable for caseless comparisons.
center
(
)
¶
Return a centered string of length width.
Padding is done using the specified fill character (default is a space).
count
(
)
¶
S.count(sub[, start[, end]]) -> int
Return the number of non-overlapping occurrences of substring sub in
string S[start:end]. Optional arguments start and end are
interpreted as in slice notation.
encode
(
)
¶
Encode the string using the codec registered for encoding.
encoding
The encoding in which to encode the string.
errors
The error handling scheme to use for encoding errors.
The default is ‘strict’ meaning that encoding errors raise a
UnicodeEncodeError. Other possible values are ‘ignore’, ‘replace’ and
‘xmlcharrefreplace’ as well as any other name registered with
codecs.register_error that can handle UnicodeEncodeErrors.
endswith
(
)
¶
S.endswith(suffix[, start[, end]]) -> bool
Return True if S ends with the specified suffix, False otherwise.
With optional start, test S beginning at that position.
With optional end, stop comparing S at that position.
suffix can also be a tuple of strings to try.
expandtabs
(
)
¶
Return a copy where all tab characters are expanded using spaces.
If tabsize is not given, a tab size of 8 characters is assumed.
find
(
)
¶
S.find(sub[, start[, end]]) -> int
Return the lowest index in S where substring sub is found,
such that sub is contained within S[start:end]. Optional
arguments start and end are interpreted as in slice notation.
Return -1 on failure.
format
(
)
¶
S.format(*args, **kwargs) -> str
Return a formatted version of S, using substitutions from args and kwargs.
The substitutions are identified by braces (‘{’ and ‘}’).
format_map
(
)
¶
S.format_map(mapping) -> str
Return a formatted version of S, using substitutions from mapping.
The substitutions are identified by braces (‘{’ and ‘}’).
index
(
)
¶
S.index(sub[, start[, end]]) -> int
Return the lowest index in S where substring sub is found,
such that sub is contained within S[start:end]. Optional
arguments start and end are interpreted as in slice notation.
Raises ValueError when the substring is not found.
isalnum
(
)
¶
Return True if the string is an alpha-numeric string, False otherwise.
A string is alpha-numeric if all characters in the string are alpha-numeric and
there is at least one character in the string.
isalpha
(
)
¶
Return True if the string is an alphabetic string, False otherwise.
A string is alphabetic if all characters in the string are alphabetic and there
is at least one character in the string.
isascii
(
)
¶
Return True if all characters in the string are ASCII, False otherwise.
ASCII characters have code points in the range U+0000-U+007F.
Empty string is ASCII too.
isdecimal
(
)
¶
Return True if the string is a decimal string, False otherwise.
A string is a decimal string if all characters in the string are decimal and
there is at least one character in the string.
isdigit
(
)
¶
Return True if the string is a digit string, False otherwise.
A string is a digit string if all characters in the string are digits and there
is at least one character in the string.
isidentifier
(
)
¶
Return True if the string is a valid Python identifier, False otherwise.
Call keyword.iskeyword(s) to test whether string s is a reserved identifier,
such as “def” or “class”.
islower
(
)
¶
Return True if the string is a lowercase string, False otherwise.
A string is lowercase if all cased characters in the string are lowercase and
there is at least one cased character in the string.
isnumeric
(
)
¶
Return True if the string is a numeric string, False otherwise.
A string is numeric if all characters in the string are numeric and there is at
least one character in the string.
isprintable
(
)
¶
Return True if the string is printable, False otherwise.
A string is printable if all of its characters are considered printable in
repr() or if it is empty.
isspace
(
)
¶
Return True if the string is a whitespace string, False otherwise.
A string is whitespace if all characters in the string are whitespace and there
is at least one character in the string.
istitle
(
)
¶
Return True if the string is a title-cased string, False otherwise.
In a title-cased string, upper- and title-case characters may only
follow uncased characters and lowercase characters only cased ones.
isupper
(
)
¶
Return True if the string is an uppercase string, False otherwise.
A string is uppercase if all cased characters in the string are uppercase and
there is at least one cased character in the string.
join
(
)
¶
Concatenate any number of strings.
The string whose method is called is inserted in between each given string.
The result is returned as a new string.
Example: ‘.’.join([‘ab’, ‘pq’, ‘rs’]) -> ‘ab.pq.rs’
ljust
(
)
¶
Return a left-justified string of length width.
Padding is done using the specified fill character (default is a space).
lower
(
)
¶
Return a copy of the string converted to lowercase.
lstrip
(
)
¶
Return a copy of the string with leading whitespace removed.
If chars is given and not None, remove characters in chars instead.
partition
(
)
¶
Partition the string into three parts using the given separator.
This will search for the separator in the string. If the separator is found,
returns a 3-tuple containing the part before the separator, the separator
itself, and the part after it.
If the separator is not found, returns a 3-tuple containing the original string
and two empty strings.
removeprefix
(
)
¶
Return a str with the given prefix string removed if present.
If the string starts with the prefix string, return string[len(prefix):].
Otherwise, return a copy of the original string.
removesuffix
(
)
¶
Return a str with the given suffix string removed if present.
If the string ends with the suffix string and that suffix is not empty,
return string[:-len(suffix)]. Otherwise, return a copy of the original
string.
replace
(
)
¶
Return a copy with all occurrences of substring old replaced by new.
count
Maximum number of occurrences to replace.
-1 (the default value) means replace all occurrences.
If the optional argument count is given, only the first count occurrences are
replaced.
rfind
(
)
¶
S.rfind(sub[, start[, end]]) -> int
Return the highest index in S where substring sub is found,
such that sub is contained within S[start:end]. Optional
arguments start and end are interpreted as in slice notation.
Return -1 on failure.
rindex
(
)
¶
S.rindex(sub[, start[, end]]) -> int
Return the highest index in S where substring sub is found,
such that sub is contained within S[start:end]. Optional
arguments start and end are interpreted as in slice notation.
Raises ValueError when the substring is not found.
rjust
(
)
¶
Return a right-justified string of length width.
Padding is done using the specified fill character (default is a space).
rpartition
(
)
¶
Partition the string into three parts using the given separator.
This will search for the separator in the string, starting at the end. If
the separator is found, returns a 3-tuple containing the part before the
separator, the separator itself, and the part after it.
If the separator is not found, returns a 3-tuple containing two empty strings
and the original string.
rsplit
(
)
¶
Return a list of the substrings in the string, using sep as the separator string.
sep
The separator used to split the string.
When set to None (the default value), will split on any whitespace
character (including \n \r \t \f and spaces) and will discard
empty strings from the result.
maxsplit
Maximum number of splits.
-1 (the default value) means no limit.
Splitting starts at the end of the string and works to the front.
rstrip
(
)
¶
Return a copy of the string with trailing whitespace removed.
If chars is given and not None, remove characters in chars instead.
split
(
)
¶
Return a list of the substrings in the string, using sep as the separator string.
sep
The separator used to split the string.
When set to None (the default value), will split on any whitespace
character (including \n \r \t \f and spaces) and will discard
empty strings from the result.
maxsplit
Maximum number of splits.
-1 (the default value) means no limit.
Splitting starts at the front of the string and works to the end.
Note, str.split() is mainly useful for data that has been intentionally
delimited. With natural text that includes punctuation, consider using
the regular expression module.
splitlines
(
)
¶
Return a list of the lines in the string, breaking at line boundaries.
Line breaks are not included in the resulting list unless keepends is given and
true.
startswith
(
)
¶
S.startswith(prefix[, start[, end]]) -> bool
Return True if S starts with the specified prefix, False otherwise.
With optional start, test S beginning at that position.
With optional end, stop comparing S at that position.
prefix can also be a tuple of strings to try.
strip
(
)
¶
Return a copy of the string with leading and trailing whitespace removed.
If chars is given and not None, remove characters in chars instead.
swapcase
(
)
¶
Convert uppercase characters to lowercase and lowercase characters to uppercase.
title
(
)
¶
Return a version of the string where each word is titlecased.
More specifically, words start with uppercased characters and all remaining
cased characters have lower case.
translate
(
)
¶
Replace each character in the string using the given translation table.
table
Translation table, which must be a mapping of Unicode ordinals to
Unicode ordinals, strings, or None.
The table must implement lookup/indexing via
getitem
, for instance a
dictionary or list. If this operation raises LookupError, the character is
left untouched. Characters mapped to None are deleted.
upper
(
)
¶
Return a copy of the string converted to uppercase.
zfill
(
)
¶
Pad a numeric string with zeros on the left, to fill a field of the given width.
The string is never truncated.
algopy.op.
addw
(
a
:
algopy.UInt64
|
int
,
b
:
algopy.UInt64
|
int
,
/
,
)
→
tuple
[
algopy.UInt64
,
algopy.UInt64
]
¶
A plus B as a 128-bit result. X is the carry-bit, Y is the low-order 64 bits.
Native TEAL opcode:
addw
algopy.op.
app_opted_in
(
a
:
algopy.Account
|
algopy.UInt64
|
int
,
b
:
algopy.Application
|
algopy.UInt64
|
int
,
/
,
)
→
bool
¶
1 if account A is opted in to application B, else 0
params: Txn.Accounts offset (or, since v4, an
available
account address),
available
application id (or, since v4, a Txn.ForeignApps offset). Return: 1 if opted in and 0 otherwise.
Native TEAL opcode:
app_opted_in
algopy.op.
arg
(
a
:
algopy.UInt64
|
int
,
/
)
→
algopy.Bytes
¶
Ath LogicSig argument
Native TEAL opcode:
arg
,
args
algopy.op.
balance
(
a
:
algopy.Account
|
algopy.UInt64
|
int
,
/
)
→
algopy.UInt64
¶
balance for account A, in microalgos. The balance is observed after the effects of previous transactions in the group, and after the fee for the current transaction is deducted. Changes caused by inner transactions are observable immediately following
itxn_submit
params: Txn.Accounts offset (or, since v4, an
available
account address),
available
application id (or, since v4, a Txn.ForeignApps offset). Return: value.
Native TEAL opcode:
balance
algopy.op.
base64_decode
(
e
:
algopy.op.Base64
,
a
:
algopy.Bytes
|
bytes
,
/
)
→
algopy.Bytes
¶
decode A which was base64-encoded using
encoding
E. Fail if A is not base64 encoded with encoding E
Warning
: Usage should be restricted to very rare use cases. In almost all cases, smart contracts should directly handle non-encoded byte-strings. This opcode should only be used in cases where base64 is the only available option, e.g. interoperability with a third-party that only signs base64 strings.
Decodes A using the base64 encoding E. Specify the encoding with an immediate arg either as URL and Filename Safe (
URLEncoding
) or Standard (
StdEncoding
). See
RFC 4648 sections 4 and 5
. It is assumed that the encoding ends with the exact number of
=
padding characters as required by the RFC. When padding occurs, any unused pad bits in the encoding must be set to zero or the decoding will fail. The special cases of
\n
and
\r
are allowed but completely ignored. An error will result when attempting to decode a string with a character that is not in the encoding alphabet or not one of
=
,
\r
, or
\n
.
Parameters
:
e
(
Base64
) – encoding index
Native TEAL opcode:
base64_decode
algopy.op.
bitlen
(
a
:
algopy.Bytes
|
algopy.UInt64
|
bytes
|
int
,
/
)
→
algopy.UInt64
¶
The highest set bit in A. If A is a byte-array, it is interpreted as a big-endian unsigned integer. bitlen of 0 is 0, bitlen of 8 is 4
bitlen interprets arrays as big-endian integers, unlike setbit/getbit
Native TEAL opcode:
bitlen
algopy.op.
bsqrt
(
a
:
algopy.BigUInt
|
int
,
/
)
→
algopy.BigUInt
¶
The largest integer I such that I^2 <= A. A and I are interpreted as big-endian unsigned integers
Native TEAL opcode:
bsqrt
algopy.op.
btoi
(
a
:
algopy.Bytes
|
bytes
,
/
)
→
algopy.UInt64
¶
converts big-endian byte array A to uint64. Fails if len(A) > 8. Padded by leading 0s if len(A) < 8.
btoi
fails if the input is longer than 8 bytes.
Native TEAL opcode:
btoi
algopy.op.
bzero
(
a
:
algopy.UInt64
|
int
,
/
)
→
algopy.Bytes
¶
zero filled byte-array of length A
Native TEAL opcode:
bzero
algopy.op.
concat
(
a
:
algopy.Bytes
|
bytes
,
b
:
algopy.Bytes
|
bytes
,
/
)
→
algopy.Bytes
¶
join A and B
concat
fails if the result would be greater than 4096 bytes.
Native TEAL opcode:
concat
algopy.op.
divmodw
(
a
:
algopy.UInt64
|
int
,
b
:
algopy.UInt64
|
int
,
c
:
algopy.UInt64
|
int
,
d
:
algopy.UInt64
|
int
,
/
,
)
→
tuple
[
algopy.UInt64
,
algopy.UInt64
,
algopy.UInt64
,
algopy.UInt64
]
¶
W,X = (A,B / C,D); Y,Z = (A,B modulo C,D)
The notation J,K indicates that two uint64 values J and K are interpreted as a uint128 value, with J as the high uint64 and K the low.
Native TEAL opcode:
divmodw
algopy.op.
divw
(
a
:
algopy.UInt64
|
int
,
b
:
algopy.UInt64
|
int
,
c
:
algopy.UInt64
|
int
,
/
,
)
→
algopy.UInt64
¶
A,B / C. Fail if C == 0 or if result overflows.
The notation A,B indicates that A and B are interpreted as a uint128 value, with A as the high uint64 and B the low.
Native TEAL opcode:
divw
algopy.op.
ecdsa_pk_decompress
(
v
:
algopy.op.ECDSA
,
a
:
algopy.Bytes
|
bytes
,
/
,
)
→
tuple
[
algopy.Bytes
,
algopy.Bytes
]
¶
decompress pubkey A into components X, Y
The 33 byte public key in a compressed form to be decompressed into X and Y (top) components. All values are big-endian encoded.
Parameters
:
v
(
ECDSA
) – curve index
Native TEAL opcode:
ecdsa_pk_decompress
algopy.op.
ecdsa_pk_recover
(
v
:
algopy.op.ECDSA
,
a
:
algopy.Bytes
|
bytes
,
b
:
algopy.UInt64
|
int
,
c
:
algopy.Bytes
|
bytes
,
d
:
algopy.Bytes
|
bytes
,
/
,
)
→
tuple
[
algopy.Bytes
,
algopy.Bytes
]
¶
for (data A, recovery id B, signature C, D) recover a public key
S (top) and R elements of a signature, recovery id and data (bottom) are expected on the stack and used to deriver a public key. All values are big-endian encoded. The signed data must be 32 bytes long.
Parameters
:
v
(
ECDSA
) – curve index
Native TEAL opcode:
ecdsa_pk_recover
algopy.op.
ecdsa_verify
(
v
:
algopy.op.ECDSA
,
a
:
algopy.Bytes
|
bytes
,
b
:
algopy.Bytes
|
bytes
,
c
:
algopy.Bytes
|
bytes
,
d
:
algopy.Bytes
|
bytes
,
e
:
algopy.Bytes
|
bytes
,
/
,
)
→
bool
¶
for (data A, signature B, C and pubkey D, E) verify the signature of the data against the pubkey => {0 or 1}
The 32 byte Y-component of a public key is the last element on the stack, preceded by X-component of a pubkey, preceded by S and R components of a signature, preceded by the data that is fifth element on the stack. All values are big-endian encoded. The signed data must be 32 bytes long, and signatures in lower-S form are only accepted.
Parameters
:
v
(
ECDSA
) – curve index
Native TEAL opcode:
ecdsa_verify
algopy.op.
ed25519verify
(
a
:
algopy.Bytes
|
bytes
,
b
:
algopy.Bytes
|
bytes
,
c
:
algopy.Bytes
|
bytes
,
/
,
)
→
bool
¶
for (data A, signature B, pubkey C) verify the signature of (“ProgData” || program_hash || data) against the pubkey => {0 or 1}
The 32 byte public key is the last element on the stack, preceded by the 64 byte signature at the second-to-last element on the stack, preceded by the data which was signed at the third-to-last element on the stack.
Native TEAL opcode:
ed25519verify
algopy.op.
ed25519verify_bare
(
a
:
algopy.Bytes
|
bytes
,
b
:
algopy.Bytes
|
bytes
,
c
:
algopy.Bytes
|
bytes
,
/
,
)
→
bool
¶
for (data A, signature B, pubkey C) verify the signature of the data against the pubkey => {0 or 1}
Native TEAL opcode:
ed25519verify_bare
algopy.op.
err
(
)
→
Never
¶
Fail immediately.
Returns typing.Never
:
Halts program
Native TEAL opcode:
err
algopy.op.
exit
(
a
:
algopy.UInt64
|
int
,
/
)
→
Never
¶
use A as success value; end
Returns typing.Never
:
Halts program
Native TEAL opcode:
return
algopy.op.
exp
(
a
:
algopy.UInt64
|
int
,
b
:
algopy.UInt64
|
int
,
/
)
→
algopy.UInt64
¶
A raised to the Bth power. Fail if A == B == 0 and on overflow
Native TEAL opcode:
exp
algopy.op.
expw
(
a
:
algopy.UInt64
|
int
,
b
:
algopy.UInt64
|
int
,
/
,
)
→
tuple
[
algopy.UInt64
,
algopy.UInt64
]
¶
A raised to the Bth power as a 128-bit result in two uint64s. X is the high 64 bits, Y is the low. Fail if A == B == 0 or if the results exceeds 2^128-1
Native TEAL opcode:
expw
algopy.op.
extract
(
a
:
algopy.Bytes
|
bytes
,
b
:
algopy.UInt64
|
int
,
c
:
algopy.UInt64
|
int
,
/
,
)
→
algopy.Bytes
¶
A range of bytes from A starting at B up to but not including B+C. If B+C is larger than the array length, the program fails
extract3
can be called using
extract
with no immediates.
Native TEAL opcode:
extract
,
extract3
algopy.op.
extract_uint16
(
a
:
algopy.Bytes
|
bytes
,
b
:
algopy.UInt64
|
int
,
/
,
)
→
algopy.UInt64
¶
A uint16 formed from a range of big-endian bytes from A starting at B up to but not including B+2. If B+2 is larger than the array length, the program fails
Native TEAL opcode:
extract_uint16
algopy.op.
extract_uint32
(
a
:
algopy.Bytes
|
bytes
,
b
:
algopy.UInt64
|
int
,
/
,
)
→
algopy.UInt64
¶
A uint32 formed from a range of big-endian bytes from A starting at B up to but not including B+4. If B+4 is larger than the array length, the program fails
Native TEAL opcode:
extract_uint32
algopy.op.
extract_uint64
(
a
:
algopy.Bytes
|
bytes
,
b
:
algopy.UInt64
|
int
,
/
,
)
→
algopy.UInt64
¶
A uint64 formed from a range of big-endian bytes from A starting at B up to but not including B+8. If B+8 is larger than the array length, the program fails
Native TEAL opcode:
extract_uint64
algopy.op.
falcon_verify
(
a
:
algopy.Bytes
|
bytes
,
b
:
algopy.Bytes
|
bytes
,
c
:
algopy.Bytes
|
bytes
,
/
,
)
→
bool
¶
for (data A, compressed-format signature B, pubkey C) verify the signature of data against the pubkey
Min AVM version: 12
Native TEAL opcode:
falcon_verify
algopy.op.
gaid
(
a
:
algopy.UInt64
|
int
,
/
)
→
algopy.UInt64
¶
ID of the asset or application created in the Ath transaction of the current group
gaids
fails unless the requested transaction created an asset or application and A < GroupIndex.
Native TEAL opcode:
gaid
,
gaids
algopy.op.
getbit
(
a
:
algopy.Bytes
|
algopy.UInt64
|
bytes
|
int
,
b
:
algopy.UInt64
|
int
,
/
,
)
→
algopy.UInt64
¶
Bth bit of (byte-array or integer) A. If B is greater than or equal to the bit length of the value (8*byte length), the program fails
see explanation of bit ordering in setbit
Native TEAL opcode:
getbit
algopy.op.
getbyte
(
a
:
algopy.Bytes
|
bytes
,
b
:
algopy.UInt64
|
int
,
/
)
→
algopy.UInt64
¶
Bth byte of A, as an integer. If B is greater than or equal to the array length, the program fails
Native TEAL opcode:
getbyte
algopy.op.
gload_bytes
(
a
:
algopy.UInt64
|
int
,
b
:
algopy.UInt64
|
int
,
/
)
→
algopy.Bytes
¶
Bth scratch space value of the Ath transaction in the current group
Native TEAL opcode:
gload
,
gloads
,
gloadss
algopy.op.
gload_uint64
(
a
:
algopy.UInt64
|
int
,
b
:
algopy.UInt64
|
int
,
/
)
→
algopy.UInt64
¶
Bth scratch space value of the Ath transaction in the current group
Native TEAL opcode:
gload
,
gloads
,
gloadss
algopy.op.
itob
(
a
:
algopy.UInt64
|
int
,
/
)
→
algopy.Bytes
¶
converts uint64 A to big-endian byte array, always of length 8
Native TEAL opcode:
itob
algopy.op.
keccak256
(
a
:
algopy.Bytes
|
bytes
,
/
)
→
algopy.Bytes
¶
Keccak256 hash of value A, yields [32]byte
Native TEAL opcode:
keccak256
algopy.op.
mimc
(
c
:
algopy.op.MiMCConfigurations
,
a
:
algopy.Bytes
|
bytes
,
/
,
)
→
algopy.Bytes
¶
MiMC hash of scalars A, using curve and parameters specified by configuration C
A is a list of concatenated 32 byte big-endian unsigned integer scalars. Fail if A’s length is not a multiple of 32 or any element exceeds the curve modulus.
The MiMC hash function has known collisions since any input which is a multiple of the elliptic curve modulus will hash to the same value. MiMC is thus not a general purpose hash function, but meant to be used in zero knowledge applications to match a zk-circuit implementation.
Min AVM version: 11
Parameters
:
c
(
MiMCConfigurations
) – configuration index
Native TEAL opcode:
mimc
algopy.op.
min_balance
(
a
:
algopy.Account
|
algopy.UInt64
|
int
,
/
)
→
algopy.UInt64
¶
minimum required balance for account A, in microalgos. Required balance is affected by ASA, App, and Box usage. When creating or opting into an app, the minimum balance grows before the app code runs, therefore the increase is visible there. When deleting or closing out, the minimum balance decreases after the app executes. Changes caused by inner transactions or box usage are observable immediately following the opcode effecting the change.
params: Txn.Accounts offset (or, since v4, an
available
account address),
available
application id (or, since v4, a Txn.ForeignApps offset). Return: value.
Native TEAL opcode:
min_balance
algopy.op.
mulw
(
a
:
algopy.UInt64
|
int
,
b
:
algopy.UInt64
|
int
,
/
,
)
→
tuple
[
algopy.UInt64
,
algopy.UInt64
]
¶
A times B as a 128-bit result in two uint64s. X is the high 64 bits, Y is the low
Native TEAL opcode:
mulw
algopy.op.
online_stake
(
)
→
algopy.UInt64
¶
the total online stake in the agreement round
Min AVM version: 11
Native TEAL opcode:
online_stake
algopy.op.
replace
(
a
:
algopy.Bytes
|
bytes
,
b
:
algopy.UInt64
|
int
,
c
:
algopy.Bytes
|
bytes
,
/
,
)
→
algopy.Bytes
¶
Copy of A with the bytes starting at B replaced by the bytes of C. Fails if B+len(C) exceeds len(A)
replace3
can be called using
replace
with no immediates.
Native TEAL opcode:
replace2
,
replace3
algopy.op.
select_bytes
(
a
:
algopy.Bytes
|
bytes
,
b
:
algopy.Bytes
|
bytes
,
c
:
bool
|
algopy.UInt64
|
int
,
/
,
)
→
algopy.Bytes
¶
selects one of two values based on top-of-stack: B if C != 0, else A
Native TEAL opcode:
select
algopy.op.
select_uint64
(
a
:
algopy.UInt64
|
int
,
b
:
algopy.UInt64
|
int
,
c
:
bool
|
algopy.UInt64
|
int
,
/
,
)
→
algopy.UInt64
¶
selects one of two values based on top-of-stack: B if C != 0, else A
Native TEAL opcode:
select
algopy.op.
setbit_bytes
(
a
:
algopy.Bytes
|
bytes
,
b
:
algopy.UInt64
|
int
,
c
:
algopy.UInt64
|
int
,
/
,
)
→
algopy.Bytes
¶
Copy of (byte-array or integer) A, with the Bth bit set to (0 or 1) C. If B is greater than or equal to the bit length of the value (8*byte length), the program fails
When A is a uint64, index 0 is the least significant bit. Setting bit 3 to 1 on the integer 0 yields 8, or 2^3. When A is a byte array, index 0 is the leftmost bit of the leftmost byte. Setting bits 0 through 11 to 1 in a 4-byte-array of 0s yields the byte array 0xfff00000. Setting bit 3 to 1 on the 1-byte-array 0x00 yields the byte array 0x10.
Native TEAL opcode:
setbit
algopy.op.
setbit_uint64
(
a
:
algopy.UInt64
|
int
,
b
:
algopy.UInt64
|
int
,
c
:
algopy.UInt64
|
int
,
/
,
)
→
algopy.UInt64
¶
Copy of (byte-array or integer) A, with the Bth bit set to (0 or 1) C. If B is greater than or equal to the bit length of the value (8*byte length), the program fails
When A is a uint64, index 0 is the least significant bit. Setting bit 3 to 1 on the integer 0 yields 8, or 2^3. When A is a byte array, index 0 is the leftmost bit of the leftmost byte. Setting bits 0 through 11 to 1 in a 4-byte-array of 0s yields the byte array 0xfff00000. Setting bit 3 to 1 on the 1-byte-array 0x00 yields the byte array 0x10.
Native TEAL opcode:
setbit
algopy.op.
setbyte
(
a
:
algopy.Bytes
|
bytes
,
b
:
algopy.UInt64
|
int
,
c
:
algopy.UInt64
|
int
,
/
,
)
→
algopy.Bytes
¶
Copy of A with the Bth byte set to small integer (between 0..255) C. If B is greater than or equal to the array length, the program fails
Native TEAL opcode:
setbyte
algopy.op.
sha256
(
a
:
algopy.Bytes
|
bytes
,
/
)
→
algopy.Bytes
¶
SHA256 hash of value A, yields [32]byte
Native TEAL opcode:
sha256
algopy.op.
sha3_256
(
a
:
algopy.Bytes
|
bytes
,
/
)
→
algopy.Bytes
¶
SHA3_256 hash of value A, yields [32]byte
Native TEAL opcode:
sha3_256
algopy.op.
sha512_256
(
a
:
algopy.Bytes
|
bytes
,
/
)
→
algopy.Bytes
¶
SHA512_256 hash of value A, yields [32]byte
Native TEAL opcode:
sha512_256
algopy.op.
shl
(
a
:
algopy.UInt64
|
int
,
b
:
algopy.UInt64
|
int
,
/
)
→
algopy.UInt64
¶
A times 2^B, modulo 2^64
Native TEAL opcode:
shl
algopy.op.
shr
(
a
:
algopy.UInt64
|
int
,
b
:
algopy.UInt64
|
int
,
/
)
→
algopy.UInt64
¶
A divided by 2^B
Native TEAL opcode:
shr
algopy.op.
sqrt
(
a
:
algopy.UInt64
|
int
,
/
)
→
algopy.UInt64
¶
The largest integer I such that I^2 <= A
Native TEAL opcode:
sqrt
algopy.op.
substring
(
a
:
algopy.Bytes
|
bytes
,
b
:
algopy.UInt64
|
int
,
c
:
algopy.UInt64
|
int
,
/
,
)
→
algopy.Bytes
¶
A range of bytes from A starting at B up to but not including C. If C < B, or either is larger than the array length, the program fails
Native TEAL opcode:
substring
,
substring3
algopy.op.
sumhash512
(
a
:
algopy.Bytes
|
bytes
,
/
)
→
algopy.Bytes
¶
sumhash512 of value A, yields [64]byte
Min AVM version: 12
Native TEAL opcode:
sumhash512
algopy.op.
vrf_verify
(
s
:
algopy.op.VrfVerify
,
a
:
algopy.Bytes
|
bytes
,
b
:
algopy.Bytes
|
bytes
,
c
:
algopy.Bytes
|
bytes
,
/
,
)
→
tuple
[
algopy.Bytes
,
bool
]
¶
Verify the proof B of message A against pubkey C. Returns vrf output and verification flag.
VrfAlgorand
is the VRF used in Algorand. It is ECVRF-ED25519-SHA512-Elligator2, specified in the IETF internet draft
draft-irtf-cfrg-vrf-03
.
Parameters
:
s
(
VrfVerify
) – parameters index
Native TEAL opcode:
vrf_verify
Next
PuyaPy compiler
Previous
algopy.itxn
Copyright © 2024, Algorand Foundation
Made with
Sphinx
and
@pradyunsg
's
Furo |
|
Back to top
View this page
Toggle Light / Dark / Auto color theme
Toggle table of contents sidebar
PuyaPy compiler
¶
The PuyaPy compiler is a multi-stage, optimising compiler that takes Algorand Python and prepares it for execution on the AVM. PuyaPy ensures the resulting AVM bytecode execution semantics that match the given Python code. PuyaPy produces output that is directly compatible with
AlgoKit typed clients
to make deployment and calling easy (among other formats).
The PuyaPy compiler is based on the
Puya compiler architecture
, which allows for multiple frontend languages to leverage the majority of the compiler logic so adding new frontend languages for execution on Algorand is relatively easy.
Compiler installation
¶
The minimum supported Python version for running the PuyaPy compiler is 3.12.
There are three ways of installing the PuyaPy compiler.
You can install
AlgoKit CLI
and you can then use the
algokit
compile
py
command.
You can install the PuyaPy compiler into your project and thus lock the compiler version for that project:
pip
install
puyapy
# OR
poetry
add
puyapy
--group
=
dev
Note: if you do this then when you use
algokit
compile
py
within that project directory it will invoke the installed compiler rather than a global one.
You can install the compiler globally using
pipx
:
pipx
install
puya
Alternatively, it can be installed per project. For example, if you’re using
poetry
,
you can install it as a dev-dependency like so:
If you just want to play with some examples, you can clone the repo and have a poke around:
git
clone
https://github.com/algorandfoundation/puya.git
cd
puya
poetry
install
poetry
shell
# compile the "Hello World" example
puyapy
examples/hello_world
Using the compiler
¶
To check that you can run the compiler successfully after installation, you can run the
help command:
puyapy
-
h
# OR
algokit
compile
py
-
h
To compile a contract or contracts, just supply the path(s) - either to the .py files themselves,
or the containing directories. In the case of containing directories, any (non-abstract) contracts
discovered therein will be compiled, allowing you to compile multiple contracts at once. You can
also supply more than one path at a time to the compiler.
e.g. either
puyapy
my_project/
or
puyapy
my_project/contract.py
will work to compile a single contract.
Compiler architecture
¶
The PuyaPy compiler is based on the Puya compiler architecture, which allows for multiple frontend languages to leverage the majority of the compiler logic so adding new frontend languages for execution on Algorand is relatively easy.
The PuyaPy compiler takes Algorand Python through a series of transformations with each transformation serving a specific purpose:
Python code
-> Python Abstract Syntax Tree (AST)
-> MyPy AST
-> Puya AST (AWST)
-> Intermediate Representation (IR) in SSA form
-> Optimizations (multiple rounds)
-> Destructured IR
-> Optimizations (multiple rounds)
-> Memory IR (MIR)
-> Optimizations (multiple rounds)
-> TealOps IR
-> Optimizations (multiple rounds)
-> TEAL code
-> AVM bytecode
While this may appear complex, splitting it in this manner allows for each step to be expressed in a simple form to do one thing (well) and allows us to make use of industry research into compiler algorithms and formats.
Type checking
¶
The first and second steps of the
compiler pipeline
are significant to note, because it’s where we perform type checking. We leverage
MyPy
to do this, so we recommend that you install and use the latest version of MyPy in your development environment to get the best typing information that aligns to what the PuyaPy compiler expects. This should work with standard Python tooling e.g. with Visual Studio Code, PyCharm, et. al.
The easiest way to get a productive development environment with Algorand Python is to instantiate a template with AlgoKit via
algokit
init
-t
python
. This will give you a full development environment with intellisense, linting, automatic formatting, breakpoint debugging, deployment and CI/CD.
Alternatively, you can construct your own environment by configuring MyPy, Ruff, etc. with the same configuration files
used by that template
.
The MyPy config that PuyaPy uses is in
compile.py
Compiler usage
¶
The options available for the compile can be seen by executing
puyapy
-h
or
algokit
compile
py
-h
:
puyapy
[
-
h
]
[
--
version
]
[
-
O
{
0
,
1
,
2
}]
[
--
output
-
teal
|
--
no
-
output
-
teal
]
[
--
output
-
arc32
|
--
no
-
output
-
arc32
]
[
--
output
-
client
|
--
no
-
output
-
client
]
[
--
out
-
dir
OUT_DIR
]
[
--
log
-
level
{
notset
,
debug
,
info
,
warning
,
error
,
critical
}]
[
-
g
{
0
,
1
,
2
}]
[
--
output
-
awst
|
--
no
-
output
-
awst
]
[
--
output
-
ssa
-
ir
|
--
no
-
output
-
ssa
-
ir
]
[
--
output
-
optimization
-
ir
|
--
no
-
output
-
optimization
-
ir
]
[
--
output
-
destructured
-
ir
|
--
no
-
output
-
destructured
-
ir
]
[
--
output
-
memory
-
ir
|
--
no
-
output
-
memory
-
ir
]
[
--
target
-
avm
-
version
{
10
}]
[
--
locals
-
coalescing
-
strategy
{
root_operand
,
root_operand_excluding_args
,
aggressive
}]
PATH
[
PATH
...
]
Options
¶
Option
Description
Default
-h
,
--help
Show the help message and exit
N/A
--version
Show program’s version number and exit
N/A
-O
{0,1,2}
--optimization-level
{0,1,2}
Set optimization level of output TEAL / AVM bytecode
1
--output-teal
,
--no-output-teal
Output TEAL
True
--output-arc32
,
--no-output-arc32
Output {contract}.arc32.json ARC-32 app spec file if the contract is an ARC-4 contract
True
--output-arc56
,
--no-output-arc56
Output {contract}.arc56.json ARC-56 app spec file if the contract is an ARC-4 contract
False
--output-client
,
--no-output-client
Output Algorand Python contract client for typed ARC4 ABI calls
False
--output-bytecode
,
--no-output-bytecode
Output AVM bytecode
False
--out-dir
OUT_DIR
The path for outputting artefacts
Same folder as contract
--log-level
{notset,debug,info,warning,error,critical}
Minimum level to log to console
info
-g
{0,1,2}
,
--debug-level
{0,1,2}
Output debug information level
0
= No debug annotations
1
= Output debug annotations
2
= Reserved for future use, currently the same as
1
1
--template-var
Allows specifying template values. Can be used multiple times, see below for examples
N/A
--template-vars-prefix
Prefix to use for template variables
“TMPL_”
Defining template values
¶
Template Variables
, can be replaced with literal values during compilation to bytecode using the
--template-var
option.
Additionally, Algorand Python functions that create AVM bytecode, such as
compile_contract
and
compile_logicsig
, can also provide the specified values.
Examples of Variable Definitions
¶
The table below illustrates how different variables and values can be defined:
Variable Type
Example Algorand Python
Value definition example
UInt64
algopy.TemplateVar[UInt64]("SOME_INT")
SOME_INT=1234
Bytes
algopy.TemplateVar[Bytes]("SOME_BYTES")
SOME_BYTES=0x1A2B
String
algopy.TemplateVar[String]("SOME_STR")
SOME_STR="hello"
All template values specified via the command line are prefixed with “TMPL_” by default.
The default prefix can be modified using the
--template-vars-prefix
option.
Advanced options
¶
There are additional compiler options that allow you to tweak the behaviour in more advanced ways or tweak the output to receive intermediate representations from the compiler pipeline. Most users won’t need to use these options unless exploring the inner workings of the compiler or performing more advanced optimisations.
Option
Description
Default
--output-awst
,
--no-output-awst
Output parsed result of Puya Abstract Syntax Tree (AWST)
False
--output-ssa-ir
,
--no-output-ssa-ir
Output the Intermediate Representation (IR) in Single Static Assignment (SSA) form before optimisations form
False
--output-optimization-ir
,
--no-output-optimization-ir
Output the IR after each optimization step
False
--output-destructured-ir
,
--no-output-destructured-ir
Output the IR after SSA destructuring and before Memory IR (MIR)
False
--output-memory-ir
,
--no-output-memory-ir
Output Memory IR (MIR) before lowering to TealOps IR
--target-avm-version
{10}
Target AVM version for the output
10
--locals-coalescing-strategy
{root_operand,root_operand_excluding_args,aggressive}
Strategy choice for out-of-ssa local variable coalescing. The best choice for your app is best determined through experimentation
root_operand
Sample
pyproject.toml
¶
A sample
pyproject.toml
file with known good configuration is:
[tool.poetry]
name
=
"algorand_python_contract"
version
=
"0.1.0"
description
=
"Algorand smart contracts"
authors
=
["Name <name@domain.tld>"]
readme
=
"README.md"
[tool.poetry.dependencies]
python
=
"^3.12"
algokit-utils
=
"^2.2.0"
python-dotenv
=
"^1.0.0"
algorand-python
=
"^1.0.0"
[tool.poetry.group.dev.dependencies]
black = { extras = ["d"], version
=
"*"
}
ruff
=
"^0.1.6"
mypy
=
"*"
pytest
=
"*"
pytest-cov
=
"*"
pip-audit
=
"*"
pre-commit
=
"*"
puyapy
=
"^1.0"
[build-system]
requires
=
["poetry-core"]
build-backend
=
"poetry.core.masonry.api"
[tool.ruff]
line-length
=
120
select
=
[
"E",
"F",
"ANN",
"UP",
"N",
"C4",
"B",
"A",
"YTT",
"W",
"FBT",
"Q",
"RUF",
"I",
]
ignore
=
[
"ANN101", # no type for self
"ANN102", # no type for cls
]
unfixable
=
["B", "RUF"]
[tool.ruff.flake8-annotations]
allow-star-arg-any
=
true
suppress-none-returning
=
true
[tool.pytest.ini_options]
pythonpath
=
["smart_contracts", "tests"]
[tool.mypy]
files
=
"smart_contracts/"
python_version
=
"3.12"
disallow_any_generics
=
true
disallow_subclassing_any
=
true
disallow_untyped_calls
=
true
disallow_untyped_defs
=
true
disallow_incomplete_defs
=
true
check_untyped_defs
=
true
disallow_untyped_decorators
=
true
warn_redundant_casts
=
true
warn_unused_ignores
=
true
warn_return_any
=
true
strict_equality
=
true
strict_concatenate
=
true
disallow_any_unimported
=
true
disallow_any_expr
=
true
disallow_any_decorated
=
true
disallow_any_explicit
=
true
Next
Algorand Python Testing
Previous
algopy.op
Copyright © 2024, Algorand Foundation
Made with
Sphinx
and
@pradyunsg
's
Furo |
|
Back to top
View this page
Toggle Light / Dark / Auto color theme
Toggle table of contents sidebar
Algorand Python Testing
¶
algorand-python-testing
is a companion package to
Algorand Python
that enables efficient unit testing of Algorand Python smart contracts in an offline environment. This package emulates key AVM behaviors without requiring a network connection, offering fast and reliable testing capabilities with a familiar Pythonic interface.
The
algorand-python-testing
package provides:
A simple interface for fast and reliable unit testing
An offline testing environment that simulates core AVM functionality
A familiar Pythonic experience, compatible with testing frameworks like
pytest
,
unittest
, and
hypothesis
Quick Start
¶
To get started refer to the
official documentation
.
Next
Breakpoint debugging
Previous
PuyaPy compiler
Copyright © 2024, Algorand Foundation
Made with
Sphinx
and
@pradyunsg
's
Furo |
|
Back to top
View this page
Toggle Light / Dark / Auto color theme
Toggle table of contents sidebar
Breakpoint debugging
¶
The AlgoKit AVM VS Code Debugger extension enables line-by-line debugging of Algorand Python smart contracts that are executed on the AVM. It provides a seamless debugging experience by leveraging AVM simulate traces and source maps.
Quick Start
¶
For detailed setup instructions, features, and advanced usage, please refer to the
official repository
.
Previous
Algorand Python Testing
Copyright © 2024, Algorand Foundation
Made with
Sphinx
and
@pradyunsg
's
Furo |
Subsets and Splits