Blockchain Developer Token Standards and Creation 3 — Questions and Answers
Question 1: What is the key difference between ERC-721 and ERC-1155 token standards?
- ERC-1155 supports both fungible and non-fungible tokens in one contract, ERC-721 only non-fungible (Correct answer)
- ERC-721 is for fungible tokens only
- ERC-1155 cannot represent NFTs
- ERC-721 supports batch transfers but ERC-1155 does not
Correct answer: ERC-1155 supports both fungible and non-fungible tokens in one contract, ERC-721 only non-fungible
ERC-1155 is a multi-token standard handling fungible, non-fungible, and semi-fungible tokens together.
Question 2: Which ERC-721 function returns the owner of a specific token ID?
- ownerOf(tokenId) (Correct answer)
- balanceOf(owner)
- tokenURI(tokenId)
- approve(to, tokenId)
Correct answer: ownerOf(tokenId)
ownerOf(tokenId) returns the address that currently owns the given NFT.
Question 3: What is the primary purpose of the ERC-721 tokenURI() function?
- Return a URI pointing to the token's JSON metadata (Correct answer)
- Transfer the token to a new owner
- Burn the token
- Return the total supply
Correct answer: Return a URI pointing to the token's JSON metadata
tokenURI() returns a link to metadata describing the NFT, often including name, image, and attributes.
Question 4: Why does ERC-1155 enable significant gas savings for transferring many tokens?
- It supports batch operations like safeBatchTransferFrom in a single transaction (Correct answer)
- It eliminates the need for events
- It removes ownership tracking
- It uses no storage
Correct answer: It supports batch operations like safeBatchTransferFrom in a single transaction
Batch transfer functions let multiple token types and amounts move in one transaction, reducing overhead.
Question 5: What safety check distinguishes safeTransferFrom from transferFrom in ERC-721?
- It verifies the recipient contract implements onERC721Received (Correct answer)
- It checks the sender's gas balance
- It validates the token's metadata URI
- It enforces a maximum supply
Correct answer: It verifies the recipient contract implements onERC721Received
safeTransferFrom calls onERC721Received to ensure contract recipients can handle NFTs, preventing locked tokens.
Question 6: In ERC-1155 metadata, what does the {id} substitution placeholder in a URI represent?
- The lowercase hex token ID padded to 64 characters (Correct answer)
- The contract address
- The owner's address
- The chain ID
Correct answer: The lowercase hex token ID padded to 64 characters
Clients replace {id} with the 64-character zero-padded lowercase hex token ID to fetch per-token metadata.
Question 7: Which interface must a contract implement to be recognized as ERC-721 compliant via ERC-165?
- supportsInterface returning true for the ERC-721 interface ID (Correct answer)
- A public mint function
- A fixed totalSupply variable
- An owner-only constructor
Correct answer: supportsInterface returning true for the ERC-721 interface ID
ERC-165's supportsInterface lets contracts advertise that they implement the ERC-721 interface ID.
What is the key difference between ERC-721 and ERC-1155 token standards?