Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 43 additions & 15 deletions contract/Ethereum.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,61 @@ contract ENS {

event Sent_Eth(address sender, address receiever, uint256 amount);

//Owner of the contract will have extra previliges
address private immutable owner;

// Mapping system that connects name to address
mapping(string => address) user;
mapping(string => address) private user;

// A variable to check if the address has a name based of the state of its boolen
mapping(address => bool) public wallet_Address;
mapping(address => bool) private wallet_Address;

// A variable to store a 5 digit minified address as we will use it to protect against errors that can be generated from capitalization as James and james are two different things entirely
mapping(uint => address) minified_Address;
mapping(uint => address) private minified_Address;

//We will be using this variable to store the amount of digit we will be using for minified address and since it is a constant we store it directly with 5
uint hashdigit = 5;
uint public hashdigit = 5;

//Modulus variable to make it 10 ^ 8

uint hashModulus = 10 ** hashdigit;
uint private hashModulus = 10 ** hashdigit;


constructor(uint _hashdigit) {
if(_hashdigit > 0) {
hashdigit = _hashdigit;
hashModulus = 10 ** hashdigit;
}
owner = msg.sender;
}

modifier onlyOwner() {
require(msg.sender == owner,'Admin access is required to call this method');
_;
}

/**
@dev allows unregistered users to create a profile with a username
@param _username username of user
*/
* @dev allow owner to update the hashDigit
* @param _hashdigit hashDigit of the unique identifier
*/
function updateHashDigits(uint _hashdigit) onlyOwner public {
require(_hashdigit > 0, "Invalid input provided");

hashdigit = _hashdigit;
hashModulus = 10 ** hashdigit;
}

function getOwner() public view returns(address) {
return owner;
}


/**
@dev allows unregistered users to create a profile with a username
@param _username username of user
*/
// This is three step process where you would sumbit username, use the same name to get a uniue digit code and also verify your digit code/ unique id
function submitUsername(string memory _username) public returns(uint) {
function submitUsername(string memory _username) public {
require(bytes(_username).length > 0, "Empty username");
require(
wallet_Address[msg.sender] == false,
Expand All @@ -47,18 +78,15 @@ contract ENS {
);
minified_Address[min_Digits] = msg.sender;
wallet_Address[msg.sender] = true;
return min_Digits;
emit NewUser(_username, msg.sender);
}


// Input the name to obtain your unique ID

function getDigitCode(string memory _username) public view returns (uint){

uint pack_string = uint(keccak256(abi.encodePacked(_username)));

uint min_Digits = pack_string % hashModulus;

uint pack_string = uint(keccak256(abi.encodePacked(_username)));
uint min_Digits = pack_string % hashModulus;
return min_Digits;
}

Expand Down