Last active
August 26, 2018 10:28
-
-
Save khursani8/5d4a48c5fefc57983b8eb945afc9e770 to your computer and use it in GitHub Desktop.
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.4.24+commit.e67f0147.js&optimize=true&gist=
This file contains hidden or 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.10; | |
| interface ERC20 { | |
| function balanceOf(address who) public view returns (uint256); | |
| function transfer(address to, uint256 value) public returns (bool); | |
| function allowance(address owner, address spender) public view returns (uint256); | |
| function transferFrom(address from, address to, uint256 value) public returns (bool); | |
| function approve(address spender, uint256 value) public returns (bool); | |
| event Transfer(address indexed from, address indexed to, uint256 value); | |
| event Approval(address indexed owner, address indexed spender, uint256 value); | |
| } |
This file contains hidden or 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.10; | |
| interface ERC223 { | |
| function transfer(address to, uint value, bytes data) public; | |
| event Transfer(address indexed from, address indexed to, uint value, bytes indexed data); | |
| } |
This file contains hidden or 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.10; | |
| contract ERC223ReceivingContract { | |
| function tokenFallback(address _from, uint _value, bytes _data) public; | |
| } |
This file contains hidden or 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.10; | |
| library SafeMath { | |
| function mul(uint256 a, uint256 b) internal pure returns (uint256) { | |
| if (a == 0) { | |
| return 0; | |
| } | |
| uint256 c = a * b; | |
| assert(c / a == b); | |
| return c; | |
| } | |
| function div(uint256 a, uint256 b) internal pure returns (uint256) { | |
| // assert(b > 0); // Solidity automatically throws when dividing by 0 | |
| uint256 c = a / b; | |
| // assert(a == b * c + a % b); // There is no case in which this doesn't hold | |
| return c; | |
| } | |
| function sub(uint256 a, uint256 b) internal pure returns (uint256) { | |
| assert(b <= a); | |
| return a - b; | |
| } | |
| function add(uint256 a, uint256 b) internal pure returns (uint256) { | |
| uint256 c = a + b; | |
| assert(c >= a); | |
| return c; | |
| } | |
| } |
This file contains hidden or 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.24; | |
| contract StandardToken { | |
| struct Task { | |
| string title; // weight is accumulated by delegation | |
| string description; // if true, that person already voted | |
| string expiryDate; | |
| uint timeLimit; | |
| uint totalLabeled; | |
| uint totalBacked; | |
| uint rewardPerItem; | |
| uint totalItem; | |
| uint totalRemainingItem; | |
| uint noOfValidator; | |
| } | |
| uint totalTasks = 0; | |
| string[] listOfId; | |
| Task[] tasks; | |
| mapping (string=>Task) idToTask; | |
| function createTask(string _id,string _title,string _description,string _expiryDate,uint _totalItem,uint _noOfValidator,uint _timeLimit) | |
| public { | |
| idToTask[_id].title = _title; | |
| idToTask[_id].description = _description; | |
| idToTask[_id].totalBacked = 0; | |
| idToTask[_id].rewardPerItem = 0; | |
| idToTask[_id].totalItem = _totalItem; | |
| idToTask[_id].totalRemainingItem = _totalItem; | |
| idToTask[_id].noOfValidator = _noOfValidator; | |
| idToTask[_id].timeLimit = _timeLimit; | |
| idToTask[_id].expiryDate = _expiryDate; | |
| totalTasks++; | |
| listOfId.push(_id); | |
| } | |
| function getTask(string _id) | |
| public view | |
| returns (string,string,string,uint,uint,uint) | |
| { | |
| return (idToTask[_id].title, | |
| idToTask[_id].description, | |
| idToTask[_id].expiryDate, | |
| idToTask[_id].totalItem, | |
| idToTask[_id].noOfValidator, | |
| idToTask[_id].timeLimit); | |
| } | |
| // function getAllTask() | |
| // public view | |
| // returns (string[],string[],string[],uint[],uint[],uint[]) | |
| // { | |
| // string[] memory titles = new string[](totalTasks); | |
| // string[] memory expiryDates = new string[](totalTasks); | |
| // string[] memory descriptions = new string[](totalTasks); | |
| // uint[] memory totalItems = new uint[](totalTasks); | |
| // uint[] memory noOfValidators = new uint[](totalTasks); | |
| // uint[] memory timeLimits = new uint[](totalTasks); | |
| // for (uint i = 0; i < totalTasks; i++) { | |
| // Task storage task = idToTask[listOfId[i]]; | |
| // titles[i] = task.title; | |
| // expiryDates[i] = task.expiryDate; | |
| // descriptions[i] = task.description; | |
| // totalItems[i] = task.totalItem; | |
| // noOfValidators[i] = task.noOfValidator; | |
| // timeLimits[i] = task.timeLimit; | |
| // } | |
| // return (titles,descriptions,expiryDates,totalItems,noOfValidators,timeLimits); | |
| // } | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment