Created
April 4, 2020 07:37
-
-
Save koshikraj/a61eb70723aaf04008c18744c49e6808 to your computer and use it in GitHub Desktop.
Amity Online - Solidity summary session
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.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)); | |
} | |
} |
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.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