NFT Advanced NFT Mechanics 3 — Questions and Answers
Question 1: What does setApprovalForAll allow in an ERC-721 contract?
- Approve one token to one operator
- Approve an operator for all of an owner's tokens (Correct answer)
- Permanently lock tokens
- Mint to multiple recipients
Correct answer: Approve an operator for all of an owner's tokens
setApprovalForAll grants or revokes an operator permission over every token an owner holds in that contract.
Question 2: Why might a developer use OpenZeppelin's ERC721Enumerable extension?
- To enable on-chain enumeration of all tokens and per-owner tokens (Correct answer)
- To add royalties
- To reduce contract size
- To enforce soulbound transfers
Correct answer: To enable on-chain enumeration of all tokens and per-owner tokens
ERC721Enumerable adds totalSupply and indexing functions so tokens can be enumerated on-chain.
Question 3: What is a reentrancy risk when handling NFT purchases with ETH refunds?
- Gas griefing only
- An external call letting an attacker re-enter before state updates (Correct answer)
- Integer overflow
- Front-running the metadata
Correct answer: An external call letting an attacker re-enter before state updates
An external call before updating state can let a malicious receiver re-enter and exploit stale balances.
Question 4: Which pattern is recommended to prevent reentrancy in withdrawal functions?
- Update state before external calls (Correct answer)
- Make functions payable
- Use tx.origin
- Disable events
Correct answer: Update state before external calls
Following checks-effects-interactions—updating state before the external call—prevents reentrant exploitation.
Question 5: What does a minimal proxy (ERC-1167) clone primarily save on?
- Royalty fees
- Deployment gas costs (Correct answer)
- Metadata storage
- Transfer time
Correct answer: Deployment gas costs
ERC-1167 clones delegate to a single implementation, drastically reducing per-deployment gas.
Question 6: In an NFT marketplace, why is using a signed off-chain order (e.g., EIP-712) useful?
- It mints faster
- It enables gasless listings verified on-chain at fill time (Correct answer)
- It removes royalties
- It bypasses approvals
Correct answer: It enables gasless listings verified on-chain at fill time
EIP-712 signed orders let sellers list without gas; the signature is verified on-chain only when an order is filled.
Question 7: What is the risk of storing NFT metadata on a centralized server?
- Higher gas
- Metadata can be altered or go offline (Correct answer)
- Slower minting
- Royalties break
Correct answer: Metadata can be altered or go offline
Centralized hosting means the metadata or image can change or disappear, breaking the NFT's permanence.
What does setApprovalForAll allow in an ERC-721 contract?