Your First 90 DaysAcademy
The Grammar · Contracts Talking to Contracts · Week 5 · Checkpoint 12

The One Canonical

Three hundred and five lines to do a job you already watched done in two hundred and six. Read it across four boards and the extra hundred turn out to be one idea repeated: every operation split in two, so that balances only ever move in one place.

16 steps~30 min3 nodes for your map
01 · Three hundred and five lines

In checkpoint four you read a complete ERC20 in two hundred and six lines. Solmate's: terse, self-contained, every operation written out exactly once. This is OpenZeppelin's, the file most tokens on Ethereum inherit from, and it does the identical job in three hundred and five.

It will not fit on one board. So it arrives in four, each showing more of the file than the last, numbered exactly as the file numbers itself. Right now you have lines 1 to 47: the paperwork, what the contract keeps, and the constructor.

02 · Four names after is

Line 29 opens the contract, and four names follow the word `is`. Solmate's ERC20 followed nothing at all. This one inherits from Context, from IERC20 and IERC20Metadata, and from IERC20Errors, and lines 6 to 9 say where each of the four lives.

Three of those four are shapes rather than code. The two interfaces name the functions this file promises to have. IERC20Errors names the errors it is allowed to revert with. Context is the only one carrying a body, and you meet its single function in a moment.

03 · What it keeps, and who may read it

Five things stored, on lines 30 to 37, and every one of them `private`. Look inside the mappings. The key has a name: `address account`, `address spender`. The compiler ignores those names completely, and you do not, which tells you precisely who they were written for.

And the constructor takes two arguments. A name and a symbol, on line 44, assigned on 45 and 46, done. Solmate's constructor also took the number of decimals. This one does not, and the next board shows you where that number went instead.

04 · The public face

The board has grown to line 167, and nine public functions sit on it. Six only read. `decimals` on line 77 is one of the six, and it hands back eighteen from a function body rather than from storage, which is why the constructor on line 44 needed no third argument.

Solmate declared its balances mapping `public` and let the compiler write the getter. This file declares `_balances` private on line 30 and writes the getter itself, on lines 87 and 88. Same answer to a caller, four more lines, one difference worth naming.

Every stored value in this file is private. So how does a wallet read someone's balance?
your balance2,400
BANK_DBowner: the bank
you2,400
what the app is actually showing you
BANK_DBowner: the bank
you2,400their pen
you hold a claim. they hold the pen.
your digital life
BANK · you2,400the bank ✍
INSTAGRAM · you2.1M followersMeta ✍
STEAM · you134 gamesValve ✍
AIRLINE · you58,200 milesthe airline ✍
four tables. zero pens that are yours.
BANK_DBowner: the bank
you2,400
DENIED
try both pens
PLATFORM_DBowner: the platform
her · 8 years2,000,000 followers
one automated decision away
BANK_DB · you · 2,400intentcompetencecontinuity
your row stands on all three
FTX_DBowner: FTX
you5 BTC
the backing vault●●●●●
the row stayed. the backing did not.
CARD_DBowner: your bank ✍
TV you never bought−1,100
fraud reversal+1,100
someone holds the pen, so someone can fix it
?_DBowner: nobody
youstill yours?
?
can a table exist that nobody owns?
?
?_DBowner: ̶n̶o̶b̶o̶d̶y̶
you100
no owner, no pen, no trust?
keeper 1
you100
keeper 2
you100
keeper 3
you100
keeper 4
you100
keeper 5
you100
no THE copy, only copies.
keeper 2
you100
keeper 3
you100
keeper 4
you100
keeper 5
you100
your copy
you100
five copies. one of them is yours.
one attacker
one attacker, ten thousand faces.
real machinesburned wattsnext page, sealed
writing costs watts. faking voters buys nothing.
cost paid OUTSIDE: hardware and power
proof of work, burn energy to vote.
page 1you · 100page 2you · 100page 3you · 100page 4you · 100
rewrite one line, break every lock after it.
office lunchtrusted keeperconsensusfive keepers, real cost
the price buys trustlessness. the office already has trust.
?
ownerless ledger
you?
a key, not a login?
nobody owns the table. so who owns your row?
internal splitone funnelNatSpec

Three new nodes on your map

internal split · one funnel · NatSpec · +10 Lynx