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 signatu... | |
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... | |
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
... | |
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 sa... | |
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 ... | |
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
... | |
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 ... | |
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 mat... | |
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 ... | |
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... | |
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
... | |
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... | |
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... | |
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.
Eac... | |
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 argumen... | |
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 a... | |
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, A... | |
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 C... | |
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
LocalStat... | |
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 Accou... |
End of preview. Expand in Data Studio
README.md exists but content is empty.
- Downloads last month
- 3