Developing a ToDo list dApp in Ethereum

Pick up your groceries, on the chain.

Photo by Roman Synkevych on Unsplash
Centralized System
You should now see this
  1. Launched a local Blockchain on a localhost port
  2. Changed Metamask to work on our local Blockchain
  3. And imported our private accounts
contract Todo {
uint public count = 0;
struct Task {
uint id;
string content;
bool completed;
}
mapping(uint => Task) public tasks;
function createTask(string memory _content) public {
count = count + 1;
tasks[count] = Task(taskCount, _content, false);
emit TaskCreated(taskCount, _content, false);
}
event TaskCreated(
uint id,
string content,
bool completed
);
event TaskCompleted(
uint id,
bool completed
);
function checkTask(uint _id) public {
Task memory _task = tasks[_id];
_task.completed = !_task.completed;
tasks[_id] = _task;
emit TaskCompleted(_id, _task.completed);
}
Code for the Solidity Smart Contract
var Todo = artifacts.require(“./Todo.sol”);
module.exports = function(deployer)
{ deployer.deploy(Todo);};
truffle migrate
truffle console
todo = await Todo.deployed()
todo.createTask(“Give me 50 claps!”)
task = await todo.tasks(1)
task.checkTask(1)

Building: Ignite Tournaments / Former: DeFi Alliance, Persistence, Eth India Co