Chapter 3

Inheritance and Interfaces

Inheritance lets you reuse and extend contract logic without copy-pasting code. A token might inherit from ERC-20 base behavior, add minting from an Ownable parent, and expose a custom interface for frontends — all composed into one deployed contract.

Abstract contracts can leave functions unimplemented, forcing child contracts to fill in the gaps. Interfaces are even lighter — they declare external functions so your contract can call another without importing its full source.

When overriding functions, use the override keyword and match visibility correctly. Diamond problems — ambiguous resolution when two parents define the same function — are resolved by linearization order, but the cleanest designs minimize overlap and favor composition over deep inheritance trees.