Skip to content
Tech Interview Prep
Technical interview guide

Token Standards (ERC-20, ERC-721, ERC-1155)

The interface standards that let wallets, exchanges, and other contracts interact with any token the same way: fungible, non-fungible, and multi-token.

Read
45 min
Practice MCQs
25
Interview Q&A
25
Edition
v3
Editorial status
Reviewed

Scope: ERC-20, ERC-165, ERC-721, ERC-1155, ERC-2612, ERC-2981, and ERC-4906 specifications; OpenZeppelin Contracts 5.x documentation reviewed 2026-09-04.

Curated: · Written: · Reviewed:

25 questions

MCQ-7A team implements `mint(address to, uint256 amount)` by calling the internal `_transfer(address(0), to, amount)`. The internal `_transfer` begins with `require(from != address(0) && to != address(0), "zero address")`. What happens when `mint` is called?
MCQ-3A payments service stores USDC balances as uint256 base units and renders them for users with a hardcoded `decimals = 18`. USDC's ERC-20 contract reports `decimals() == 6`. A user with 1_000_000 base units sees a balance of 0.000000000001 USDC and files a support ticket. What is the correct fix?
MCQ-1A router calls `IERC20(token).transfer(to, amount)`, where the interface declares `returns (bool)`, wrapped in `require(..., "transfer failed")`. After listing a token that is 12% of the router's daily volume, every swap through it reverts. The call trace shows the token's call frame returning successfully and the revert raised in the router's frame. A direct `eth_call` of `transfer(to, amount)` from a funded, approved account returns `0x`, while `balanceOf` returns a well-formed 32-byte value. The token cannot be dropped from the listing. What is the correct diagnosis and fix?
MCQ-4Alice has approved 100 tokens to a router. The router transfers 60 tokens to Bob. Alice then submits approve(router, 50) to reduce the allowance. Before that transaction is mined, the router transfers 50 tokens to Carol. The approve(router, 50) is mined after the transfer to Carol. What is the final allowance and how many tokens did Carol receive?
MCQ-5The token is a plain ERC-20: approve sets the allowance to the given value, and transferFrom reverts if the spender's allowance is below the amount. Alice's allowance to router R is 100. She submits approve(R, 50) to lower it. R's operator sees the pending transaction and submits transferFrom(Alice, R, 100) with a higher gas price. That transferFrom is mined in block N, leaving allowance(Alice, R) at 0. The approve is mined in block N+1, setting allowance(Alice, R) to 50. R then submits transferFrom(Alice, R, 50), which also succeeds. Alice's balance fell by 150. Which mechanism produced that?
MCQ-6usdX is an OpenZeppelin v5 ERC20Permit token on Ethereum mainnet (chain id 1). Alice holds 2,000e18 usdX, allowance(Router, Alice) is 0, and nonces(Alice) is 5. With block.timestamp at 1,700,000,010, she signs two EIP-2612 permits off-chain against the token's chain-and-contract domain: both name spender Router and value 500e18 with deadline 1,700,003,600, P1 on nonce 5 and P2 on nonce 6. A relayer submits the two transactions in the same block, P2 first. Once that block is mined, what are allowance(Router, Alice) and nonces(Alice)?
MCQ-8A vault mints shares equal to the `amount` argument it passes to `transferFrom`. It accepts any ERC-20 token. Which credited amount best prevents over-issuing shares when a token takes a fee on transfer?
MCQ-9A vault pulls deposits with `token.safeTransferFrom(msg.sender, address(this), amount)` and mints `amount` shares at the current share price. It is deployed against a token that charges a 2% fee on every transfer and whose `transferFrom` returns no boolean. A user deposits 1,000 tokens and the call succeeds. What is the vault's state immediately after?
MCQ-24A team upgrades an ERC-20 token behind a proxy. The old implementation stored `mapping(address => uint256) balances` at slot 0 and `uint256 totalSupply` at slot 1. The new implementation adds `address public newAdmin;` before `balances`, shifting `balances` to slot 1 and `totalSupply` to slot 2. After the upgrade, `balanceOf(alice)` returns a huge number and `totalSupply()` returns a small nonzero value. Which invariant did the upgrade break?
MCQ-12A marketplace escrow contract accepts NFTs through safeTransferFrom and implements onERC721Received(address,address,uint256,bytes) to record each deposit. What must the hook return so the ERC-721 caller accepts the transfer?
MCQ-25A team's escrow contract is about to send an ERC-721 token to a buyer's contract wallet, and the team wants the transaction to revert rather than leave the token with a wallet that cannot handle NFTs. Which statement describes how the ERC-721 standard meets that requirement?
MCQ-11A marketplace calls transferFrom(user, buyer, tokenId) for whichever token a buyer picks from a collection. The integration spec requires exactly one approval transaction from the user, covering every token they own in that collection including tokens minted after the approval, and users must keep custody of their NFTs. After launch, transfers revert with 'ERC721: caller is not token owner or approved' whenever the buyer picks a token other than the one the user approved. Which change fixes the integration?
MCQ-10An indexer ingests ERC-721 Transfer events for three collections deployed on the same chain into one table keyed by `token_id` alone. After 15,000 mints (5,000 per collection) the table holds 5,000 rows. Two bugs surface: transferring collection B's token #42 changes the owner displayed for collection A's token #42, and after collection A's token #42 is burned the dashboard lists `0x0000...0000` as its owner. Which change fixes both symptoms?
MCQ-2An indexer keeps one row per ERC-721 asset. A collection was deployed by the same factory to mainnet (chain ID 1) and to Base (chain ID 8453), and CREATE2 gave both deployments the same contract address. Mainnet minted token IDs 1-3,000; Base minted 2,501-5,500. Every row carries a chain_id column, but the only unique index is on (contract_address, token_id), with token_id stored as a number. Ingest runs mainnet first, then Base, writing rows with INSERT ... ON CONFLICT (contract_address, token_id) DO UPDATE SET chain_id = EXCLUDED.chain_id, owner = EXCLUDED.owner. After both passes, how many rows does the table hold and how many of them carry chain ID 1?
MCQ-14An NFT marketplace indexer tracks a 10,000-token ERC-721 collection. Its current pipeline only listens for the ERC-721 Transfer event and re-reads tokenURI when a transfer is seen. A collection owner now updates the image and attributes of 400 tokens in place, without transferring any of them. The indexer's stored metadata for those 400 tokens stays stale for days, and the team wants the smallest change that makes the indexer pick up in-place metadata edits. Which change should the team make?
MCQ-13An indexer walks NFT collections and flags a token when the image a browser will load is not fixed by a content-addressed identifier that the contract's own tokenURI logic commits to. In other words, the contract's returned bytes must name the image bytes, not just a host. It walks three collections today: - C1, 2,000 tokens: tokenURI(id) returns ipfs://bafyMeta.../id.json, a CID baked into the contract with no setter; that JSON's image field is https://cdn.c1.example/id.png. - C2, 3,000 tokens: tokenURI(id) returns https://api.c2.example/id.json from the collection's own server; that JSON's image field is ipfs://bafyImg.../id.png. - C3, 1,500 tokens: tokenURI(id) returns a data: URI holding the whole JSON, assembled from immutable token data with no setter; that JSON's image field is ipfs://bafyImg.../id.png. How many tokens does the indexer flag in each collection?
MCQ-21A marketplace's listing guard runs three staticcalls against a collection, each capped at 30,000 gas, and lists the collection as ERC-721 only if all three return true: - `supportsInterface(0x01ffc9a7)` → `true` - `supportsInterface(0xffffffff)` → `true` - `supportsInterface(0x80ac58cd)` → `true` All three passed and the collection was listed. What does the guard's rule get wrong?
MCQ-15A marketplace contract needs to render a "My NFTs" page for a wallet. The team's first design calls `balanceOf(owner)` and then loops `tokenOfOwnerByIndex(owner, i)` for i in 0..balance-1, reading each token's metadata URI on-chain in a single view call. The collection contract implements ERC-165 and returns true for `0x80ac58cd` (ERC-721) but false for `0x780e9d63` (ERC-721 Enumerable). The wallet holds 3,000 tokens from this collection, and the page must load in under 2 seconds against a node with a 30M gas `eth_call` cap. What is the correct diagnosis and fix?
MCQ-16A marketplace's settlement contract calls royaltyInfo(tokenId, 0), passing 0 as the sale price, before each sale, then transfers the returned amount to the returned receiver. The collection computes its royalty as 5% of the salePrice argument. A 10 ETH sale settles and the seller is paid. What does the splitter receive?
MCQ-22A studio ships a game's items as ERC-1155 tokens in a single contract. Porting an ERC-721 integration, an engineer calls approve(marketplace, 42) to let the marketplace move a player's item #42; the call fails because ERC-1155 defines no per-token approve. The marketplace still has to move items out of player wallets. Which statement about the approval the marketplace needs is correct?
MCQ-20A correctly implemented indexer replays ERC-1155 logs for one collection from its deployment block, applying each log once in (block, transactionIndex, logIndex) order. For token id 42 it sees, in order: (1) TransferSingle from 0x0 to Alice, value 500; (2) TransferBatch from Alice to Bob, ids [42, 43], values [120, 200]; (3) TransferSingle from Bob to Alice, value 50; (4) TransferSingle from Alice to 0x0, value 30. What balance does it report for Alice, id 42?
MCQ-23An indexer calls uri(31) on an ERC-1155 contract and receives the template `ipfs://bafy.../{id}.json`. It must resolve that template to the concrete metadata URL for token ID 31. Which substitution produces the path the standard defines?
MCQ-19A contract escrow is the recipient of a single `safeTransferFrom` on an ERC-1155 collection, and the escrow does not implement ERC-165. When does the ERC-1155 implementation call the receiver hook on that escrow?
MCQ-18An escrow contract holds 6 units of token ID 7 and 4 units of token ID 12 in an ERC-1155 collection. Its settlement function calls safeBatchTransferFrom(escrow, buyer, [7, 12], [3, 5], ""), where buyer is an externally owned account. What does the call do?
MCQ-17A marketplace indexer already serves ERC-721 collections with a table keyed UNIQUE(contract, token_id) and one row per token. It must answer 'how many units of token ID does a given account hold?' for every collection it serves. You point it at an ERC-1155 contract whose ID 7 is a fungible in-game currency: 40,000 units held across 3,000 addresses. What must the indexer store for ID 7?