What Is a Token?
A token is a balance sheet kept by a smart contract. The contract stores who owns how many units. ERC-20 is the standard for fungible tokens, where every unit is identical and interchangeable (like rupees or dollars).
ERC-20 Interface
| Function | Purpose |
|---|---|
totalSupply() | Total tokens in existence |
balanceOf(owner) | Balance of an address |
transfer(to, amount) | Send tokens from caller |
approve(spender, amount) | Allow another address to spend your tokens |
allowance(owner, spender) | How much the spender may still use |
transferFrom(from, to, amount) | Spender moves tokens on behalf of owner |
Events: Transfer and Approval. Wallets and exchanges rely on these standard names.
Decimals
- Tokens have no decimal type, so 18 decimals is the usual convention
- A balance of
1000000000000000000with 18 decimals is 1.0 token - Wallets display the number divided by 10^decimals
Build It With OpenZeppelin
_mintcreates tokens. Here the deployer gets the first supply- Only the owner can mint more. Think about this carefully: unlimited owner minting is a trust risk
ERC20Burnablelets holders destroy their own tokens
The Approve and TransferFrom Flow
A decentralized exchange cannot take tokens from your wallet without permission. The flow is:
- You call
approve(exchange, 100). This allows the exchange contract to pull up to 100 tokens - The exchange calls
transferFrom(you, pool, 100)when you trade - The allowance goes down by the amount used
Test in Remix
- Deploy with
1000asinitialSupply - Call
balanceOffor your account. You should see 1000 followed by 18 zeros - Call
transferto another account. Check both balances - Call
approvefrom account 1 for account 2, thentransferFromfrom account 2
Design Questions Before Launch
- Fixed or mintable supply?
- Who holds the owner key? Use multisig for real projects
- Do you need pausing, taxes or blocklists? Each adds risk
- Has the contract been tested and audited?
Practice
- Create your own token with a fixed supply and no mint function
- Explain approve and transferFrom to a friend
- Why do tokens use 18 decimals?
Conclusion
ERC-20 is the fungible token standard. Build with OpenZeppelin, think carefully about minting power, and understand approve plus transferFrom for safe interactions.

