How does the ERC-1155 token standard differ from ERC-20 and ERC-721?

Answer

ERC-1155 is a multi-token standard that can represent both fungible and non-fungible tokens within a single smart contract — addressing limitations of having separate ERC-20 and ERC-721 contracts. Key differences: (1) Multiple token types in one contract — ERC-20 represents one fungible token type; ERC-721 represents one NFT collection; ERC-1155 represents unlimited token types via id; (2) Semi-fungible tokens — a token ID can have multiple copies (e.g., 10,000 copies of "Sword #5" in a game) — not fully unique (like NFTs) but not infinitely fungible (like ERC-20); (3) Batch transferssafeBatchTransferFrom(from, to, [id1, id2], [amount1, amount2], data) transfers multiple token types in one transaction, saving gas; (4) Single approvalsetApprovalForAll grants approval for all token types; (5) Gas efficiency — deploying one ERC-1155 contract is cheaper than deploying multiple ERC-20/ERC-721 contracts; batch minting is cheaper. Use cases: game items (sword, shield, potion — each with different fungibility), marketplace contracts holding diverse assets, music albums (album as NFT, individual tracks as fungible ERC-1155). OpenSea and most NFT platforms support ERC-1155.