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://smartpy.io/templates/fa2_lib.py")
Resources
- The documentation you are currently reading
- Library template: view, download.
- Library tests: NFT view, download, Fungible view, download, Single asset view, download
- pdoc (code documentation): fa2_lib, fa2_lib_test_nft, fa2_lib_test_fungible, fa2_lib_test_single_asset
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.