Created
August 4, 2023 11:27
-
-
Save CodeLeom/82c166396a5c85e8cc4eef655331cc5e to your computer and use it in GitHub Desktop.
A simple todo list smart contract
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
| //SPDX-License-Identifier: MIT | |
| pragma solidity ^0.8.3; | |
| contract TodoList { | |
| struct Todo { | |
| string text; | |
| bool isComplete; | |
| } | |
| Todo[] public todos; | |
| function createTodo(string calldata _text) external { | |
| todos.push(Todo({ | |
| text : _text, | |
| isComplete : false | |
| })); | |
| } | |
| function updateTodo(uint _index, string calldata _text) external{ | |
| todos[_index].text = _text; | |
| } | |
| function toggleIsComplete(uint _index) external { | |
| todos[_index].isComplete = !todos[_index].isComplete; | |
| } | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment