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

What It Can Do

A function signature is a summary the compiler keeps honest. Read the nine signatures in Solmate's ERC20 and you can say what a two hundred and six line contract does before you open a single body.

14 steps~26 min3 nodes for your map
01 · The biggest file yet

Your fourth contract, and your third token. This is Solmate's ERC20, the most modern of the three, and it is written to be inherited rather than deployed on its own. Two hundred and six lines, complete, banner comments and all.

Here is the claim this lesson rests on. Nine lines of this file will tell you almost everything it can be asked to do. Not the bodies, not the comments. Nine lines, after which you could describe the contract to someone who has never opened it.

02 · Nine lines, lit

There they are, and there are no others. One constructor and eight functions. Every remaining line in the file is a comment, a state declaration, or a body belonging to one of these nine.

The line that opens a function is called its signature, and it is the part the outside world deals with. A caller never sees a body. It sees a name, a list of what it must hand over, and a list of what comes back.

03 · Anatomy, the front half

Take one and read it slowly. The word `function`, then the name `approve`, then a pair of brackets. Inside the brackets sit the parameters: each one a type and a label, in the order a caller must supply them.

So `address spender, uint256 amount` says this function needs an address and a number, in that order. You now know the exact shape of every call to it, and you have not looked below line 68.

04 · Anatomy, the back half

After the brackets: `public virtual returns (bool)`. Three separate facts, each a single word or phrase, each one you can read without scrolling. We will take them one at a time over the next few steps.

So a signature answers four questions. What is it called, what must a caller bring, who is allowed to call it, and what comes back. Four answers for one line of reading. That is why signatures are the cheapest map of a file there is.

05 · Doors and machinery

Function first: a marker saying a function may be called from outside the contract as well as from inside it. The name: public. Five functions carry it, and those five are the doors.

The other three carry `internal`, the word you met on Uniswap's helpers: reachable from this contract and from anything inheriting it, and from nowhere else. Two words, and the eight functions split into doors and machinery.

Reading only the signatures, which of these can a wallet call directly?
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?
signaturesvisibilityvirtual

Three new nodes on your map

signatures · visibility · virtual · +10 Lynx