Mappings and Structs¶
So far we have only used mappings and simple data types. So, we can now map addresses to booleans, or uint to addresses or any combination of that.
But what if you want to define something a bit more complex?
Let's say you work on the latest DeFi Project and your project does deposits and withdrawals. You not only want to save the amount that was deposited, but also by whom and possibly some more information.
You could define several mappings for this using simple data types. But there is also another way: Structs.
With structs you can define your own Datatype.
What You Know At The End Of The Lab¶
🔣 How you can define your own datatypes using structs
🆒 How to combine structs and mappings to get the most out of your Smart Contract functionality
Prerequisites - You need:¶
Chrome or Firefox browser.
An Internet connection
About 60 Minutes of your precious time ⌛
💪 💪 💪 Let's get started!
Updated to Solidity 0.8
The following Smart Contracts have been updated to Solidity 0.8 and might deviate slightly from the Videos. As always, all and everything will be explained so you don't need to worry to miss anything.