Skip to content

algorandfoundation/arc20

Repository files navigation

ARC-20 Reference Implementation

This is the reference implementation of Smart ASA based on the ARC-20 specification.

The implementation offers:

The reference implementation:

  • Stores Smart ASA opt-in state in the Local State of the Smart ASA Application;
  • Allows a single Controlled ASA per Smart ASA Application.

Future application enhancements may include:

  • Storing Smart ASA opt-in state in Boxes;
  • Allowing multiple Controlled ASAs per Smart ASA Application.

Smart ASA

The ASA URL (au) and the ASA Metadata Hash (am) fields of the underlying Controlled ASA are initialized the corresponding Smart ASA fields on creation.

The fields on the underlying Controlled ASA are immutable, while the fields of the Smart ASA can be updated by the Smart ASA Manager after creation.

Smart ASA with ASA Metadata Registry Integration

The Smart ASA implementation integrates with the ASA Metadata Registry.

The ASA URL (au) and the ASA Metadata Hash (am) fields of the underlying Controlled ASA are initialized the corresponding Smart ASA fields on creation and MUST be set according to the ARC-89 specification

The Asset Metadata on the ASA Metadata Registry is managed by the ASA Manager.

Since the Controlled ASA Manager is assigned to the Smart ASA Application, the interaction with the ASA Metadata Registry is achieved by a "Flash Asset Metadata Manager" technique: the Smart ASA Application grants the Controlled ASA Manager to the Smart ASA Manager, just for an atomic interaction with the ASA Metadata Registry and immediately revokes it after the operation.

The following is the structure of a Smart ASA - ASA Metadata Registry atomic interaction:

  • [Txn: 0]: Call to the Smart ASA asa_metadata_registry_init method to initialize the interaction with ASA Metadata Registry, and granting the Controlled ASA Manager role to the Smart ASA Manager;

  • [Txn: 1...N]: Calls to the ASA Metadata Registry Application to perform the desired operation (e.g., create or update the Asset Metadata) with eventual MBR payments (if needed);

  • [Txn: N+1]: AssetConfig transaction that returns the Controlled ASA RBAC back to the original Smart ASA Application.

The Smart ASA Application ensures that the Controlled ASA Manager role is granted to the Smart ASA Mnanger, only for the duration of the atomic interaction with the ASA Metadata Registry (of any kind), and that it is revoked immediately after.

Deployments

Deploy on LocalNet

algokit project deploy localnet arc89_smart_asa
algokit explore
  1. Download the ARC-56 App Spec JSON file;
  2. Navigate to the Lora App Lab;
  3. Create the App Interface using the deployed App ID and App Spec JSON;
  4. Explore the Smart ASA interface.

Local Setup and Tests

This reference implementation is developed with AlgoKit.

  • Install AlgoKit
  • Setup your virtual environment (managed with Poetry)
algokit bootstrap all
  • Start your Algorand LocalNet (requires Docker)
algokit localnet start
  • Run tests (managed with PyTest)
algokit project run test

or, for verbose results:

poetry run pytest -s -v tests/<test_case>.py

Packages

 
 
 

Contributors