-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuserRegistration.sol
More file actions
33 lines (24 loc) · 978 Bytes
/
userRegistration.sol
File metadata and controls
33 lines (24 loc) · 978 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
25
26
27
28
29
30
31
32
33
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.18;
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol";
import "./thisIsMyContract.sol";
contract UserRegistration is Ownable {
struct User {
bytes32 hashedAddress;
bool registered;
}
mapping(address => User) public users;
event UserRegistered(address indexed user);
// Function to register a user
function register() external {
require(!users[msg.sender].registered, "User already registered");
bytes32 hashedAddress = keccak256(abi.encodePacked(msg.sender));
users[msg.sender] = User(hashedAddress, true);
emit UserRegistered(msg.sender);
}
// Function to get the hashed address information
function getHashedInfo() external view returns (bytes32) {
require(users[msg.sender].registered, "User not registered");
return users[msg.sender].hashedAddress;
}
}