Code Monkey home page Code Monkey logo

udacity_flight_surety'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).

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

  3. Register an airline introducing account address and name.

    Then, an OK message will be logged and it will be added to airlines combobox

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.

  1. Select in Metamask the new airline account.

  2. Add funds to the new airline.

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

  4. Switch in metamask to a third account, to be used as a passenger.

  5. Paste or write flight code and set the amount of ethers we want to pay for a flight insurance, and then click on "Buy".

  6. 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.

  7. 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.

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

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

Resources

Program version numbers

~/Projects/udacity/FlightSurety$ truffle version Truffle v5.7.0 (core: 5.7.0) Ganache v7.5.0 Solidity - ^0.5.16 (solc-js) Node v16.19.0 Web3.js v1.7.4

udacity_flight_surety's People

Contributors

sudkul avatar

Watchers

 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.