Struct

In Solidity, a struct is a user-defined composite data type that groups together variables of different data types under a single name. It allows you to create a custom data type that can be used to represent a single object with multiple properties.
Here is an example of how to define a struct in Solidity:
pragma solidity ^0.8.0;
​
contract Example {
struct Person {
string name;
uint age;
address wallet;
}
​
Person public person;
}
In this example, we defined a struct called Person with three properties: name, age, and wallet. We then created an instance of the Person struct called person, which can be accessed and modified by functions in the contract.
Last modified 10mo ago