NFT Advanced NFT Mechanics 2 — Questions and Answers
Question 1: In ERC-721, which function is used to safely transfer a token while checking that the recipient contract can handle ERC-721 tokens?
- transferFrom
- safeTransferFrom (Correct answer)
- approve
- setApprovalForAll
Correct answer: safeTransferFrom
safeTransferFrom verifies the recipient implements onERC721Received before completing the transfer.
Question 2: What does the ERC-2981 standard add to NFT contracts?
- On-chain metadata storage
- Royalty payment information (Correct answer)
- Batch minting support
- Soulbound enforcement
Correct answer: Royalty payment information
ERC-2981 provides a standardized way to signal royalty amount and recipient for secondary sales.
Question 3: Which interface must a contract implement to be recognized for capability detection like ERC-721 support?
- ERC-165 (Correct answer)
- ERC-20
- ERC-777
- ERC-1167
Correct answer: ERC-165
ERC-165 defines supportsInterface, allowing contracts to advertise which interfaces they implement.
Question 4: In ERC-1155, why is balanceOfBatch more gas-efficient than multiple balanceOf calls?
- It caches results off-chain
- It queries multiple token IDs in one call (Correct answer)
- It skips storage reads
- It uses a different opcode
Correct answer: It queries multiple token IDs in one call
balanceOfBatch returns balances for many id/owner pairs in a single function call, reducing overhead.
Question 5: What is a common purpose of a tokenURI returning an IPFS hash rather than an HTTP URL?
- Faster minting
- Content-addressed immutability (Correct answer)
- Lower gas fees
- Built-in royalties
Correct answer: Content-addressed immutability
IPFS hashes are content-addressed, so the metadata cannot change without changing the hash.
Question 6: Which event must ERC-721 emit when ownership of a token changes?
- Approval
- Transfer (Correct answer)
- Mint
- OwnershipChanged
Correct answer: Transfer
The Transfer event logs from, to, and tokenId whenever a token moves between addresses.
Question 7: What is the main advantage of lazy minting?
- Tokens mint automatically each block
- Minting gas is deferred until first purchase (Correct answer)
- It prevents all royalties
- It removes the need for metadata
Correct answer: Minting gas is deferred until first purchase
Lazy minting defers the on-chain mint (and its gas) until a buyer actually purchases the NFT.
In ERC-721, which function is used to safely transfer a token while checking that the recipient contract can handle ERC-721 tokens?