Overview โ
INFO
The FA2 library has been introduced on March 4th, 2022 and officially replaces the legacy FA2.py template since June 4th, 2022.
Introduction โ
FA2 is the Tezos standard for a unified token contract interface.
It supports a wide range of token types and implementations (fungible tokens, NFTsโฆ).
FA2 has been standardized through a system called TZIP.
> TZIP-12 and TZIP-16 are the related specifications.
FA2 offers possibilities equivalent to ERC-20, ERC-721 or ERC-1155 in Ethereum.
Library โ
SmartPy provides a modular (experimental) FA2 library that can be configured and adapted with custom logic to support a very wide range of needs.
import smartpy as sp
FA2 = sp.io.import_script_from_url("https://legacy.smartpy.io/templates/fa2_lib.py")
Resources โ
- The documentation you are currently reading
- Library template: view, download.
- Library tests: part 1 view, download, part 2 view, download, part 3 view, download
- pdoc (code documentation): fa2_lib, fa2_lib_test1, fa2_lib_test2, fa2_lib_test3
Token identification โ
A token is uniquely identified on the chain by:
- the token contract address
- a token ID, a natural number (
nat
).
If the contract supports only a single token, the token ID MUST be 0. Otherwise the contract is fully responsible for assigning and managing token IDs.
FA2 library manages incrementing token ids.