Your First 90 DaysAcademy
The Vocabulary · Every Word, Inside Real Code · Week 4 · Checkpoint 10

The Registry

A mapping does not have to answer with a number. Read the ENS registry, where every name on Ethereum is three fields under a hashed key, and the owner of one record decides the owner of every record beneath it.

14 steps~27 min3 nodes for your map
01 · Not a token

Four token contracts have gone past now, three of them fungible and one not, and every one kept the same kind of table: who holds what. This file keeps something else entirely. It is the ENS registry, one hundred and eighty nine lines, and it is where every name on Ethereum is written down.

Nothing in it is fungible and nothing in it is counted. What it stores is a record: several facts about one name, kept together under one key. Read the state block first, the way you always do, and the whole difference shows up in two lines.

02 · Where the balances would be

Line 13 is the registry itself. Read it left to right: hand it a `bytes32`, get back a `Record`. A token's ledger returns a number at this point in the line. This one returns a name for something declared a few lines above it, and that is the shape of the whole file.

Line 14 you have met before, in a token's allowance table: an address, then another address, then a `bool`. Two tables, and fourteen functions arranged around them. Every one of those functions either reads one of these two or writes one of them.

03 · A record per key

Lines 7 to 11 declare the shape, and you know this one already: a struct, three fields, each written as a type and then a label. An owner, a resolver, and a `uint64` called `ttl`. Sitting there on its own it stores nothing at all.

Line 13 is where it becomes storage. A mapping whose value is a record rather than a number gives every key three slots instead of one. Ask for `records[node].owner` and you are reading one field, out of one entry, by name.

04 · The key is a hash

The key type is `bytes32`: thirty two bytes, fixed width, with no length to carry around. Line 34 takes one, line 124 takes one, line 146 and line 154 take one. Scroll the file end to end and every function that talks about a name takes that same type.

The word `string` does not appear once. A name is turned into thirty two bytes before it ever reaches this contract, and what arrives is the result of that. Line 13 stores records under those bytes, and the text that produced them lives somewhere else.

Nothing in this file is typed string, and every function takes bytes32 node. So what does the registry actually know about a name?
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?
recordshashed keyssubnodes

Three new nodes on your map

records · hashed keys · subnodes · +10 Lynx