<100 subscribers
Share Dialog
Share Dialog


Here I introduce you to some primitive data types available in Solidity.

Line 6, we have a bool variable, this type of variable only can have two possible values, true or false.
Lines 8-10, we have uint type, uint stands for unsigned integer, meaning non negative integers.
We can declare uint8 where the possible values goes from 0 to 2 ** 8-1, uint16 (0 to 2 ** 16-1), uint32 …. uint256, by declaring “uint” is an alias for uint256.
The same applies for int type, lines 12-14, but it works with negative numbers and the ranges are different. i.e. for int256 goes from -2 ** 255 to 2 ** 255-1.
Line 17-18, it’s possible to call type().min or max to view the min or max values it can take. Line 20, we have address type, in which we can save EVM addresses. Lines 22-23, we can have data type bytes, it represents a sequence of bytes, There are two types: fixed-size byte arrays and dynamically-sized byte arrays. We will learn it deeply later. Last, these primitives have default values if you don’t assign one when declared. Lines 27-30, “false” for bool type, “0” for uint and int types and “zero address” for address type.
Here I introduce you to some primitive data types available in Solidity.

Line 6, we have a bool variable, this type of variable only can have two possible values, true or false.
Lines 8-10, we have uint type, uint stands for unsigned integer, meaning non negative integers.
We can declare uint8 where the possible values goes from 0 to 2 ** 8-1, uint16 (0 to 2 ** 16-1), uint32 …. uint256, by declaring “uint” is an alias for uint256.
The same applies for int type, lines 12-14, but it works with negative numbers and the ranges are different. i.e. for int256 goes from -2 ** 255 to 2 ** 255-1.
Line 17-18, it’s possible to call type().min or max to view the min or max values it can take. Line 20, we have address type, in which we can save EVM addresses. Lines 22-23, we can have data type bytes, it represents a sequence of bytes, There are two types: fixed-size byte arrays and dynamically-sized byte arrays. We will learn it deeply later. Last, these primitives have default values if you don’t assign one when declared. Lines 27-30, “false” for bool type, “0” for uint and int types and “zero address” for address type.
No comments yet