SOLIDITY - 101 (PART 1)
17 July, 2022
0
0
0
Contributors
You can read my last article about COMPILING SMART CONTRACT, here π Colmpiling Smart Contract
Let's Start
π VARIABLES
- Variables are data items that is defined to store different values for the runtime of the program.
- We have different type of values to store in program like it can be an Integer, String, Characters, boolean etc.
- Variables in solidity are :
Integers
- Numbers can be negative as well as positive but not decimals
Unsigned Integers
- Numbers can only positive but not negative or decimals
Boolean
- True or False
String
- A combination characters. It can be a word, sentence etc.
Address
- Its a special type of data that is used in smart contract. As EVM has an hexadecimal unique value for every accounts or smart contract. We call them address as EVM will interact with the account/contract using the address.
π ACCESS IDENTIFIER
- Access Identifier means that we can decide who can access the variables/function or anything in the smart contract.
- For Security purposes, We need to restrict the access. We do this using access Identifier.
π DEFINING A VARIABLE
- We define variable in solidity as this pattern.
π Remember, We can also omit the access identifier and EVM by default will take internal as access identifier. π Remember, Always try to use Variable Name as self-explanatory. π Remember, We use " " for defining strings and ; to end any syntax.
π SPECIAL ACCESS IDENTIFIER FOR FUNCTIONS
- These access identifier is just to tell EVM how the function will interact with the storage.
π DEFINING FUNCTIONS
- We define function in solidity as this pattern.
π Remember, We can also omit the special access identifier. π Remember, Always try to use Function Name as self-explanatory.
π EXAMPLE
That's all.
In the next article, we will look why we need special access identifiers, how we can add on these variables and use it more space effeciently.
Hello, I am Tanisk Annpurna