/FlightSurety

Flight Insurance App

Primary LanguageJavaScript

FLIGHT INSURANCE APP

This repository containts an Ethereum DApp that demonstrates a flight insurance application

CURRENT: live version of contract: ETHERSCAN

Preview

app-preview-image-1 app-preview-image-2

Getting Started

These instructions will get you a copy of the FlightSurety.app and lets you run the client on the local machine and deploys your own contract to the test network rinkeby.

Prerequisites

Please make sure you've enabled MetaMask extension in your browser and gulp installed.

Installing and Using the FlightSurety Contracts for Yourself on the RINKEBY TESTNETWORK

Client Setup

  1. Clone this repository:

    $ git clone https://github.com/Userrick/FlightSurety
  2. Got to Flightsurety/client/ and install all requisite npm packages (as listed in package.json):

    $ npm install
  3. Create a new file in FlightSurety/client/src/blockchain/ with the name migration-secrets.js:

    $ touch migration-secrets.js
  4. Install truffle-hdwallet-provider in FlightSurety/client/src/blockchain/:

    $ npm install
  5. Copy the following into it (attention to https://):

    const secrets = {
        address: "YOUR ADDRESS WHICH WILL ALSO BE THE FIRST ADMIN OF FLIGHTSURETYDATA CONTRACT"
        mnemonic: "YOUR-SEED-WORDS-FROM-METAMASK-ACCOUNT",
        ENDPOINT: "https://YOUR-INFURA-ENDPOINT_KEY"
    }
    
    module.exports = secrets;
  6. Follow this guide to reveal your seed words from your METAMASK account.

    a) Be sure to be on the rinkeby testnetwork

    b) Copy your seed words from your METAMASK into the respective marked section of the secrets-migration.js file

  7. Visit the infura website

    a) login or create account

    b) create a new project

    c) COPY the endpoint from the project to clipboard

    INFURA-key

    d) PASTE it into the respective field in the secrets-migration.js file

  8. Now launch your personal flight insurance contracts to the network by following these commands:

    $ truffle compile
    
    $ truffle migrate --reset --network rinkeby
  9. Now launch the client by the following command:

    $ npm start

Server Setup

  1. Got to Flightsurety/server/ and install all requisite npm packages (as listed in package.json):

    $ npm install
  2. Create a new file in FlightSurety/server/ with the name secrets.js:

    $ touch secrets.js
  3. Copy the following into it (attention to https://):

    const secrets = {
        mnemonic: "YOUR-SEED-WORDS-FROM-METAMASK-ACCOUNT",
        ENDPOINT: "https://YOUR-INFURA-ENDPOINT_KEY",
        privateKey: "YOUR-PRIVATE-KEY-OF-METAMASK-ACCOUNT-USED-FOR-REGISTRATING-DEFAULT-ORACLES-AND-ALSO-RESPOND-TO-ORACLE-REQUEST"
    }
    
    module.exports = secrets;
  4. Edit the config.js file in Flightsurety/server/ to your needs

    Make sure to use the same address as for deploying your smart contract!

  5. Install MongoDB from MONGODB

  6. Open New Terminal and run:

    $ mongod
  7. Now launch the server by the following command in a new terminal and wait until every oracle of the 40 are registered:

    $ npm run dev

    Now you should be able to interact with your contract at LOCALHOST via METAMASK on the rinkeby test network.

    If you encounter some issues let me know!

    Enjoy!

Testing without losing too much eth and for that oracles from server work properly on rinkeby

  1. Make sure to search for all the comments in the FlightSuretyApp and FlightSuretyData contract marked with ///@dev and comment the direct below require statement out.

Built With

  • Ethereum - Ethereum is a decentralized platform that runs smart contracts
  • Truffle Framework - Truffle is the most popular development framework for Ethereum with a mission to make your life a whole lot easier.
  • truffle-hdwallet-provider - HD Wallet-enabled Web3 provider. Use it to sign transactions for addresses derived from a 12-word mnemonic.
  • NODE + NPM
  • MONGODB - The database for modern applications
  • REACT - A JavaScript library for building user interfaces
  • REACT-Bootstrap - The most popular front-end framework Rebuilt for React.

Version Used

  • Truffle v5.0.22 (core: 5.0.22)
  • Solidity v0.5.8 (solc-js)
  • Node v12.4.0
  • Web3.js v1.0.0-beta.37

Authors

Starter code was provided by Udacity

Resources