Skip to content

Instantly share code, notes, and snippets.

@resilience-me
Last active March 15, 2016 00:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save resilience-me/bbf89b4b0c6a0dddc0bb to your computer and use it in GitHub Desktop.
Save resilience-me/bbf89b4b0c6a0dddc0bb to your computer and use it in GitHub Desktop.
Component of the Proof-of-individuality (POI) system. Generates new POIs each month, anonymous and un-traceable. http://proofofindividuality.online
/* component of the Proof-of-individuality (POI) system. Generates new POIs each month, anonymous and un-traceable */
/* Registration and pseudonym party group-generation on https://github.com/d11e9/poi/blob/master/contracts/poi.sol */
contract generatePOItokens{
address owner;
string public name;
string public symbol;
uint8 public decimals;
mapping (address => uint256) public balanceOf;
event Transfer(address indexed from, address indexed to, uint256 value);
function generatePOItokens(address[] verifiedUsers) {
owner = msg.sender;
balanceOf[owner] = verifiedUsers.length; // Give the creator all initial tokens
name = "POI"; // Set the name for display purposes
symbol = "POI"; // Set the symbol for display purposes
decimals = 0; // Amount of decimals for display purposes
/* Send POIs to every verified address */
for (uint i = 0; i < verifiedUsers.length; i++)
balanceOf[owner] -= 1;
balanceOf[verifiedUsers[i]] += 1;
Transfer(owner, verifiedUsers[i], 1); // Notify anyone listening that this transfer took place
}
function depricatePOIs() {
if (msg.sender == owner) suicide(owner);
}
}
contract POIscheduler{
address[] verifiedUsers;
address POIaddress;
uint public genesisblock;
uint public roundLength;
uint public nextRound;
function POIscheduler(){
genesisblock = block.number;
roundLength = 3000; // set POI pseudonym parties to happen once a month
nextRound = genesisblock + roundLength;
scheduleCall();
}
function issuePOIs() {
if(block.number<nextRound)
throw;
// depricate old POIs
generatePOItokens(POIaddress).depricatePOIs();
POIaddress = new generatePOItokens(verifiedUsers);
/* schedule a new POI round one month from now */
nextRound += roundLength;
scheduleCall();
}
function scheduleCall() public {
/* ethereum-alarm-clock is a DAO for excecuting scheduled calls */
address scheduler = 0x26416b12610d26fd31d227456e9009270574038f; // alarm service v0.7 on the morden testnet
// the 4-byte signature of the local function we want to be called.
bytes4 sig = bytes4(sha3("issuePOIs()"));
uint targetBlock = nextRound;
// the 4-byte signature of the scheduleCall function.
bytes4 scheduleCallSig = bytes4(sha3("scheduleCall(bytes4,uint256)"));
scheduler.call(scheduleCallSig, sig, targetBlock);
}
function verifyPOI (address v) constant returns (string){
if (generatePOItokens(POIaddress).balanceOf[v]==0){
return "account does not have a valid POI";
}
return "account has a valid POI";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment