-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathregistration.sol
32 lines (28 loc) · 991 Bytes
/
registration.sol
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
pragma solidity ^0.4.0;
contract CitizenRegistration {
event ErrorLogger(string);
event AddCitizen(string);
struct _Citizen{
string _fullname;
uint _dateofbirth;
string _permanentAddress;
bool _isACitizen;
}
_Citizen[] _Citizens;
mapping (address => _Citizen) _validCitizens;
function addCitizen (string fullname,uint dateofbirth , string permanentAddress)
public returns (bool){
if(_validCitizens[msg.sender]._isACitizen != true){
_Citizen memory newCitizen = _Citizen(fullname,dateofbirth,permanentAddress,true);
_validCitizens[msg.sender] = newCitizen;
_Citizens.push(newCitizen);
AddCitizen(_Citizens[_Citizens.length-1]._fullname);
return true;
}else{
ErrorLogger("You cannot reister again");
}
}
function getCitizenInfo(address id) public returns (string){
return _validCitizens[id]._fullname;
}
}