What is the ERC-20 standard and what are its key functions and events?
What the interviewer wants to hear
- Standard interface for fungible tokens
- balanceOf, totalSupply, transfer
- approve, allowance, transferFrom for delegated spending
- Transfer and Approval events
- Why standards matter for wallets and exchanges
Model answer
ERC-20 is a standard interface for fungible tokens, meaning every unit is the same, like rupees or shares. Because every token follows the same interface, wallets, exchanges and DeFi apps can support any new token without custom code. The key read functions are totalSupply, balanceOf(account) and allowance(owner, spender), plus optional name, symbol and decimals. transfer(to, amount) moves tokens from the caller. For contracts to spend tokens on a user's behalf, the user calls approve(spender, amount), and the spender later calls transferFrom(from, to, amount). The standard events are Transfer and Approval, which wallets and indexers use to track balances. In practice I build tokens on OpenZeppelin's audited implementation. I also handle non-standard tokens carefully, for example ones that do not return a bool, using SafeERC20.
Can you answer it under time pressure?
Take a timed easy round and get scored on every answer.
More easy Blockchain Developer questions
- Explain what a blockchain is to someone who is not technical.
- What is a smart contract, and what are its main limitations?
- What is the difference between proof of work and proof of stake?
- Describe the basic architecture of a decentralised application (dApp).
- How does a crypto wallet work, and what is the role of the private key and the seed phrase?
- How are transaction fees calculated on Ethereum today?
- Compare ERC-20, ERC-721 and ERC-1155. When would you use each?
- What are Layer 2 networks, and why are they important for Ethereum?
- What are events in Solidity, and how do you use them in a real project?