Skip to content

algokit_utils.asset

Classes

ValidationTypeCreate a collection of name/value pairs.

Functions

opt_inOpt-in to a list of assets on the Algorand blockchain. Before an account can receive a specific asset,
it must opt-in to receive it. An opt-in transaction places an asset holding of 0 into the account and increases
its minimum balance by 100,000 microAlgos.
opt_outOpt out from a list of Algorand Standard Assets (ASAs) by transferring them back to their creators.
The account also recovers the Minimum Balance Requirement for the asset (100,000 microAlgos)
The optOut function manages the opt-out process, permitting the account to discontinue holding a group of assets.

API

class algokit_utils.asset.ValidationType

ValidationType(*args, **kwds)

Create a collection of name/value pairs.

Example enumeration:

class Color(Enum): … RED = 1 … BLUE = 2 … GREEN = 3

Access them by:

  • attribute access:

    Color.RED <Color.RED: 1>

  • value lookup:

    Color(1) <Color.RED: 1>

  • name lookup:

    Color[‘RED’] <Color.RED: 1>

Enumerations can be iterated over, and know how many members they have:

len(Color) 3 list(Color) [<Color.RED: 1>, <Color.BLUE: 2>, <Color.GREEN: 3>]

Methods can be added to enumerations, and members can have their own attributes – see the documentation for details.

Initialization

__dir__

dir()

Returns public methods and other interesting attributes.

__format__

format(format_spec)

Default object formatter.

Return str(self) if format_spec is empty. Raise TypeError otherwise.

__hash__

hash()

Return hash(self).

__reduce_ex__

reduce_ex(proto)

Helper for pickle.

__repr__

repr()

Return repr(self).

__str__

str()

Return str(self).

name

name()

The name of the Enum member.

value

value()

The value of the Enum member.

algokit_utils.asset.opt_in

opt_in(algod_client: algosdk.v2client.algod.AlgodClient, account: algokit_utils.models.Account, asset_ids: list[int]) → dict[int, str]

Opt-in to a list of assets on the Algorand blockchain. Before an account can receive a specific asset, it must opt-in to receive it. An opt-in transaction places an asset holding of 0 into the account and increases its minimum balance by 100,000 microAlgos.

Args: algod_client (AlgodClient): An instance of the AlgodClient class from the algosdk library. account (Account): An instance of the Account class representing the account that wants to opt-in to the assets. asset_ids (list[int]): A list of integers representing the asset IDs to opt-in to. Returns: dict[int, str]: A dictionary where the keys are the asset IDs and the values are the transaction IDs for opting-in to each asset.

algokit_utils.asset.opt_out

opt_out(algod_client: algosdk.v2client.algod.AlgodClient, account: algokit_utils.models.Account, asset_ids: list[int]) → dict[int, str]

Opt out from a list of Algorand Standard Assets (ASAs) by transferring them back to their creators. The account also recovers the Minimum Balance Requirement for the asset (100,000 microAlgos) The optOut function manages the opt-out process, permitting the account to discontinue holding a group of assets.

It’s essential to note that an account can only opt_out of an asset if its balance of that asset is zero.

Args: algod_client (AlgodClient): An instance of the AlgodClient class from the algosdk library. account (Account): An instance of the Account class that holds the private key and address for an account. asset_ids (list[int]): A list of integers representing the asset IDs of the ASAs to opt out from. Returns: dict[int, str]: A dictionary where the keys are the asset IDs and the values are the transaction IDs of the executed transactions.