Skip to content

Instantly share code, notes, and snippets.

@koshikraj
Created April 4, 2020 07:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save koshikraj/a61eb70723aaf04008c18744c49e6808 to your computer and use it in GitHub Desktop.
Save koshikraj/a61eb70723aaf04008c18744c49e6808 to your computer and use it in GitHub Desktop.
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