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:
pragma
command - Creating a contract:
contract
command - 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:
constructor
command
- Variable type:
address
- Owner concept
- Global variable:
msg.sender
- Checking conditions:
if
command - Permissions and access concepts
- Managing conditions:
require
command - 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:
mapping
command - Access control: creating a whitelist using a
mapping
- Enum concept
- Structs
- Combining
mapping
andstruct
- One struct per address
- You can only modify your own struct, no whitelist
- Combining
mapping
andarray
- Each address has a mapping with array of structs