Learning Objectives – after this chapter you will be able to:
- Distinguish fungible and non-fungible tokens.
- Describe the ERC-721 interface, token IDs and metadata.
- Explain how ERC-1155 manages many token types in one contract.
- Evaluate NFT storage, royalty and ownership issues.
What is an NFT?
A Non-Fungible Token (NFT) is a token that is unique: each one has its own identifier (token ID) and cannot be swapped one-for-one with another token of the same contract. An NFT records who owns which token ID.
- Fungible (ERC-20): one token = any other token – like currency notes.
- Non-fungible (ERC-721): every token is distinct – like a numbered concert seat or a property deed.
- Uses: digital art and collectibles, game items, event tickets, memberships, domain names, certificates and tokenized real-world assets.
ERC-721 – Non-Fungible Token Standard
| Function / Event | Purpose |
|---|---|
balanceOf(owner) | How many NFTs from this contract an address owns. |
ownerOf(tokenId) | Who owns a particular token. |
safeTransferFrom(from, to, tokenId) | Transfer and check that a receiving contract can handle NFTs. |
transferFrom(from, to, tokenId) | Transfer without the receiver check. |
approve(to, tokenId) / getApproved(tokenId) | Approve one address for one token. |
setApprovalForAll(operator, bool) / isApprovedForAll | Approve an operator (e.g. a marketplace) for all your tokens. |
Events: Transfer, Approval, ApprovalForAll | Logged for wallets and marketplaces. |
Metadata extension: name(), symbol(), tokenURI(tokenId) | Link to a JSON file describing the token (name, image, attributes). |
ERC-721 contracts must also implement ERC-165 (supportsInterface) so other contracts can detect which standards they support.
ERC-1155 – Multi-Token Standard
- One contract can manage many token types – fungible (e.g. 1,000 “gold coins”), non-fungible (a single “legendary sword”) or semi-fungible (100 identical tickets).
- Balances are tracked per (account, id):
balanceOf(account, id)andbalanceOfBatch(...). - Batch transfers –
safeBatchTransferFrom– move many token types in one transaction, saving gas. Events:TransferSingle,TransferBatch,ApprovalForAll,URI. - Popular in blockchain games and ticketing.
| Basis | ERC-20 | ERC-721 | ERC-1155 |
|---|---|---|---|
| Token type | Fungible | Non-fungible | Both, in one contract |
| Balance tracked as | Amount per address | Owner per token ID | Amount per (address, id) |
| Batch transfer | No | No | Yes |
| Typical use | Currencies, governance tokens | Art, collectibles, deeds | Games, tickets, mixed assets |
Metadata, Storage and Royalties
- The blockchain usually stores only the token ID, the owner and a tokenURI. The image and description are in a JSON file stored off-chain.
- If the metadata is on an ordinary web server, it can disappear or be changed. Content-addressed storage such as IPFS (where the link is the hash of the content) or fully on-chain storage makes NFTs more durable.
- Owning an NFT gives ownership of the token; copyright and other rights in the artwork depend on the licence granted by the creator – they are not automatically transferred.
- ERC-2981 defines a standard way for an NFT to report royalty information (
royaltyInfo). Paying royalties depends on marketplaces honouring it; the standard itself does not enforce payment.
Key Takeaways
- NFTs are unique tokens identified by (contract address, token ID).
- ERC-721 = one unique token per ID; ERC-1155 = many fungible and non-fungible types with batch transfers.
- Metadata is usually off-chain – durable storage and clear licences matter.
Question / Answer (15 questions)
Answer : An NFT is a unique blockchain token identified by its contract address and token ID. Unlike fungible tokens, one NFT cannot be exchanged one-for-one with another because each represents something distinct.
Answer : Fungible tokens are interchangeable units of equal value, such as ERC-20 stablecoins. Non-fungible tokens are unique, such as an ERC-721 token representing a specific piece of digital art or a numbered event ticket.
Answer : ownerOf(tokenId) returns the address that currently owns the specified token.
Answer : safeTransferFrom checks that if the recipient is a contract, it implements the ERC-721 receiver interface; otherwise the transfer reverts. This prevents NFTs from being locked in contracts that cannot handle them. transferFrom performs no such check.
Answer : It lets an owner approve an operator, such as a marketplace contract, to manage all of the owner’s tokens in that contract. It is convenient but must be granted only to trusted contracts.
Answer : tokenURI(tokenId), part of the ERC-721 metadata extension, returns a URI pointing to a JSON metadata file describing the token, typically containing a name, description, image link and attributes.
Answer : ERC-165 provides supportsInterface, which lets wallets, marketplaces and other contracts query whether a contract implements ERC-721 (and its extensions) before interacting with it.
Answer : ERC-1155 is the multi-token standard that lets a single contract manage many token types – fungible, non-fungible and semi-fungible – with balances tracked per account and token ID, and supports batch transfers.
Answer : A game can keep all its currencies and items in one contract and transfer many item types in one batch transaction, reducing deployment and gas costs.
Answer : TransferSingle for transfers of one token type and TransferBatch for transfers of multiple token types in one operation.
Answer : The server could go offline or the file could be changed, so the NFT might later point to missing or different content. Content-addressed storage such as IPFS or on-chain storage reduces this risk.
Answer : Not automatically. The buyer owns the token; rights to the underlying work depend on the licence or legal terms provided by the creator.
Answer : ERC-2981 is the NFT Royalty Standard. It defines royaltyInfo(tokenId, salePrice), which returns the royalty receiver and amount. Marketplaces can use it, but the standard does not force payment.
Answer : By the combination of the contract address and the token ID within that contract.
Answer : Event tickets, in-game items, membership or access passes, and certificates or tokenized ownership records for real-world assets.
MCQ Test : Check Your Understanding (5 questions)
Select an option and press Check Answer, or answer all questions and press Submit Test to see your score. Each answer comes with an explanation.
Bibliography/References
The notes, questions and MCQs on this page are original explanations written for this course. The works listed below were consulted and are cited for attribution and further reading. Product names, logos and trademarks belong to their respective owners. Short quotations, where used, are marked and attributed.
- Ethereum Improvement Proposals. (2018). ERC-721: Non-Fungible Token Standard. https://eips.ethereum.org/EIPS/eip-721
- Ethereum Improvement Proposals. (2018). ERC-1155: Multi Token Standard. https://eips.ethereum.org/EIPS/eip-1155
- Ethereum Improvement Proposals. (2020). ERC-2981: NFT Royalty Standard. https://eips.ethereum.org/EIPS/eip-2981
- ethereum.org. (n.d.). Non-fungible tokens (NFT). https://ethereum.org/en/nft/
- ethereum.org. (n.d.). ERC-721 Non-Fungible Token Standard. Ethereum Developer Documentation. https://ethereum.org/en/developers/docs/standards/tokens/erc-721/
- ethereum.org. (n.d.). ERC-1155 Multi-Token Standard. Ethereum Developer Documentation. https://ethereum.org/en/developers/docs/standards/tokens/erc-1155/
- IPFS Documentation. (n.d.). What is IPFS? https://docs.ipfs.tech/concepts/what-is-ipfs/