This is the reference implementation of Smart ASA based on the ARC-20 specification.
The implementation offers:
-
A basic Smart ASA;
-
A Smart ASA with ASA Metadata Registry integration (RECOMMENDED).
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.
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.
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 ASAasa_metadata_registry_initmethod 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]:AssetConfigtransaction 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.
Deploy on LocalNet
algokit project deploy localnet arc89_smart_asa
algokit explore- Download the ARC-56 App Spec JSON file;
- Navigate to the Lora App Lab;
- Create the App Interface using the deployed App ID and App Spec JSON;
- Explore the Smart ASA interface.
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 testor, for verbose results:
poetry run pytest -s -v tests/<test_case>.py