This is a set of smart contracts examples to learn Solidity fundamentals
Register-01.sol is a very basic smart contract.
Then will be created new versions, adding Solidity concepts in each of them.
I suggest to try it in Remix
- Comments
- License-Identifier
- Solidity version:
pragmacommand - Creating a contract:
contractcommand - Variable type:
string - Variable visibility:
private - Creating a function:
function - Function visibility:
external - Function types:
view - Function with parameters
- Returning data in functions
- Variable type:
uint - Variable visibility:
public - Initializing a variable
- Increasing numbers
- Initializing a contract:
constructorcommand
- Variable type:
address - Owner concept
- Global variable:
msg.sender - Checking conditions:
ifcommand - Permissions and access concepts
- Managing conditions:
requirecommand - Error messages
- Function modifiers
- Events
- All together 1
- types string, uint, address
- msg.sender and owner, constructor
- require, function modifiers, events
- Array
- Loop structures:
for - Local / memory array
- Key -> value concept:
mappingcommand - Access control: creating a whitelist using a
mapping
- Enum concept
- Structs
- Combining
mappingandstruct - One struct per address
- You can only modify your own struct, no whitelist
- Combining
mappingandarray - Each address has a mapping with array of structs