A simple Solidity smart contract that allows users to create and manage their own decentralized task lists directly on the blockchain.
Each user can add tasks, mark them as completed, and track their overall progress in percentage.
- Add new checklist tasks
- Mark tasks as completed
- View your personal checklist
- Track progress (completion percentage)
- Fully decentralized โ each user's tasks are private and stored on-chain
Smart contract deployment link:https://celo-sepolia.blockscout.com/address/0xb7c13edbf2863F15D37989F9beD9A71545729131
Contract Name: DecentralizedChecklist
Language: Solidity ^0.8.0
License: MIT
| Function | Description |
|---|---|
addTask(string _description) |
Adds a new task to your personal checklist. |
markTaskCompleted(uint _index) |
Marks a task as completed using its index. |
getMyTasks() |
Returns all tasks created by the sender. |
getProgress() |
Returns the percentage of tasks completed. |
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract DecentralizedChecklist {
struct Task {
string description;
bool isCompleted;
}
mapping(address => Task[]) private userTasks;
function addTask(string memory _description) public {
userTasks[msg.sender].push(Task({
description: _description,
isCompleted: false
}));
}
function markTaskCompleted(uint _index) public {
require(_index < userTasks[msg.sender].length, "Invalid task index");
userTasks[msg.sender][_index].isCompleted = true;
}
function getMyTasks() public view returns (Task[] memory) {
return userTasks[msg.sender];
}
function getProgress() public view returns (uint) {
Task[] memory tasks = userTasks[msg.sender];
uint total = tasks.length;
if (total == 0) return 0;
uint completed = 0;
for (uint i = 0; i < total; i++) {
if (tasks[i].isCompleted) {
completed++;
}
}
return (completed * 100) / total;
}
}