1
The code below should do. The function giveReferenceId assigns an id to a user based on the address. The array clients save a list of users (just in case you need that list at some point). To be sure that the same address only gets one id, the line: require(referenceid[msg.sender]==0); is used...