Your First 90 DaysAcademy
First Contact · What a Contract Even Is · Week 2 · Checkpoint 3

What It Remembers

A contract's memory is its entire world model, and it is usually nine lines near the top. Read Uniswap V2's token end to end and learn to tell what is stored, what is baked in, and what can never be known.

14 steps~27 min3 nodes for your map
01 · A second token

Your third contract, and your second token. This is the ERC20 that every Uniswap V2 pool is built on: hold some and you hold a share of a pool. Ninety four lines, complete.

You have read a token before, so a lot of this will look familiar. Watch for the places it makes different choices from WETH9, because those differences are where the interesting reading is. This lesson is about one thing above all: what a contract chooses to remember.

02 · Pinned, not ranged

Line 1 reads `=0.5.16`. Not a caret, not a range: an equals sign, naming exactly one compiler version and refusing every other. You have now seen all three styles, a range, a caret and a pin.

Two imports follow. One is an interface, the other a library called SafeMath. The name is a clue about the era. You learned that the 0.8 series made arithmetic revert on overflow. This is 0.5, where it did not, so contracts did that work by hand.

03 · Built on two other files

Line 6 is inheritance, the word you met last lesson: this contract takes on everything an interface declares. Line 7 is something new. Function first: a statement that attaches a library's functions to a type, so they can be written as if the type owned them.

The name: using for. After line 7, any `uint` in this file can be written as `x.add(y)`. It is the same library function either way, just spelled to read like a method. You will meet this everywhere.

04 · Three things it never has to store

Three values, and all three carry a word you have not met. Function first: a marker for a value fixed when the contract is compiled, which can therefore never change and never needs to be looked up. The name: constant.

The name of this token, its symbol, and its eighteen decimals were decided before deployment and are true of every pool that will ever exist. Before reading on: if these are state variables, where does their data live?

These three are declared like state variables but marked constant. Where does their data actually live?
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?
constantsstoragelibraries

Three new nodes on your map

constants · storage · libraries · +10 Lynx