Created
February 27, 2018 02:45
-
-
Save jharris-code/247c07faacdd6b054d342592857c058c to your computer and use it in GitHub Desktop.
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.0; | |
contract WolframPocV1 { | |
address private owner; | |
struct Work { | |
bytes32 title; | |
address validator; | |
uint baselineUsers; | |
uint validatedUsers; | |
bool outcome; | |
} | |
// basic list of work items | |
mapping (uint => Work) public workList; | |
// modifier to allow only certain addresses | |
modifier onlyBy(address _account) { | |
require(msg.sender == _account); | |
_; | |
} | |
// constructor | |
function WolframPocV1() public { | |
owner = msg.sender; | |
} | |
// add work item that can be validated | |
function addWork(uint _workId, bytes32 _title, address _validator, uint _baselineUsers) | |
public | |
onlyBy(owner) | |
{ | |
workList[_workId] = Work(_title, _validator, _baselineUsers, 0, false); | |
} | |
// validate work | |
function validateWork(uint _workId, uint _users) | |
public | |
onlyBy(workList[_workId].validator) | |
{ | |
workList[_workId].validatedUsers = _users; | |
if(_users >= workList[_workId].baselineUsers) { | |
workList[_workId].outcome = true; | |
} | |
} | |
// get status of work | |
function workOutcome(uint _workId) public view returns (bool) { | |
return workList[_workId].outcome; | |
} | |
// destroy and return funds if any | |
function destroy() | |
public | |
onlyBy(owner) | |
{ | |
selfdestruct(owner); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment