Part III · Tokens and allowances
Lab: MBox-Burn, burning and revoking
Burning really lowers total supply; revoking an allowance changes only the allowance, never balances.
Deploying a burnable token
The deployed MBox has no burn function and cannot get one later, so a separate token with burn / burnFrom was deployed:
- Contract address: View address on Sepolia Etherscan (opens in a new tab): 0x2AE6BbE8b524381535D1f443fe95018b1f64e3F2
- Name:
超级无敌宇宙第一老马斯克看了都不知道该叫什么的焚烧Token(the MBox name with “焚烧”, “burn”, added), symbolMBox-Burn, initial supply 1,000,000, all to account A
Right after deployment, A burned 1,000 of its own tokens: totalSupply fell from 1,000,000 to 999,000. The old MBox contract was not touched.
burn is not “transfer to 0x0”
burnlowers both the holder’s balance andtotalSupply, and emitsTransfer(holder → 0x0, amount).- A plain
transferto the zero address (if a contract allows it) changes balances only and does not lowertotalSupply.
Both can show a “transfer to 0x0” event in an explorer. Whether supply actually fell must be read from totalSupply(), not inferred from the event. This lab used a dedicated burn, so supply really went down.
approve 500, burnFrom 100
- A first sent B 0.0001 SepETH to pay for test gas (B never used a faucet).
- A called
approve(B, 500): allowance 500, balances unchanged. - B called
burnFrom(A, 100): A lost 100, supply fell another 100 to 998,900, and 400 of the allowance remained.
Two transferFrom calls in Chapter 12 later used 300 of those 400, leaving 100. That 100 allowance stayed in place after the lab; nobody cleared it.
D-01: revoking the leftover 100
The P0 review recorded this leftover allowance as a Low finding (F-ALLOW-001): not a compromised contract but a leftover from the experiment. If B signed, it could still move up to 100 test tokens. Decision D-01 approved revoking it. After re-reading the allowance, nonce and balances and simulating again, A broadcast exactly one approve(B, 0):
- Block 12117312, status success; gasUsed 24,538, effective gas price 69 wei, fee 1,693,122 wei
allowance(A, B): 100 → 0- Balances and supply unchanged: A 998,800, B 100,
totalSupply998,900 - A’s nonce 19 → 20
All MBox-Burn transactions
B’s two transferFrom calls are in Chapter 12.
MBox-Burn at the snapshot
| Item | Value |
|---|---|
| totalSupply | 998,900 |
| balanceOf(A) | 998,800 |
| balanceOf(B) | 100 |
| allowance(A, B) | 0 (revoked) |
998,900 = 1,000,000 − 1,000 (A’s own burn) − 100 (B’s burnFrom).
Three things you can check yourself
- Transaction details: the network is Sepolia, the sender is A, the target is the MBox-Burn contract, the status is success.
- Event or contract read: the
Approvalevent, or readallowance(A, B)directly and see that it is 0. - Balances and supply: changing an allowance should not change the holder’s assets.