-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStructs.sol
More file actions
24 lines (20 loc) · 839 Bytes
/
Copy pathStructs.sol
File metadata and controls
24 lines (20 loc) · 839 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
//SPDX-License-Identifier: MIT
pragma solidity 0.8.19;
contract Structs {
/*structs---------------------------------------------------------------------------------------------
The contract should now contain the following:
setUserDetails(string calldata name, uint256 age) this function accepts 2 arguments that represent the details
of the user calling the smart contract and it saves them into a defined struct,
getUserDetail() this function retrieves and returns the details saved for the user calling the contract.*/
struct User{
string name;
uint256 age;
}
mapping(address => User) public users;
function setUserDetails(string calldata _name, uint256 _age) public {
users[msg.sender] = User(_name,_age);
}
function getUserDetail() public view returns(User memory _userInfo){
return users[msg.sender];
}
}