EXPERIMENTAL WIP
There is no guarantee to the API of this repository. It is subject to change without a tagged release.
This repository is meant to contain PyTEAL utility methods common in many Smart Contract programs.
InlineAssembly
- Can be used to inject TEAL source directly into a PyTEAL program
accumulate
iterate
- Provides a convenience method for calling a method n times
odd
- Returns 1 ifx
is oddeven
- Returns 1 ifx
is evenfactorial
- Returnsx! = x * x-1 * x-2 * ...
wide_factorial
- Returnsx! = x * x-1 * x-2 * ...
wide_power
exponential
- Approximatese ** x
forn
iterationslog2
log10
- Returns log base10
of the integer passedln
- Returns natural log ofx
of the integer passedpow10
- Returns10 ** x
max
- Returns the maximum of 2 integersmin
- Returns the minimum of 2 integersdiv_ceil
- Returns the result of division rounded up to the next integersaturation
- Returns an output that is the value of n bounded to the upper and lower saturation values
GlobalBlob
- Class holding static methods to work with the global storage of an application as a binary large objectLocalBlob
- Class holding static methods to work with the local storage of an application as a binary large objectglobal_must_get
- Returns the result of a global storage MaybeValue if it exists, else Assert and fail the programglobal_get_else
- Returns the result of a global storage MaybeValue if it exists, else return a default valuelocal_must_get
- Returns the result of a loccal storage MaybeValue if it exists, else Assert and fail the programlocal_get_else
- Returns the result of a local storage MaybeValue if it exists, else return a default value
atoi
- Converts a byte string representing a number to the integer value it representsitoa
- Converts an integer to the ascii byte string it representswitoa
- Converts an byte string interpreted as an integer to the ascii byte string it representshead
- Gets the first byte from a bytestring, returns as bytestail
- Returns the string with the first character removedsuffix
- Returns the last n bytes of a given byte stringprefix
- Returns the first n bytes of a given byte stringrest
encode_uvarint
- Returns the uvarint encoding of an integer
assert_common_checks
- Calls all txn checker assert methodsassert_min_fee
- Checks that the fee for a transaction is exactly equal to the current min feeassert_no_rekey
- Checks that the rekey_to field is empty, Assert if it is setassert_no_close_to
- Checks that the close_remainder_to field is empty, Assert if it is setassert_no_asset_close_to
- Checks that the asset_close_to field is empty, Assert if it is set
Common inner transaction operations
pay
axfer
As PyTEAL user, your contribution is extremely valuable to grow PyTEAL utilities!
Please follow the contribution guide!
- Set up the sandbox and start it (
dev
mode recommended):./sandbox up dev
- Clone this repo:
git clone https://github.com/algorand/pyteal-utils.git
andcd
into thepyteal-utils
directory - Install Python dependecies:
poetry install
- Activate a virual env:
poetry shell
- Configure pre-commit hooks:
pre-commit install