Code Monkey home page Code Monkey logo

bc_p4's Introduction

My FlightSurety

My versions

  • Truffle v5.1.10
  • Node v10.18.0
  • Ganache CLI v6.8.1 (ganache-core: 2.9.1)
  • Web3 v1.2.4

How to test the project from the frontend?

Run npm install

Run ganache cli with 30 accounts created:

ganache-cli -a 30 -l 8000000

Compile and deploy contracts on the local environment:

truffle compile && truffle migrate --reset

Copy the public keys of those 30 accounts and save them into ./src/server/oracles.json file. This step is required because those oracles need some money to register itself with the contract (10 ether registration fee).

Start server to simulate oracles:

npm run server

Start dapp:

npm run dapp

Go to localhost:8000 to see the dapp. To simply test the dapp, you can do the following:

  1. Select the flight that you want for all three drop down boxes (the same flight)
  2. Click on Buy button to buy the insurance of the selected flight
  3. Click on Submit-to-Oracles button to initiate the flight status update
  4. Go to the console of npm run server, you will see like the following:

Flight [TG1001] status has been updated to [20]

You might want to do step number 3 until you see such message with the status code not equal 0 or 10.

  1. Click on Claim button to get the amount back. You can also see the current balance will be increase ~1.5 ether.

How to run tests?

In order to run tests you can simply run the following commands:

truffle compile && truffle test

I've include the tests for airline consensus, oracles registration as well as the complete scenario tests. Please see the test files.

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

Resources

bc_p4's People

Contributors

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