Solidity theorytheory 0/50 · 0%
Standards · medium

33. ERC-20 in detail

Balances, allowances and the approve race.

ERC-20 defines `totalSupply`, `balanceOf`, `transfer`, `approve`, `allowance` and `transferFrom`, plus `Transfer` and `Approval` events. Decimals are cosmetic: values are always integers.

function transferFrom(address f, address t, uint256 v) external returns (bool);

Watch out for non-standard tokens that return no boolean, fee-on-transfer tokens where the received amount is smaller than requested, and the classic approve front-running race (use increase/decrease or permit).

Check your understanding

  1. 1. What do token decimals change on chain?

  2. 2. What is the fee-on-transfer pitfall?

  3. 3. How is the approve race avoided?