GithubHelp home page GithubHelp logo

flight-surety's Introduction

How does it work?

DAPP

The suggested flow is to start by trying to buy an insurance. An error message of "Airline not yet available to sell insurance" should be prompted in the "Operational Status" area since we have not added any funds yet. After receiving funds we should be able to buy insurance, display or get the insurance information and send a request of flight status to Oracles. This will trigger the callOracle and submitOracleResponse functions in the server. If Oracles report a status code of late airline, the contract will call the processFlightStatus function which will credit passenger with 1.5X the amount they paid and the passenger should be able to get paid.

Server

The server will start by initiallizing 40 oracles. After that it will be ready to receive any event call from our DAPP client.

Features

The first airline is registered when the contract is deployed with isActive status equals to true and haveFunds status equals to false. Next airlines are added to the registration queue by calling the registerAirline function. To confirme registration a registered airline must call the setAirlineStatus function. The first 3 airlines will be registered without the need of approval of other airlines, but after that, new airlines will need multi-party consensus of 50% of registered airlines.

To be able to sell insurance the airline will need to submit funding of 10 ether to the contract. We can test this from the Dapp by trying to sell an insurance before adding funds to them.

Events

The following events are available and can be viewed in the server terminal:

  • OracleRequest
  • BoughtInsurance
  • FlightStatusInfo
  • PassengerPaid
  • FundsReceived

Running tests

Running tests in the truffle console is more stable.

Type truffle develop in the terminal. Next type test test/flightSurety.js.

Install

This repository contains Smart Contract code in Solidity (using Truffle), tests (also using Truffle), dApp scaffolding (using HTML, CSS and JS) and server app scaffolding.

To install, download or clone the repo, then:

npm install npm install webpack-cli -g truffle compile

Develop Client

To run truffle tests:

truffle test ./test/flightSurety.js truffle test ./test/oracles.js

To use the dapp:

truffle compile truffle migrate npm run dapp

To view dapp:

http://localhost:8000

Develop Server

npm run server truffle test ./test/oracles.js

Deploy

To build dapp for prod: npm run dapp:prod

Deploy the contents of the ./dapp folder

Resources

flight-surety's People

Contributors

cjafet avatar

Watchers

James Cloos avatar  avatar

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.