Created
May 16, 2018 17:19
-
-
Save franz101/c2c3559af70e743ff1684d6803083725 to your computer and use it in GitHub Desktop.
SmartCity
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
pragma solidity ^0.4.15; | |
import "./Stromanbieter.sol"; | |
contract SmartCity is Stromanbieter{ | |
address public owner; // owner of the contract | |
struct Citizen { // User structure | |
uint id; | |
bool exists; | |
address citizenAddress; | |
string fullName; | |
string personalAddress; | |
uint income; | |
string status; | |
} | |
uint totalCitizens=0; // count of total loans | |
mapping(address => Citizen) citizens; // mapping address to loan | |
// constructor executed when deploying the contract into network | |
// `msg.sender` is the account creating this contract. | |
constructor() public payable { | |
owner = msg.sender; | |
} | |
// transaction to registerCitizen | |
function registerCitizen(string fullname, string personaladdress, uint income) public { | |
//require(!citizens[msg.sender]) | |
Citizen memory c = citizens[msg.sender]; | |
if(c.exists){ | |
citizens[msg.sender] = Citizen(totalCitizens, true, msg.sender, fullname, personaladdress,income, "Registered"); // add Loan object to mapping | |
} | |
else{totalCitizens++; | |
citizens[msg.sender] = Citizen(totalCitizens, true,msg.sender, fullname, personaladdress,income, "Registered"); // add Loan object to mapping | |
} | |
} | |
// get citizen details | |
function getCitizen(address addr) public constant returns(uint, string, string, uint, string) { | |
Citizen memory c = citizens[addr]; | |
return (c.id, c.fullName, c.personalAddress, c.income, c.status); | |
} | |
function getTotal() public constant returns(uint) | |
{return totalCitizens;} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment