Interfaces
- Interfaces. An interface declares function signatures without bodies: the typed handle to any deployed contract.
- ERC interfaces. Standards ship as interfaces: IERC20 is the contract between tokens and everything that uses them.
- Duck typing on-chain. Any contract matching a signature answers the call: behaviour is the only proof, never the name.
Libraries
- Libraries. A library holds reusable functions: attached to types with using-for, deployed once or inlined.
- Battle-tested first. Money code reuses audited libraries: rewriting a token from scratch is negligence, not craft.
- using for. using SafeCast for uint256 attaches library functions as methods: ergonomics without inheritance.
Inheritance and Composition
- Inheritance. Contracts inherit with is: parents linearised, super walking the chain.
- override and virtual. virtual invites overriding; override declares it: extension points explicit on both sides.
- Composition preferred. Deep inheritance hides state and modifiers: flat composition reads and audits better.
Before and after this level
- Before: Level 6: Contract Interaction: ABI, External Calls, Ether and Value Transfers.
- Next: Level 8: Tokens & Standards: ERC Standards, Fungible and Non-Fungible Assets, Standards-Compliant Contract Design.
In the app each of these ideas is taught and then asked back, and the level ends with a checkpoint and flashcards. See Checkpoints and flashcards.
Frequently asked questions
What does Solidity Level 7: Interfaces & Libraries cover?
Interfaces, Libraries, Inheritance and Composition: 3 lessons and 9 ideas.
What should I know before this level?
The level before it, Level 6: Contract Interaction, which covers ABI, External Calls, Ether and Value Transfers.