Skip to content

Instantly share code, notes, and snippets.

@Madhava-mng
Created March 20, 2023 09:14
Show Gist options
  • Save Madhava-mng/c290469c606bb288793f5465a9c00ebb to your computer and use it in GitHub Desktop.
Save Madhava-mng/c290469c606bb288793f5465a9c00ebb to your computer and use it in GitHub Desktop.
linked address mapping in solidity
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