Part III · Tokens and allowances
Lab: MBox and ERC-20
A “token” is first of all a set of account balances and rules maintained by a contract, not an asset that must rise in value.
What ERC-20 is
ERC-20 is the most common interface standard for fungible tokens on Ethereum. It defines a set of functions such as:
balanceOf(account): an account’s balance (read-only)transfer(to, amount): the holder sends tokensapprove(spender, amount)andallowance(owner, spender): grant and look up an allowance (Chapter 10)transferFrom(owner, to, amount): an approved spender moves tokens within the allowance
For beginners it is more useful to picture a token as “points shared by a group of partner shops” than as “an asset that goes up”. A standard interface is only an agreement about how to interact: a token can still have special restrictions, fees or admin powers. Being “ERC-20 compliant” does not mean the economics are the same.
| On-chain call | Everyday analogy | What you should observe |
|---|---|---|
balanceOf(A) |
Look up A’s points | Returns data; no transaction needed |
transfer(B, 5) |
A gives B 5 points | A goes down, B goes up |
approve(S, 100) |
Allow a checkout system to deduct up to 100 points | Balances unchanged, allowance changes |
transferFrom(A, B, 5) |
The approved system deducts 5 points | Balances change, allowance usually goes down |
burn(5) (if supported) |
Points cancelled for good | Total supply goes down |
Lab: deploying MBox
- Contract address (matching the prediction from A’s nonce 5): View address on Sepolia Etherscan (opens in a new tab): 0xc4B187783f074111EbeFC50B9a1901f2a4F94630
- Name:
超级无敌宇宙第一老马斯克看了都不知道该叫什么的Token(a deliberately long Chinese joke name; in Solidity it must be written as aunicode"..."string, otherwise compilation fails with “Invalid character”) - Symbol:
MBox;decimals: 18; initial supply 1,000,000, all minted to account A
| Nonce | Time (Singapore) | Action | Transaction | Block | Gas used | Fee (wei) |
|---|---|---|---|---|---|---|
| 5 | 2026-11-12 09:36:24 | Deploy MBox | View transaction on Sepolia Etherscan (opens in a new tab): 0xf9fccb16dd1a0ef99a86d7f4e81cb0e286d4ed4e154963db517c375e3aa92058 | 12115620 | 6,212,065 | 428,632,485 |
| 6 | 09:36:36 | Send 1,000 MBox to the keyless demo address | View transaction on Sepolia Etherscan (opens in a new tab): 0x039ffbb819638f771e760b12e0e01de6ec2c2c6bb5691fa2ed5cd0d6c45eb054 | 12115621 | 141,540 | 9,907,800 |
Balances after the transfer (unchanged at the snapshot): A holds 999,000, the demo address holds 1,000, and totalSupply is still 1,000,000. Transfers do not change total supply.
Sent to a keyless address: gone for good
The 1,000 MBox went to this demo address:
View address on Sepolia Etherscan (opens in a new tab): 0x878fFf967331D01E97c8DdCD76C3Dd97333BcA6ENo private key for this address was ever stored, and it holds no SepETH. Without a private key nobody can sign a transfer out, and confirmed transactions cannot be reversed. So these 1,000 MBox are locked forever and cannot be recovered.
Names and symbols are not unique: trust the address, not the name
name() and symbol() are just unregistered strings returned by the contract. There is no on-chain registry of token names. Anyone can deploy another contract with exactly the same name and symbol, and wallets will display it the same way.
The only way to identify a token is its contract address. Seeing “MBox” does not mean it is this book’s contract; only the address 0xc4B187783f074111EbeFC50B9a1901f2a4F94630 does.
Other observations
- Deployment gas (6,212,065) is again far above a transfer (141,540): there is more code to store, including that very long Chinese name.
- The deployed MBox cannot gain a
burnfunction later. To demonstrate burning, a new contract had to be deployed: MBox-Burn in Chapter 11.