Skip to content

Instantly share code, notes, and snippets.

@CodeLeom
Created August 4, 2023 11:27
Show Gist options
  • Select an option

  • Save CodeLeom/82c166396a5c85e8cc4eef655331cc5e to your computer and use it in GitHub Desktop.

Select an option

Save CodeLeom/82c166396a5c85e8cc4eef655331cc5e to your computer and use it in GitHub Desktop.
A simple todo list smart contract
//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