Layout
4 spaces per indentation level
Use spaces for indentation
Use blank lines
1 | contract A { |
Blank lines may be omitted between groups of related one-liners
1 | contract A { |
Use UTF-8
or ASCII
encoding
Place import statements at the top of the file
Functions should be be grouped according to their visibility and ordered:
constructor
fallback function (if exists)
external
public
internal
private
Within a grouping, place the constant
functions last.
Use white spaces in expressions
Avoid extraneous whitespaces inthe following situations: immediately inside parenthesis, brackets or braces, with the exception of single line function declaration.
1 | spam(ham[1], Coin({name: "han"})): |
More than one space around an assignment or other operator to align with
1 | x = 1; |
Don’t include a whitespace in the fallback function
1 | function() { |
For control structure whose body contains a single statement, omitting the braces is ok if the statement is contained on a single line
1 | if (x < 10) |
Function declaration
1 | function increment(uint x) returns (uint) { |
Stirng should be quoted with double-quotes.
Contract and Library Names should be named using the CapWords style.
1 | SimpleToken, |
Event Names should use CapWords
Function Names should use CamelCase
Function Arguments should use CamelCase
Local and State Variables should use CamelCase
Constants should be named with all captial letters with underscores seperating words: MAX_BLOCKS
Modifier should use CamelCase