Overview
Introduction
FA2 is the Tezos standard for a unified token contract interface.
It caters to a diverse range of token types and implementations, including but not limited to fungible tokens and NFTs.
The standards relevant for FA2 are TZIP-12 and TZIP-16. They are functionality equivalent to Ethereum's ERC-20, ERC-721, and ERC-1155.
Library
SmartPy provides a modular FA2 library that can be configured and adapted with custom logic to support a very wide range of needs.
import smartpy as sp
from templates import fa2_lib as fa2
Resources
Here are some key resources to help you navigate the FA2 library:
- Library template: view, download
- Library tests: NFT view, download; Fungible: view, download; Single asset: view, download
Token identification
A token is uniquely identified on the chain by:
- its contract address and
- a token id, which is a natural number (
sp.nat
).
If a contract supports only a single token, the token ID must be 0. Although the contract is responsible for managing and assigning token ids, the FA2 library simplifies this process by automatically incrementing token ids.