Structs
Learn about structs in Solidity.
We'll cover the following
In Solidity, we can create custom data types that can have various properties by using structures, also called structs. By designing a struct, we create a customized data type that allows us to bundle data together into a single category. We can even import these structures from one contract into another, provided that they’ve been declared externally. This is particularly useful because it allows us to use structs as a way to represent records or complex entities within our smart contracts.
Declaration
The struct
keyword is used to define a composite data type that groups variables under a single name. These variables can be of different data types, and they’re known as members of the structure. The syntax for defining a struct is as follows:
Get hands-on with 1200+ tech skills courses.