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.

Minutes to read
4
Practice MCQs
25
Interview Q&A
25
Edition
v4
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.

Overview

Curated: · Written: · Reviewed:

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

In one line

One wire format per asset shape: ERC-20 for interchangeable units, ERC-721 for unique items, ERC-1155 for many token types in one contract. Reach for it when one integration must work with any compliant token, and say first that conformance proves call signatures and events, not value, custody or safety.

Key definitions

  • Base units: the integers stored on chain. decimals() is display metadata and changes no arithmetic.
  • Allowance: a spender's remaining transferFrom authority. approve overwrites it.
  • Token identity: (chain, contract, token ID) for NFTs. A token ID alone identifies nothing.
  • Operator approval: setApprovalForAll, which grants one address every token one owner holds in that contract.
  • Receiver hook: onERC721Received or onERC1155Received. It must return its exact selector or the transfer reverts.
  • ERC-2612 permit: an EIP-712 signature that sets an allowance and consumes the owner's nonce.

Formulas and complexity

amounthuman=amountbase10decimalsamount_{human} = \frac{amount_{base}}{10^{decimals}} credited=balanceAfter−balanceBeforecredited = balanceAfter - balanceBefore

Balance-difference accounting costs two balanceOf calls per deposit.

How it works

  • transfer moves the caller's balance. transferFrom checks allowance[owner][spender] and decrements it.
  • A token may return nothing, return false instead of reverting, take a fee, or rebase. A caller that decodes a missing bool reverts even though the transfer succeeded.
  • Safe NFT and ERC-1155 transfers update state, then call the receiver hook on contract recipients. A wrong return value reverts the whole transfer.
  • Event logs alone rebuild ownership and balances, so indexers key rows by canonical identity and roll back on reorgs.
no yes yes no safeTransferFrom Update balances or owner Recipient has code? Transfer complete Call receiver hook Returns exact selector? Revert whole transfer

When to use and when not to

SituationStandardTrade-off to state
Interchangeable units, full DeFi toolingERC-20Read decimals per token. Fee and rebase tokens need balance-difference accounting.
Unique items, per-token provenanceERC-721Enumeration is optional. Index events off-chain at scale.
Many token types or batch moves in one contractERC-1155setApprovalForAll is all-token authority. There is no per-token approve.
Royalty displayERC-2981A lookup. Payment is voluntary, and peer-to-peer transfers skip it.
Tokenizing an asset with no real obligationsNoneDocument issuer, upgrade, custody and exit first.

Traps interviewers probe

  1. Trusting the bool. The token returned empty data on success, so the router's ABI decode reverted in its own frame. Fix: use SafeERC20 safeTransfer, which accepts empty return data and treats an explicit false as failure. An eth_call that returns 0x points to this.
  2. Hardcoding decimals. 1,000,000 base units is 1 USDC at 6 decimals and 0.000000000001 at 18. Fix: call decimals() per token and convert at the boundary.
  3. Crediting the requested amount. A 2% fee on a 1,000 token deposit delivers 980. Minting 1,000 shares leaves the vault 20 tokens short. Fix: credit the balance difference, and reject tokens you cannot account for.
  4. Racing an allowance overwrite. Lowering an allowance from 100 to 50 lets the spender take 100 with the old value, then 50 after the new one lands, 150 in total. Fix: set zero first, or use increase and decrease allowance.
  5. Keying NFTs by token ID alone. Collections and chains reuse IDs, so a burn or transfer in one overwrites another's row. Fix: key on (chain, contract, token ID). Worked example: mainnet IDs 1 to 3,000 and Base IDs 2,501 to 5,500 sharing one (contract, token_id) key, with chain_id overwritten by the later write, leave 5,500 rows, 2,500 of them carrying chain ID 1.

Interview tips

Open with: "This is an interface standard. Conformance guarantees the ABI, so I check behaviour separately." Then answer the question asked.

Follow-ups to expect:

  • Fee-on-transfer token in a vault: balance-difference accounting, or reject the token at the allowlist.
  • Permit replay: the EIP-712 domain binds chain and contract, and the nonce is consumed once. With the nonce at 5, a permit signed for nonce 6 reverts. Once the nonce-5 permit lands, the nonce is 6.
  • Token that lies about interfaces: ERC-165 picks a code path, then behaviour is verified. supportsInterface(0xffffffff) must return false.
  • Operator approval in an NFT marketplace: setApprovalForAll covers future mints and removes per-token control, so disclose the breadth.
  • Proxy upgrade: append new state variables only. Inserting one shifts later slots, so balances and totalSupply read the wrong data.
  • Indexer reorg: roll back by block and key rows by (chain, contract, block, transaction, log index).

30-second answer outline:

  1. Name the standard and its shape: fungible, unique, or multi-token.
  2. State what conformance guarantees and what it does not.
  3. Give the integration rule: read decimals per token, check return data, credit the amount received.
  4. Name the trap that matches the question, then the fix.

Feedback on this overview

Log in free to save your progress and keep bookmarks and notes for a quick revision before your interview.