GithubHelp home page GithubHelp logo

isabella232 / immutableevidenceform Goto Github PK

View Code? Open in Web Editor NEW

This project forked from consensysmesh/immutableevidenceform

0.0 0.0 0.0 39.28 MB

Form to make evidence of a report immutable - uses drizzle build - starting template for related dapps

HTML 2.02% JavaScript 93.56% CSS 4.42%

immutableevidenceform's Introduction

Immutable Evidence Submission Form

A simple form using the drizzle truffle box that does the following:

  1. Takes form input and commits it on chain (report description, timestamp, latitude, longitude)
  2. Updates user interface when newest form submission posts to blockchain

Note that this guide has a preference toward MAC OS, although you should be able to find complimentary guides on the truffle framework website for Windows OS.

Getting Started

Clone the Repo from Git and install npm dependencies

>npm install

Starting (Your Own Version) on TestRPC (Local Testnet)

Download and Start Ganache

For those with MacOS, download Ganache here: http://truffleframework.com/ganache/. This will visualize your local blockchain (so that you can see all transactions, associated 'costs' and otherwise). Ganache is the new way to interact with TestRPC without having 10 terminals open. For those of you with Windows or other OS, you should be able to find your download(s) here: https://github.com/trufflesuite/ganache/releases

Go ahead and start Ganache by opening the application on your computer. You should see something like this: alt text

Deploy Smart Contracts With Truffle

Open your terminal and 'cd' (change directory) to the appropiate folder, where you have downloaded and unzipped the repo. Then compile and migrate your smart contracts like so (make sure that you have installed all dependencies related to truffle here: http://truffleframework.com/docs/getting_started/installation):

> truffle compile
> truffle migrate 

If you see the following node.js error...

Error: The module '/ImmutableEvidence/node_modules/scrypt/build/Release/scrypt.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 57. This version of Node.js requires
NODE_MODULE_VERSION 59

then run

>npm rebuild scrypt

If you see the following parser error...

Error parsing /ImmutableEvidence/contracts/ComplexStorage.sol: 
ParsedContract.sol:13:14: ParserError: Expected identifier, got 'LParen'
  constructor() {
             ^
Compilation failed. See above.

...then run

>npm upgrade -g truffle

(Truffle v4..1.8 (core: 4.1.9) is working at time of writing this tutorial)

If you see the following connection error during migration...

Could not connect to your Ethereum client. Please check that your Ethereum client:
    - is running
    - is accepting RPC connections (i.e., "--rpc" option is used in geth)
    - is accessible over the network
    - is properly configured in your Truffle configuration file (truffle.js)

...Go to Ganache settings in top right of Ganache User Interface and note the port number (default: 8545) Then in the terminal, open truffle.js and ensure development: { port: 8545 } is the same

Login to MetaMask and Start Web App

IMPORTANT! - Make sure, before you deploy the application locally via 'npm start' in your terminal, that your MetaMask is on the 'Localhost 8545' network. Here are the steps to ensure that it is:

  1. Download MetaMask if you haven't already and make an account

  2. Make sure to log out of that account, you should see the following screen: alt text

  3. Go to Ganache (application shown in first image of the README), you should see a mnemonic at the top of the application shown as 12 random words. Copy these words on your computer.

  4. Press the "Unlock" button on MetaMask, follow the prompts and paste the 12 words into MetaMask (you are now unlocking a test network account in which you can use fake ETH to fund your transactions).

  5. Go to the top left of the MetaMask application where it says 'Main Ethereum Network.' Click and you will see a drop down listing other networks. Choose the 'Localhost 8545 network. You should have a balance of 100 ETH. If you don't, make sure to click on the Account circle in the top left hand side of the application, go down to settings, and scroll down and press the button that says "Reset Account."

  6. Now return to your open terminal and use the following command:

> npm start
  1. A web page should open up and show the interface of your DApp (Decentralized Application). For this DApp, you should see a form, test it out and enter the details and press the submit button. You should get a prompt from MetaMask to 'sign' the transaction (authorize it).

If the MetaMask prompt does not appear, click on your MetaMask extension. The transaction can then be submitted.

You're good to go!

Starting (Your Own Version) on Rinkeby (Actual Testnet)

Have terminal open in the folder path of the project on your computer. Before migrating to testnet, make sure that the application's smart contracts build is up to date. To do this, do the following:

  1. Go to the "build" folder of the project. It should be one of the first, outermost folders in the project
  2. Open the contracts folder
  3. Delete all contents of the contracts folder
  4. Go to terminal window (in which you should be in the folder path of the project)
  5. Use the following command:
> truffle compile

Next, go to the 'truffle.js' config file in the outermost level of the project and change the private key to your test wallet private key (rinkeby). Note, there are no real funds in the current private key's wallet and I do not suggest that you use a private key (even on rinkeby) from a wallet that has mainnet funds, unless you like losing money :)

Afterwards, go to https://infura.io/signup and get yourself an account - this will give you access to a node so that you can migrate your DApp's contracts onto various Ethereum networks. Use the Rinkeby url they send you via email, which should have your API token at the end of it, and replace line 20 in the truffle.js with the following:

> return new PrivateKeyProvider([Your Private Key to Test Wallet], 'https://rinkeby.infura.io/[Your API Token from Infura]') 

Once you have changed your private key in the 'tuffle.js' config file. Open your terminal (again, which should be in the folder path of the project) and thenmigrate your smart contracts to the Rinkeby network like so (make sure that you have installed all dependencies related to truffle here: https://medium.com/@jasoons/migrating-an-ethereum-smart-contract-to-a-live-network-with-truffle-d5d35fcec327):

> truffle migrate --network rinkeby 

Now return to your open terminal and use the following command:

> npm start
  1. A web page should open up and show the interface of your DApp (Decentralized Application). For this DApp, you should see a form, test it out and enter the details and press the submit button. You should get a prompt from MetaMask to 'sign' the transaction (authorize it). You're good to go!

TODO:

  • Complete tx without user being charged

Resources

immutableevidenceform's People

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.