Vexanium Docs
  • Welcome!
  • Overview
    • Vexanium Toolchain
    • Core Concepts
    • Technical Features
  • Getting Started
    • Development Environment
      • Prerequisites
      • Before You Begin
      • Install VEX.CDT
      • Create Development Wallet
      • Start keosd and nodeos
      • Create Development Accounts
    • Smart Contract Development
      • Hello World Contract
      • Deploy, Issue and Transfer Tokens
      • Understanding ABI Files
      • Data Persistence
      • Secondary Indices
      • Adding Inline Actions
      • Inline Actions to External Contracts
      • Payable actions
      • Creating and Linking Custom Permissions
  • Vexanium Protocol
    • Consensus Protocol
    • Transaction Protocol
    • Network Peer Protocol
    • Accounts and Permissions
  • Vexanium DAO - Governance
    • DPOS Governance
    • Active Block Producers
  • Reference
    • API Reference
      • API V2 Migrations
    • Smart Contract
      • C++ Smart Contract
        • Hello World Contract
        • Simple Token Farming Contract
        • Employee Attendance Contract
      • Solidity ( EVM )
        • Setup Metamask
        • To Do List Contract
  • Resources
Powered by GitBook
On this page
  1. Reference
  2. Smart Contract
  3. Solidity ( EVM )

To Do List Contract

mkdir eth-todo-list
cd eth-todo-list
truffle init
touch package.json
package.json
{
  "name": "eth-todo-list",
  "version": "1.0.0",
  "description": "Blockchain Todo List Powered By Ethereum",
  "main": "truffle-config.js",
  "directories": {
    "test": "test"
  },
  "scripts": {
    "dev": "lite-server",
    "test": "echo \"Error: no test specified\" && sexit 1"
  },
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "bootstrap": "4.1.3",
    "chai": "^4.1.2",
    "chai-as-promised": "^7.1.1",
    "chai-bignumber": "^2.0.2",
    "lite-server": "^2.3.0",
    "nodemon": "^1.17.3",
    "truffle": "5.0.2",
    "truffle-contract": "3.0.6"
  }
}
npm install
touch ./contracts/TodoList.sol
// Some code
pragma solidity ^0.5.0;

contract TodoList {
  uint public taskCount = 0;

  struct Task {
    uint id;
    string content;
    bool completed;
  }

  mapping(uint => Task) public tasks;

  event TaskCreated(
    uint id,
    string content,
    bool completed
  );

  event TaskCompleted(
    uint id,
    bool completed
  );

  constructor() public {
    createTask("Visit vexanium.com");
  }

  function createTask(string memory _content) public {
    taskCount ++;
    tasks[taskCount] = Task(taskCount, _content, false);
    emit TaskCreated(taskCount, _content, false);
  }

  function toggleCompleted(uint _id) public {
    Task memory _task = tasks[_id];
    _task.completed = !_task.completed;
    tasks[_id] = _task;
    emit TaskCompleted(_id, _task.completed);
  }

}v
PreviousSetup MetamaskNextResources

Last updated 2 years ago