Base classes
FA2 contracts can be created by extending one of the 3 base classes:
FA2.Fa2Nft
FA2.Fa2Fungible
FA2.Fa2SingleAsset
These classes have different specialized ledger
type. Apart from that they share the same functionalities and interface. We don't recommend having both fungible and non-fungible tokens in the same contract.
When inheriting a base class you obtain a standard FA2 contract with offchain views and metadata.
Fa2Nft
This class represents NFTs.
Ledger type: sp.TBigmap(sp.TNat, sp.TAddress)
Key: <token_id>
Value: <owner>
class ExampleFa2Nft(FA2.Fa2Nft):
pass
Code documentation:
Fa2Nft
Fa2Fungible
This class represents fungible tokens.
Ledger type: sp.TBigmap(sp.TPair(sp.TAddress, sp.TNat), sp.TNat)
Key: (<owner>, <token_id>)
Value: <amount>
class ExampleFa2Fungible(FA2.Fa2Fungible):
pass
Code documentation:
Fa2Fungible
Fa2SingleAsset
This class represents a single (fungible) token.
Ledger type: sp.TBigmap(sp.Address, sp.TNat)
Key: <owner>
Value: <amount>
class ExampleFa2SingleAsset(FA2.Fa2SingleAsset):
pass
Code documentation:
Fa2SingleAsset