GithubHelp home page GithubHelp logo

ethereum-todolist's Introduction

TodoList Dapp

Live demo

ethereum-todolist-demo

Goal

While a TodoList app is not suited to ethereum-based backends, I originally wanted to do one to get my hands on this technology and to have a very simple app actually doing something I am familiar with as a front-end developper.

The goal of this sample app is to help anyone wanting to understand what are ethereum contracts and how they can be used as a distributed back-ends, with its limitations as well.

Required dependencies

A running node

You must run a node on your computer, whether its a real or virtual one. For development speed reasons, the best choice is to use testrpc because you have as much ether as you want and don't need to mine transactions.

Install instructions

Mac & Linux
sudo npm install -g ethereumjs-testrpc
Windows

The ethereumjs-testrpc package needs much more things to be installed on your machine to work on Windows.

If you can't afford this, we've covered you with Vagrant. This piece of software allows you to run a lightweight linux virtual machine in the terminal. Thus, it uses much less power than a full VM and you can still enjoy your Windows environment and tools you are used to, while providing you linux compatibility for terminal tools.

To do so, it's as easy as:

  • Downloading and installing Vagrant
  • Run vagrant up in a terminal opened at the project root. It may take some time as it must download an ubuntu ISO the first time it runs.
  • Then run vagrant ssh. If it doesn't work (it probably won't in fact) you can use Git bash if you already have it on your computer. If you don't, follow those instructions.

And that's it ! Now you can run testrpc and you should see your node running.

Truffle - Compile & Migrate contracts to the blockchain

sudo npm install -g truffle

Note : npm install -g truffle on Windows.

Instructions

Setting up the devTools and client dependencies

npm install

Note : If install fails on windows (particularly if node-gyp is the issue), run Powershell as administrator and run npm install -g windows-build-tools. It will allow you to install and use native node packages.

Run your ethereum node

With testrpc

In a terminal (or in vagrant ssh on Windows, see above), run testrpc

With Geth

Locally
  • Install Ethereum on your machine
  • npm run geth to initialize and run the ethereum node with geth console
  • personal.unlockAccount("ACCOUNT_TO_UNLOCK_ADDRESS", "pass") (see Note if you don't get it)
  • miner.start()

Note : At least the first time, you need to run those commands to create an account to mine on

  • personal.newAccount("pass")
  • personal.unlockAccount("ACCOUNT_ADDRESS", "pass")

Note 2: If you need to customize the geth parameters, check the "geth" task in gulpfile.js.

Deploy the smart contracts to the node

In another terminal, run truffle compile and then truffle migrate --reset

Warning here: You have to re-run those commands when you modify your contracts so that they are re-deployed to the blockchain.

Note : There is an experimental watcher that launch these commands when you save a contract. It may not work but it's worth the shot : npm run watch-contracts

Running the client app

With your node running and the smart contracts deployed to it, run in terminal npm start.

You're done !

FAQ

  • Why is there both a truffle.js file and a truffle-config.js file?

    Truffle requires the truffle.js file be named truffle-config on Windows machines. Feel free to delete the file that doesn't correspond to your platform.

  • Where is my production build?

    The production build will be in the build_webpack folder. This is because Truffle outputs contract compilations to the build folder.

  • Where can I find more documentation?

    This project has been created with truffle-box-react which is a marriage of Truffle and a React setup created with create-react-app. Either one would be a great place to start!

ethereum-todolist's People

Contributors

mbeaudru avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ethereum-todolist's Issues

geth.ipc: bind: invalid argument

$ npm run geth

[email protected] geth /Users/kabeer.jalaluddin/Desktop/Node Js Tutorials/TruffleProjects/ethereum-todolist-master
gulp geth

[12:03:38] Using gulpfile ~/Desktop/Node Js Tutorials/TruffleProjects/ethereum-todolist-master/gulpfile.js
[12:03:38] Starting 'geth'...
[12:03:39] Finished 'geth' after 14 ms
WARN [04-25|12:03:39] No etherbase set and no accounts found as default
INFO [04-25|12:03:39] Allocated cache and file handles database="/Users/kabeer.jalaluddin/Desktop/Node Js Tutorials/TrufflePr
ojects/ethereum-todolist-master/blockchain/geth/chaindata" cache=16 handles=16
INFO [04-25|12:03:39] Successfully wrote genesis state database=chaindata
hash=ba4fe4…dc83a6
INFO [04-25|12:03:39] Allocated cache and file handles database="/Users/kabeer.jalaluddin/Desktop/Node Js Tutorials/TrufflePr

ojects/ethereum-todolist-master/blockchain/geth/lightchaindata" cache=16 handles=16
INFO [04-25|12:03:39] Successfully wrote genesis state database=lightchaindata
hash=ba4fe4…dc83a6
WARN [04-25|12:03:39] No etherbase set and no accounts found as default
INFO [04-25|12:03:39] Starting peer-to-peer node instance=Geth/v1.7.3-stable/darwin-amd64/go1.9.2
INFO [04-25|12:03:39] Allocated cache and file handles database="/Users/kabeer.jalaluddin/Desktop/Node Js Tutorials/TrufflePr
ojects/ethereum-todolist-master/blockchain/geth/chaindata" cache=128 handles=1024
INFO [04-25|12:03:39] Initialised chain configuration config="{ChainID: Homestead: DAO: DAOSupport: false
EIP150: EIP155: EIP158: Byzantium: Engine: unknown}"
INFO [04-25|12:03:39] Disk storage enabled for ethash caches dir="/Users/kabeer.jalaluddin/Desktop/Node Js Tutorials/TruffleProject
s/ethereum-todolist-master/blockchain/geth/ethash" count=3
INFO [04-25|12:03:39] Disk storage enabled for ethash DAGs dir=/Users/kabeer.jalaluddin/.ethash
count=2
INFO [04-25|12:03:39] Initialising Ethereum protocol versions="[63 62]" network=1999
INFO [04-25|12:03:39] Loaded most recent local header number=0 hash=ba4fe4…dc83a6 td=1024
INFO [04-25|12:03:39] Loaded most recent local full block number=0 hash=ba4fe4…dc83a6 td=1024
INFO [04-25|12:03:39] Loaded most recent local fast block number=0 hash=ba4fe4…dc83a6 td=1024
INFO [04-25|12:03:39] Loaded local transaction journal transactions=0 dropped=0
INFO [04-25|12:03:39] Regenerated local transaction journal transactions=0 accounts=0
INFO [04-25|12:03:39] Starting P2P networking
INFO [04-25|12:03:39] RLPx listener up self="enode://d758362ecc5a39c42b377294cb9c50a413a1b5c759178eaf0dc1f11c
6dc94b33071fdaf9417597d71e1f8f3d37d4fa9c880ec3f363b4b2bac4e765a2c998f603@[::]:30303?discport=0"
INFO [04-25|12:03:39] Blockchain manager stopped
INFO [04-25|12:03:39] Stopping Ethereum protocol
INFO [04-25|12:03:39] Ethereum protocol stopped
INFO [04-25|12:03:39] Transaction pool stopped

INFO [04-25|12:03:39] Database closed database="/Users/kabeer.jalaluddin/Desktop/Node Js Tutorials/TrufflePr
ojects/ethereum-todolist-master/blockchain/geth/chaindata"
Fatal: Error starting protocol stack: listen unix /Users/kabeer.jalaluddin/Desktop/Node Js Tutorials/TruffleProjects/ethereum-todolis
t-master/blockchain/geth.ipc: bind: invalid argument

events.js:137
throw er; // Unhandled 'error' event
^
Error: Command geth --rpc --rpcport "8545" --rpccorsdomain "*" --datadir "blockchain" --rpcapi "db,eth,net,web3" --nodiscover --netw orkid 1999 console failed with exit code 1
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] geth: gulp geth
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] geth script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! /Users/kabeer.jalaluddin/.npm/_logs/2018-04-25T04_03_41_304Z-debug.log

2018-04-25T04_10_27_641Z-debug.log

Works fine with testrpc but this issue is also there

Async Component Methods

Why is necessary to use async and await for the component methods?

ie:
async componentWillMount() {

Is this because of ethereum?

Transaction revocation is not considered

Bug Report

Description

When creating a new todo, the scenario that the transaction is revoked due to chain reorganization is not considered.
When the transaction is executed but then revoked, the todo item still shows on the UI which will make the subsequent transaction that aims to delete it fails, losing user's transaction fee.

image

Reproduce Steps

  1. send transaction to create a new todo
  2. When the transaction is executed, UI shows the new todo
  3. Let blockchain reorganize by importing a side chain
  4. The transaction is revoked and returns to transaction pool.
  5. The todo item still shows in UI.
  6. Now if we try to delete the item by click x, the transaction will always fail.

Expected Behaviour

If the transactions revoked by chain reorganization, the todo item in UI should be removed accordingly.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.