Coder Social home page Coder Social logo

masaun / disaster-risk-insurance Goto Github PK

View Code? Open in Web Editor NEW
0.0 3.0 0.0 1.62 MB

Smart contract based Disaster Risk Insurance (by using ChainLink and Honeycomb MarketPlace)

HTML 4.30% CSS 2.12% JavaScript 93.58%
chainlink honeycomb solidity web3js react

disaster-risk-insurance's Introduction

Disaster Risk Insurance

  • Disaster Risk Insurance is micro insurance in case of happening disaster by using smart contract.
  • Any users who fund premiums and match condition can receive insurance money instantly by smart contract.
  • This is the Disaster Risk Insurance project to build a dapp that calls a Honeycomb marketplace API through a Chainlink node over the Ropsten testnet.

UI and process of Disaster Risk Insurance

Once you follow the previous steps, your browser should display the page below at http://localhost:3000/. If the page is blank, try logging in to your MetaMask add-on.

  • [Basic process]:
    • This is the Disaster Risk Insurance project of an oracle-connected dapp.
    • The oracle returns a city name which is matched IP-address of being requested from current user.
    • The users can fund premiums between 0.1ETH ~ 0.5ETH. In case it happen disaster in your city, you can receive 2 times insurance money which you funded premiums until previous time of happening disaster.
    • If result of request that user's city name which called by registerd IP address match with city name of disaster area, user can receive withdrawed insurance money from fund pool of premiums automatically by smart contract.

  • [Some premise]:
    • User need to register with their wallet-address and IP-address as benefically
    • Disaster area also need to register with city name and isDisaster (Define both of properties in struct of DisasterArea )
      • This time I prepare seed data of 3 disaster area. If it push bottom of button which is called "Create Disaster Area", it can save seed data of 3 disaster area. (Next time, I will find disaster area API and implement them as oracle and implement matching logic)

Replace the ipStack with a Honeycomb API

See how the JobID of ipStack API is set in migrations/4_deploy_disaster_risk_insurance.js:

const jobId_1 = web3.utils.toHex("d1d029a5f50c44789f19da3ec4e51e7b"); // This jobId's data-type is bytes32 const jobId_2 = web3.utils.toHex("c62efeba282f48dcb5a1d5b7b7cade9d"); // This jobId's data-type is int256 const jobId_3 = web3.utils.toHex("11a18a9089bd4c668f13f5e5df5547b8"); // This jobId's data-type is uint256

The honeycomb.market Ropsten node serves a random int256 between two limits with this JobID. To develop a smart contract that depends on another type of call, you are going to need to change it.

First, see this article that gives a general overview of Honeycomb Marketplace. Then, follow these steps:

As a result, you are going to see the Ropsten listing for that endpoint. Replace the JobID in migrations/4_deploy_disaster_risk_insurance.js with the new JobID.

Note that you are also going to have to modify the smart contract based on the API you have used. See this article for an example.


Before installation

npm install -g truffle

  • Install the Metamask add-on to your browser and create a wallet. Note down the mnemonics. Fund it with Ropsten ETH and Ropsten LINK.

  • Create an Infura account, get an endpoint URL for the Ropsten testnet and note it down.

  • (Optional) Install Visual Studio Code


Installation

  • Clone this repo using:

git clone https://github.com/clc-group/honeycomb-example-project.git

  • Go to the main directory (/honeycomb-example-project)

  • Install the dependencies for the smart contract:

npm install

  • Create the file that you are going to enter your Infura credentials:

cp wallet.json.example wallet.json

  • Open the newly created wallet.json file and enter the mnemonics and the endpoint URL you have noted down earlier, similar to wallet.json.example.

  • Deploy the contract (Ropsten LINK will be transferred from your wallet to the contract automatically during deployment)

npm run deploy-ropsten

  • Go to the front-end project directory (/honeycomb-example-project/client)

  • Install the dependencies for the front-end project:

npm install

  • Start the server

npm run start


References

disaster-risk-insurance's People

Contributors

masaun avatar

Watchers

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