Skip to content

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:

  1. Chrome or Firefox browser.

  2. An Internet connection

  3. About 60 Minutes of your precious time ⌛

Videos

📺 Full Video Walkthrough: https://www.udemy.com/course/blockchain-developer/?referralCode=E8611DF99D7E491DFD96

Get Started

💪 💪 💪 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.


Last update: April 23, 2021