{2/24}
Properly styled computer code is more easily read and understood by humans.
You may revisit the code you write later, or you may work on code with other people in the future. Itβs important that your code is easily understood by yourself and others.
{3/24}
Consistency:
Code is read much more often than it is written. The guidelines provided here are intended to improve the readability of code and make it consistent across the wide spectrum of Solidity code.
{4/24}
Indentation:
Use 4 spaces per indentation level.
Tabs or Spaces:
Spaces are the preferred indentation method.
Mixing tabs and spaces should be avoided.
{5/24}
Within a contract surround function declarations with a single blank line.
Blank lines may be omitted between groups of related one-liners (such as stub functions for an abstract contract)
{6/24}
Maximum Line Length:
Keeping lines under the PEP 8 recommendation to a maximum of 79 (or 99) characters helps readers easily parse the code.
Wrapped lines should conform to the following guidelines.
{7/24}
1. The first argument should not be attached to the opening parenthesis.
2. One, and only one, indent should be used.
3. Each argument should fall on its own line.
4. The terminating element, ); , should be placed on the final line by itself.
{8/24}
Assignment Statements:
{9/24}
Event Definitions and Event Emitters:
{10/24}
Imports:
Import statements should always be placed at the top of the file.
11/24
Order of Functions
Ordering helps readers identify which functions they can call and find the constructor and fallback definitions easier.
Functions should be grouped according to their visibility and ordered:
constructor
fallback function
external
public
internal
private
{12/24}
Control Structures:
The braces denoting the body of a contract, library, functions, and structs should: π
{13/24}
- open on the same line as the declaration
- close on their own line at the same indentation level as the beginning of the declaration.
- The opening brace should be proceeded by a single space.
{14/24}
The same recommendations apply to the control structures if, else, while, and for.
{15/24}
Additionally, there should be a single space between the control structures if, while, and for and the parenthetic block representing the conditional, as well as a single space between the conditional parenthetic block and the opening brace.
{16/24}
Function Declaration:
For short function declarations, it is recommended for the opening brace of the function body to be kept on the same line as the function declaration.
The closing brace should be at the same indentation level as the function declaration.
{17/24}
You should explicitly label the visibility of all functions, including constructors.
{18/24}
The visibility modifier for a function should come before any custom modifiers.
{19/24}
In variable declarations, do not separate the keyword mapping from its type by a space.
Do not separate any nested mapping keyword from its type by whitespace.
12 Tips to learn any new technology in less timeπ
Thread π§΅π
Learning a new technology can be a scary task, but it doesn't have to be if you plan ahead of time.
I learned the following technologies and frameworks from scratch as a complete newbie in OOP in just one year using this technique. I don't pretend that I know each and every bit but I know enough.
7 Tips to help you enhance your problem-solving abilities π
Thread π§΅π
1. Understand the problem
The first step to solving any problem is to understand what the problem is. This may seem obvious, but it is often overlooked. Make sure you know what the problem is before trying to solve it.
2. Break the problem down
Once you understand the problem, the next step is to break it down into smaller, more manageable pieces. This will make it easier to find a solution.
How did a clever transaction trick the Bitcoin system and generated 184 Billion new Bitcoins? π
Thread π§΅π
Back in 2010, there was a transaction that created 184 Billion new Bitcoins.
This was due to the fact that in C++, the amount field is a signed integer and not an unsigned integer.
A clever transaction passed all the checks, including the one for not creating new bitcoins, but only because the output amounts overflowed past the maximum number.
2^64 is 1.84 * 10^19 satoshis, which is 184 billion bitcoins.