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++;
}