Created
March 20, 2023 09:14
-
-
Save Madhava-mng/c290469c606bb288793f5465a9c00ebb to your computer and use it in GitHub Desktop.
linked address mapping in solidity
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct Customer { | |
string name; | |
string email; | |
} | |
mapping(address => Customer) customer; | |
mapping(address => address) IDs; // this is the map that make a link address by address or (foo by foo) | |
function addCustomer(string memory _name, string memory _email) public { | |
address tmp; | |
tmp = IDs[0x0000000000000000000000000000000000000000]; | |
do{ | |
if(IDs[tmp] == 0x0000000000000000000000000000000000000000){ | |
IDs[tmp] == msg.sender; | |
customer[msg.sender] = Customer({name:_name, email:_email}); | |
break; | |
} | |
tmp = IDs[tmp]; | |
}while (true); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment