A simple yet powerful Ethereum smart contract to manage your daily tasks directly on the blockchain! Built using Solidity by a passionate beginner learning through YouTube tutorials and ChatGPT guidance. 🎥🤖
After building my first wallet, I wanted to take it one step further. This TodoList taught me about structs, arrays, and more real-world logic. Here's what I picked up:
- ✅ How to define and use
structfor creating task objects - ✅ Storing multiple items using a
Task[]dynamic array - ✅ How
publiclets you view contract variables from outside - ✅ Writing functions to add new tasks and read specific ones
- ✅ Using
forloops in Solidity to search for tasks by ID - ✅ Toggling boolean values (
true↔false) with!operator - ✅ Error handling using
revert()
| 🔧 Function | 💡 What It Does |
|---|---|
addTask() |
Add a new task with description and ID |
getTask() |
Fetch a task’s details using its unique ID |
toggleTask() |
Flip task status between completed and not completed |
- Go to Remix IDE
- Create a new file
TodoList.soland paste the contract code - Compile using version
0.8.0or above - Deploy to local VM or Injected Web3 (MetaMask)
- Use the UI to:
- 🆕 Add a task
- 🔍 Get a task by ID
- 🔁 Toggle a task's status (complete/incomplete)
Task[] public alltasks;
uint public currentId = 1;
function addTask(string memory description) public {
alltasks.push(Task(currentId, description, false));
currentId++;
}