-
Notifications
You must be signed in to change notification settings - Fork 37
Home
Erin Hales edited this page Apr 19, 2021
·
6 revisions
Whenever possible, try to keep Contracts, Libraries and Interfaces in their owns files. Additionally, they should go in their respective folders (contracts
, interfaces
and libs
).
- type declarations
- state variables
- events
- functions
Ordering helps readers identify which functions they can call and to find the constructor and fallback definitions easier.
Functions should be grouped according to their visibility and ordered:
- constructor
- initialize()
- modifiers
- external
- public
- internal
- private
Within a grouping, place the view and pure functions last.
camelCase
- events (and event params)
- all state variables
- public and external functions
- internal functions in libraries
_underscoreCamelCase
- function parameters
- local variable names
- internal and private functions in contracts
Note: Avoid naming variables with trailing underscore _var_
.
Group by internal exports first, then external imports.