-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathW3day1.sol
More file actions
53 lines (41 loc) · 1.24 KB
/
W3day1.sol
File metadata and controls
53 lines (41 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.26;
contract NestedStruct{
struct Wallet {
uint256 balance;
uint256 lastDeposit;
}
struct Security {
bool twoFAenabled;
bool isFrozen;
}
struct Profile{
string username;
uint256 createdAt;
}
struct User{
Wallet wallet;
Security security;
Profile profile;
}
mapping(address => User) public users;
function Register(string memory username) public{
users[msg.sender].profile = Profile({
username: username,
createdAt: block.timestamp
});
users[msg.sender].security.isFrozen = false;
}
function Deposit() public payable{
require(users[msg.sender].security.isFrozen == false, "Account is FROZEN");
require(msg.value > 0, "Deposit a valid amount");
users[msg.sender].wallet.balance += msg.value;
users[msg.sender].wallet.lastDeposit = block.timestamp;
}
function getBalance(address user) public view {
users[user].wallet.balance;
}
function frozeProfile(address user) public {
users[user].security.isFrozen = true;
}
}