Skip to content

Instantly share code, notes, and snippets.

@linagee
Created August 25, 2015 22:51
Show Gist options
  • Save linagee/28693697e1deed6507ca to your computer and use it in GitHub Desktop.
Save linagee/28693697e1deed6507ca to your computer and use it in GitHub Desktop.
contract mortal {
/* Define variable owner of the type address*/
address owner;
/* this function is executed at initialization and sets the owner of the contract */
function mortal() { owner = msg.sender; }
/* Function to recover the funds on the contract */
function kill() { if (msg.sender == owner) suicide(owner); }
}
contract TimeClock is mortal {
struct TimeEntry {
uint start;
uint stop;
}
struct TimeUser {
TimeEntry[] timeEntries;
}
mapping (address => TimeUser) timeUsers;
function startTime() {
var arr = timeUsers[msg.sender];
arr.timeEntries.length++; //add an entry
arr.timeEntries[arr.timeEntries.length].start = block.timestamp - 15;
}
function getStartTime() returns (uint time) {
var arr = timeUsers[msg.sender];
return arr.timeEntries[arr.timeEntries.length].start;
}
//stop => for msg.sender, also must enter a "note" that gets stored (must check this is valid with state)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment