Blockchain Developer Token Standards and NFTs 3 — Questions and Answers
Question 1: Which ERC-20 function approves a spender to transfer tokens on the owner's behalf?
- transfer
- approve (Correct answer)
- mint
- burn
Correct answer: approve
approve(spender, amount) authorizes a spender to move up to amount tokens via transferFrom.
Question 2: What known issue affects the classic ERC-20 approve function when changing a non-zero allowance?
- Reentrancy in mint
- The approve race condition (front-running) double-spend risk (Correct answer)
- Integer overflow in totalSupply
- Loss of decimals
Correct answer: The approve race condition (front-running) double-spend risk
Changing an existing allowance can be front-run, letting a spender use both old and new allowances.
Question 3: Which standard adds gasless approvals to ERC-20 tokens via off-chain signatures (permit)?
- ERC-2612 (Correct answer)
- ERC-721
- ERC-1155
- ERC-165
Correct answer: ERC-2612
ERC-2612 introduces permit, allowing approvals through signed messages without a separate on-chain transaction.
Question 4: What does the ERC-20 decimals function represent?
- The total token supply
- The number of decimal places used to display token amounts (Correct answer)
- The contract version
- The number of holders
Correct answer: The number of decimal places used to display token amounts
decimals indicates how to scale the smallest unit; e.g., 18 decimals means 1 token = 10^18 base units.
Question 5: Why can sending ERC-20 tokens directly to a contract not expecting them cause loss?
- The contract auto-refunds
- Plain transfer has no callback, so the contract may not register the deposit (Correct answer)
- Gas is refunded to the sender
- Tokens are burned automatically
Correct answer: Plain transfer has no callback, so the contract may not register the deposit
ERC-20 transfer does not notify the recipient contract, so tokens can be stranded if the contract isn't designed to handle them.
Question 6: Which standard, ERC-777, adds hooks that notify contracts on token sends and receives?
- ERC-721
- ERC-777 (Correct answer)
- ERC-4626
- ERC-20
Correct answer: ERC-777
ERC-777 introduces tokensReceived/tokensToSend hooks via ERC-1820 to react to transfers.
Question 7: What security concern do ERC-777 receive hooks introduce that plain ERC-20 does not?
- Higher decimals
- Reentrancy via the callback during transfer (Correct answer)
- Loss of totalSupply
- Inability to approve
Correct answer: Reentrancy via the callback during transfer
Because hooks hand control to the recipient mid-transfer, they can enable reentrancy attacks if unguarded.
Which ERC-20 function approves a spender to transfer tokens on the owner's behalf?