-
Notifications
You must be signed in to change notification settings - Fork 0
/
todolist.sol
48 lines (40 loc) · 915 Bytes
/
todolist.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
pragma solidity ^0.4.17;
contract ToDOList
{
address owner;
event tsk(uint, string);
mapping (uint=>Task) task;
uint count = 0;
struct Task
{
uint256 id;
string name;
bool finish;
}
constructor() public
{
owner = msg.sender;
}
modifier isowner
{
require(owner==msg.sender, "You are not the owner");
_;
}
function addtask(string memory _task) public isowner
{
task[count] = Task(1111+count, _task, false);
emit tsk(1111+count, _task);
count++;
}
function gettask(uint _index) public view returns(uint ,string memory, bool)
{
return(task[_index].id,task[_index].name, task[_index].finish);
}
function finish(uint _index, bool _value) public isowner
{
if(_value){
delete task[_index];
count--;
}
}
}