NFT Minting and Burning Mechanics 2 — Questions and Answers
Question 1: In ERC-721, which internal function is typically called to create a new token and assign it to an address?
- _mint(to, tokenId) (Correct answer)
- _transfer(from, to, tokenId)
- _approve(to, tokenId)
- _burn(tokenId)
Correct answer: _mint(to, tokenId)
_mint(to, tokenId) creates a new token and assigns ownership to the given address.
Question 2: What event must be emitted when a token is minted in a compliant ERC-721 contract?
- Transfer event with from set to the zero address (Correct answer)
- Approval event
- Mint event with to set to msg.sender
- Burn event with tokenId
Correct answer: Transfer event with from set to the zero address
Minting emits a Transfer event where the 'from' address is the zero address.
Question 3: When a token is burned in ERC-721, what is the 'to' address in the emitted Transfer event?
- The zero address (0x0) (Correct answer)
- The contract owner's address
- The previous owner's address
- The contract's own address
Correct answer: The zero address (0x0)
Burning emits a Transfer event to the zero address, removing the token from circulation.
Question 4: Why does OpenZeppelin's _mint revert if the destination is the zero address?
- Minting to address(0) would be indistinguishable from a burn (Correct answer)
- The zero address cannot pay gas
- It would exceed the max supply
- Solidity forbids passing address(0)
Correct answer: Minting to address(0) would be indistinguishable from a burn
Allowing a mint to the zero address would collide with the convention that burns target address(0).
Question 5: What happens to the totalSupply tracking when a token is burned in an enumerable ERC-721?
- It decreases by one (Correct answer)
- It stays the same
- It increases by one
- It resets to zero
Correct answer: It decreases by one
Burning reduces the total supply count in enumerable implementations.
Question 6: Which access control pattern best restricts who can call a mint function?
- A modifier like onlyOwner or onlyRole(MINTER_ROLE) (Correct answer)
- Making the function payable
- Marking the function as view
- Adding a nonReentrant guard alone
Correct answer: A modifier like onlyOwner or onlyRole(MINTER_ROLE)
Role or ownership modifiers restrict minting to authorized addresses.
Question 7: In a burn function, what check should occur before destroying a token?
- That the caller is the owner or approved for the token (Correct answer)
- That the token price has increased
- That gas price is below a threshold
- That the contract is paused
Correct answer: That the caller is the owner or approved for the token
Only the owner or an approved operator should be permitted to burn a token.
In ERC-721, which internal function is typically called to create a new token and assign it to an address?