Track 9 · What now · lesson 1

Reading production code

30 min


You can write contracts now. The next skill is reading ones you did not write — because that is most of the job, whether you are auditing, integrating, or learning from the best.

Start with Uniswap V2's core pair contract. It is about 350 lines, it has secured billions of dollars for years, and every line is there for a reason you can now work out. It is widely considered some of the best Solidity ever written, and it is short enough to read in an afternoon.

How to read a contract you don't know

Not top to bottom. Follow this order and it goes far faster:

  1. State variables first. What does this contract remember? That tells you what it fundamentally is before you read a single function.
  2. The external functions. What can the outside world make it do? These are the entry points, and the whole attack surface.
  3. Follow the money. Every place value moves in or out. That is where bugs live and where your track 7 instincts earn their keep.
  4. Then the internals, only as needed to understand the above.

What to notice in Uniswap V2

Predict

When reading an unfamiliar contract, why start with its state variables?

Choose one answer

Where to find good code

Check

What's the fastest way to understand what an unfamiliar contract does?

Choose one answer

Worth remembering

  • Reading contracts you didn't write is most of the real job.
  • Uniswap V2's pair contract is ~350 lines of exemplary, readable Solidity — start there.
  • Read in order: state, external functions, value flows, then internals as needed.
  • You'll recognise reentrancy guards and TWAP oracles from track 7 in production.
  • OpenZeppelin, Uniswap, Aave and Solady are the code worth studying.