What is the ERC-20 token standard?

Answer

ERC-20 (Ethereum Request for Comment 20) is the standard interface for fungible tokens on Ethereum. All ERC-20 tokens implement a common interface that wallets, exchanges, and DeFi protocols can interact with uniformly. Required functions: totalSupply() — total token supply; balanceOf(address) — token balance of an address; transfer(address to, uint256 amount) — send tokens; transferFrom(address from, address to, uint256 amount) — transfer on behalf of another (requires approval); approve(address spender, uint256 amount) — authorize a contract to spend tokens; allowance(address owner, address spender) — check approved amount. Required events: Transfer(indexed from, indexed to, value), Approval(indexed owner, indexed spender, value). Examples: USDC, DAI, LINK, UNI. ERC-20 is the foundation of DeFi — DEXes, lending protocols, and yield farms all rely on the ERC-20 standard. Use OpenZeppelin's ERC20 implementation as a base contract rather than implementing from scratch: contract MyToken is ERC20 { constructor() ERC20("My Token", "MTK") { _mint(msg.sender, 1000000 * 10**decimals()); } }.