For this next part, I will assume you have some programming knowledge. Anything from functions and variables to classes and interfaces. Solidity isn’t hard to learn but it does have its quirks you need to keep in mind.
Mappings
Mappings are a way to store data in Solidity. When given a key, they will retrieve the value for you. For example, the owner of a token given by index.
They are often used to keep track of the owners of tokens. But in more intricate smart contracts they often have lots of uses.
Functions
The syntax for functions is pretty standard across languages. Solidity has a slightly different syntax because of modifiers.
The scope
indicates who can call the function. This would be private
, public
, internal
or external
. A view
function doesn’t cost any gas fees but it can only be read from the chain.
Modifiers
Modifiers make sure that only certain users can execute a function. The most used default modifier is onlyOwner
which makes sure only the owner of the contract can execute the function. But you can make your own.
the _;
syntax lets the code return to the function called the modifier. If you call _;
the code will assume that the condition has passed.
There are a lot of checks you can do with modifiers that you would otherwise have to do in the function itself.