Virendra Khorwal

Posted on

# Learn Solidity with me

## Let's start

I am learning Solidity from freeCodeCamp and Solidity Official Documentation. As I learn some new concept I will try to explain to you. This will help me to understand it easily and also maybe you. If you feel something missing comment below. And feel free to ask any queries. All help each other and learn together.

## Basics

I will first begin with the different types or data types in Solidity. There are different types in solidity.

### Integer

• int8 to int256 (8 steps) like int16, int24 etc.
• uint8 to uint256 (8 steps) like uint16, uint24 etc.

`int` are signed integers and `uint` are unsigned integers. `int256` and `int` are same. Similarly, `uint256` and `uint` are also same. Or `int` is alias for `int256` and `uint` is alias for `uint256`.

There are two address types. One is `address` and another is `address payable`. The size of `address` is 20bytes same as the size of Ethereum Address. `address payable` is same as `address` but it have some additional information like `transaction` and `send`. We can implicitly convert `address payable` to `address`. But conversion from `address` to `address payable` done explicitly using `payable(<address>)`

### Fixed Point Number

! Not fully support yet

We can declare fixed point number using `fixed` and `ufixed`. But can't assign to or from.

We will discuss how to perfrom operation on these types and other types in another blog.
Let's discuss the structure of a contract.

## Structure of Contract

If you are familiar with object oriented programming like `C++`, `Java` then you can find contract is similar like classes in these object oriented programming.

``````contract SimpleStorage {
// Code
}
``````

A contract can contain -

• State Variables
• Functions
• Function Modifiers
• Events
• Errors
• Struct Types
• Enum Types

State Variables are variables which permanently stored in contract. They store the state of that variable like

``````contract SimpleStorage {
uint storeValue; // state variable
}
``````

Struct Types are user defined or custom defined types which includes several types.

``````contract SimpleStorage {
stuct Store {
uint height;
int number;
}
}
``````

Similar is Enum types but have finit set of constant values

``````contract SimpleStorage {
enum Store {Created, Seated, Locked}
}
``````

We will discuss Function, Function Modifies, Events Errors in another blog.

## 18 Useful Github Repositories Every Developer Should Bookmark

18 Useful GitHub repositories every developer should bookmark: everything from learning resources and roadmaps to best practices, system designs, and tools.