Code Monkey home page Code Monkey logo

flightsurety-1's Introduction

FlightSurety

FlightSurety is a sample application project for Udacity's Blockchain course.

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 truffle compile

Develop Client

To run truffle tests:

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

To use the dapp:

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

Navigate through the DAPP

To an esier navigation, the page is divided in different sections:

  • Airline actions
  • Flight actions
  • Passenger actions
  • Oracle actions
  • Logs

Every time an action is performed, a log will be displayed at the bottom "Logs" section.

The basic steps to navigate and use the DAPP are the following:

  1. Open site with Metamask enabled and with contract owner account selected. Operational status should be displayed as true at logs (refresh page otherwise).

truffle test

  1. Add funds to activate the account. Minimum of 10 eth are required.

truffle test truffle test

  1. Register an airline introducing account address and name. truffle test Then, an OK message will be logged and it will be added to airlines combobox truffle test truffle test When registering the fifth airline, voting system starts and a log wil warn about it. Once the airline has 4 votes, it will be added as previous ones. truffle test

  2. Select in Metamask the new airline account.

  3. Add funds to the new airline.

  4. Register a flight introducing Flight Code and Destination. Click on the flight code to copy on clipboard.

truffle test truffle test

  1. Switch in metamask to a third account, to be used as a passenger.
  2. Paste or write flight code and set the amount of ethers we want to pay for a flight insurance, and then click on "Buy".

truffle test truffle test

  1. Oracles working on server will return a specific status. By default, it is "ON TIME", but it can be changed clicking on Oracle Simulation status buttons. Click on "LATE AIRLINE" to be able to finish this circuit.

truffle test truffle test

  1. Paste flight code on Oracles sections Flight Number box, select correct airline in dropdown menu and click on "Submit to Oracles". After few seconds, flight status will be updated in the flights display panel.

truffle test truffle test

  1. With the passenger account selected in Metamask, click on "Check credit". It will show payed insurance amount multiplied by 1.5.

truffle test

  1. Clicking on "Claim Credit" passenger will withdraw the credit and it will be added to its account.

Resources

Program version numbers

  • Node.js v6.14.4
  • Solidity v0.4.25
  • Truffle v5.1.27
  • Ganache v6.10.0-beta.2
  • truffle-hdwallet-provider v1.0.2
  • Web3 v1.2.6

flightsurety-1's People

Contributors

benattxurruka avatar dependabot[bot] 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.