Skip to content

Instantly share code, notes, and snippets.

@koshikraj

koshikraj/Hello.sol

Created Apr 4, 2020
Embed
What would you like to do?
Amity Online - Solidity summary session
pragma solidity >=0.5.0<= 0.7.0;
contract Hello {
string public owner;
constructor(string memory _owner) public {
owner = _owner;
}
function greetUser(string memory name) public pure returns(string memory) {
return string(abi.encodePacked("Greetings, ", name));
}
}
pragma solidity >=0.5.0<= 0.7.0;
contract TodoList {
string public owner;
uint public taskCounter = 0;
struct Task {
uint index;
string content;
bool completed;
uint timestamp;
}
mapping(uint=>Task) public tasks;
constructor(string memory _owner) public {
owner = _owner;
}
function createTask(string memory _content) public {
taskCounter ++;
Task memory task = Task(taskCounter, _content, false, block.timestamp);
tasks[taskCounter] = task;
}
function toggleTask(uint _index) public {
tasks[_index].completed = ! tasks[_index].completed;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment