Solidity Data types explained

Data types

To understand the logic we need to go over data types of Solidity, not just ordinary things, but the features of these types. This exercise should be useful for Smart Contract devs and those who estimate their knowledge. 

Solidity is a typed language, which means that the type of each variable (state and local) needs to be specified at compile-time. Types are divided into simple (value types) and reference types. The difference between them is that when you assign or transfer a parameter to a function, the first copy is the value stored in them, and the second only passes a reference to the place where the value to which they refer (point) is stored. We will analyze them


This type represents that it can store one of two constants TRUE or FALSE. Actually there is an implicit conversion of types in Solidity and numeric values greater than zero, it refers to TRUE, and 0 to FALSE.


int*/uint*: Signed and unsigned integers of various sizes. Differences between signed and unsigned types are- int8 can take values from -127 to 128, and uint8 – from 0 to 255.  * means a number, that indicates the size of this numeric type from 8 to 256. For example: int16, uint32, uint128, int256. But you can write without number and it will be the same like int/uint – int256/uint256. 

You can ask why we need these numbers? This is required for the economical use of memory (Maybe I will write about memory in the future).

Solidity has an automatic type conversion. This is when instead of explicit type definition, you write the keyword var (as in JavaScript), and the compiler tries to define and assign a type to it. 

So here is the interesting thing:

“var i = 0;” will be “uint8 = 0;” and you want to write a cycle 

for(var i = 0; i < 3000; i++) {}

It will not be an error, it will be a way to do an infinite cycle, because type uint8 can`t contain such a large value of 3000. 

I will write about other data types later. In the meantime, do you have any other dev questions you want me to talk about?