A simple Ethereum decentralized application (dApp) for managing to-do tasks using a Solidity smart contract, Truffle migrations, and a browser frontend connected through MetaMask.
This project demonstrates end-to-end dApp flow:
- Smart contract stores tasks on-chain
- Frontend reads and updates tasks via Web3
- MetaMask signs transactions
- Truffle handles compile, deploy, and testing
- Solidity
0.5.x - Truffle
5.0.2 - Web3.js
- @truffle/contract
- Ganache (local blockchain)
- MetaMask
- Lite Server
- Bootstrap + jQuery
To-Do-List-Blockchain/
contracts/
TodoList.sol
Migrations.sol
migrations/
1_initial_migration.js
2_deploy_contracts.js
src/
index.html
app.js
css/
TodoList.json
test/
TodoList.test.js
truffle-config.js
bs-config.json
package.json
README.md
Contract: TodoList.sol
- Stores tasks in a mapping
- Tracks
taskCount - Creates tasks with
createTask(string _content) - Toggles completion with
toggleCompleted(uint _id) - Emits events:
TaskCreated(uint id, string content, bool completed)TaskToggled(uint id, bool completed)
Default constructor task:
Check out Forbes.com
- Node.js and npm
- Ganache running on
127.0.0.1:7545 - MetaMask browser extension
npm installThis project is configured for Ganache in truffle-config.js:
- Host:
127.0.0.1 - Port:
7545 - Network ID:
*
Start Ganache first, then continue.
truffle compile
truffle migrate --resetAfter migration, make sure contract artifact is available to frontend in:
build/contracts/TodoList.json
npm run devThen open:
http://localhost:3000
- Connect MetaMask to local Ganache network.
- Import a Ganache account using its private key.
- Approve account access when the app requests connection.
The connected wallet address appears in the UI under Account.
- Add a task from input field
- Toggle task completion via checkbox
- Transactions are written to blockchain and reflected in UI
Run Truffle tests:
truffle testThe test suite validates:
- Contract deployment
- Initial default task
- Task creation
- Task completion toggling
- The
npm testscript inpackage.jsoncontains a typo (sexit) and does not run contract tests. - Use
truffle testdirectly for now. - Frontend expects
TodoList.jsonartifact to be available whenlite-serverruns.
Suprit Raj