├── readme.md └── Contract-1-Todo-App ├── readme.md └── todoContract.sol /readme.md: -------------------------------------------------------------------------------- 1 | # Solidity Smart Contract 2 | 3 | ## Contract No: 1 ( Todo-App-Smart-Contract ) 4 | -------------------------------------------------------------------------------- /Contract-1-Todo-App/readme.md: -------------------------------------------------------------------------------- 1 | # TodoList Smart Contract 2 | 3 | This is a sample smart contract written in Solidity language for a simple todo list. It allows you to create tasks and mark them as completed. 4 | 5 | ## Functions 6 | 7 | ### `createTask(string memory _content)` 8 | 9 | This function creates a new task with the given content and adds it to the todo list. 10 | 11 | ### `toggleCompleted(uint _id)` 12 | 13 | This function toggles the completed status of a task with the given ID. 14 | 15 | ## Events 16 | 17 | ### `TaskCreated(uint id, string content, bool completed)` 18 | 19 | This event is emitted when a new task is created. 20 | 21 | ### `TaskCompleted(uint id, bool completed)` 22 | 23 | This event is emitted when the completed status of a task is toggled. 24 | 25 | ## License 26 | 27 | This smart contract is licensed under the MIT License. 28 | 29 |
30 | 31 | made with 💗 by "Mubashir Alam". 32 | -------------------------------------------------------------------------------- /Contract-1-Todo-App/todoContract.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity ^0.8.0; 3 | 4 | contract TodoList { 5 | uint public taskCount = 0; 6 | 7 | struct Task { 8 | uint id; 9 | string content; 10 | bool completed; 11 | } 12 | 13 | mapping(uint => Task) public tasks; 14 | 15 | event TaskCreated(uint id, string content, bool completed); 16 | event TaskCompleted(uint id, bool completed); 17 | 18 | constructor() { 19 | createTask("Example task"); 20 | } 21 | 22 | function createTask(string memory _content) public { 23 | taskCount ++; 24 | tasks[taskCount] = Task(taskCount, _content, false); 25 | emit TaskCreated(taskCount, _content, false); 26 | } 27 | function toggleCompleted(uint _id) public { 28 | Task memory _task = tasks[_id]; 29 | _task.completed = !_task.completed; 30 | tasks[_id] = _task; 31 | emit TaskCompleted(_id, _task.completed); 32 | } 33 | 34 | } --------------------------------------------------------------------------------