/poe-image-dapp

Proof of Existence - Digital Image dApp

Primary LanguageJavaScriptMIT LicenseMIT

Consensys Developer Academy 2018 - POE Image dApp

Final Project for the Consensys 2018 Developer course by Marcellus Spears. This project allows a user to prove he/she is the unique author/creator of a digital image.


User Story

  • User uploads unique image to the dApp.
  • User registers image on blockchain with email and unique MetaMask account.
  • User creates a unique SHA256 Hash of the users image.
  • User confirms the transactions details and pulls up MetaMask modal.
  • User submits the transaction and successfully registers the asset on the blockchain.

Requirements

  • Truffle
  • Ganache
  • MetaMask
  • React
  • Redux
  • React-Router
  • Material-UI
  • Zeppelin

Installation

  1. Clone the project

    $ git clone https://github.com/plaidpizazz/poe-image-dapp.git
  2. Change to Project Directory

    $ cd poe-image-dapp
  3. Install truffle and an ethereum client. For local development, try EthereumJS TestRPC.

    $ npm install -g truffle // Version 3.0.5+ required.
    $ npm install -g ethereumjs-testrpc
  4. Install your Ethereum client

    $ npm install -g ganache-cli

Setting up the Project

  1. Change to Project Directory

    $ cd poe-image-dapp
  2. Start your Ethereum client

    $ ganache-cli
  3. Compile and migrate the contracts.

    $ truffle compile
    $ truffle migrate
  4. Run the webpack server for front-end hot reloading.

    $ npm run start

Testing the User Interface

  1. Open localhost in web browser, 'http://localhost:3000'. You should see the following homepage.

  1. Follow on-screen prompts to upload an image. Click Upload Photo

  2. Select an image from your computer. Click Open

  3. Register the image on blockchain. Click Register Photo on Blockchain.

  4. Enter your email and MetaMask account. This will check if image has already been registered.

  5. A unique SHA-256 Hash is created of your photo. Click Next.

  6. Confim the transaction details. Click Register.

  7. Submit transaction on MetaMask.


Testing the Smart Contract

  1. Jest is included for testing React components and Truffle's own suite is incldued for smart contracts. Be sure you've compile your contracts before running jest, or you'll receive some file not found errors.

  2. Change to Project Directory

    $ cd poe-image-dapp
  3. Run Desired Test

    // Runs Jest for React component tests.
    $ npm run test
    
    // Runs Truffle's test suite for smart contract tests.
    $ truffle test

Documentation

  • [Design Patter Decisions]
  • [Avoiding Common Attacks]

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.