NFTs & Token Standards

ERC-20, ERC-721 and ERC-1155 side by side, plus metadata, on-chain vs off-chain storage and royalty enforcement realities.

9 min read·5 quiz questions

Fungible vs non-fungible

ERC-20 defines fungible tokens: every unit is interchangeable, tracked as one balance per address. ERC-721 defines non-fungible tokens: each tokenId is unique and individually owned, with its own metadata. ERC-1155 is a multi-token standard letting a single contract manage both fungible and non-fungible token types, saving gas versus deploying many separate contracts.

  • ERC-20: balanceOf(address) → uint256.
  • ERC-721: ownerOf(tokenId) → address, one owner per unique id.
  • ERC-1155: balanceOf(address, id) → uint256, batched transfers.

Metadata and where art actually lives

An NFT contract usually stores only a tokenURI pointing to a JSON metadata file describing name, image and attributes. That file and the image it references can be hosted on a centralized server (fragile — it can disappear), IPFS (content-addressed, but needs pinning to stay available), or, less commonly, fully on-chain as base64-encoded data (durable but expensive).

  • Centralized URL: cheapest, least durable.
  • IPFS: content hash guarantees integrity if pinned by someone.
  • Fully on-chain: most durable, most expensive to store.

Approvals and marketplaces

Marketplaces don't hold your NFT to list it; you grant an approval (approve or setApprovalForAll) letting a marketplace contract move the token on your behalf when a sale executes. This is powerful and risky — a malicious or compromised marketplace contract with blanket approval can transfer every approved asset, so approvals should be reviewed and revoked when no longer needed.

Royalties

ERC-2981 lets a contract declare a suggested royalty percentage and recipient for secondary sales. Critically, it's a signal, not an enforcement mechanism — nothing on-chain forces a marketplace to pay it. Many marketplaces made royalties optional, which is why creators increasingly rely on off-chain agreements or contract-level transfer restrictions instead of trusting ERC-2981 alone.

Key terms

ERC-721
Standard for non-fungible tokens, each tokenId uniquely owned.
ERC-1155
Multi-token standard supporting both fungible and non-fungible types in one contract.
tokenURI
Function returning the location of a token's off-chain metadata JSON.
setApprovalForAll
Grants an operator permission to transfer all of a user's tokens in a collection.
ERC-2981
Standard for signaling a suggested royalty percentage on secondary sales.

Chapter quiz

5 questions · pass mark 75%
  1. 1. What distinguishes ERC-721 from ERC-20?

  2. 2. What is the main advantage of ERC-1155 over deploying many ERC-721 contracts?

  3. 3. Why is IPFS-hosted metadata not automatically permanent?

  4. 4. What risk comes with setApprovalForAll?

  5. 5. Is ERC-2981 royalty payment enforced on-chain?

Answer every question to submit. Progress for nfts-and-token-standards is saved in this browser.