Created
August 26, 2018 10:29
-
-
Save khursani8/217f4a87dd4fce54a8ecc9717adf7061 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.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