Giter Site home page Giter Site logo

msrikrishna / findr-app-frontend Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 4.0 6.99 MB

FINDR is a blockchain/ AI powered review app which gamifies the restaurant review process and offers incentives for the restaurant goers, reviewers and anyone who are generally interested in this space

License: MIT License

JavaScript 32.61% Solidity 12.34% TypeScript 24.26% Procfile 0.01% Python 0.07% CSS 30.72%

findr-app-frontend's Introduction

๐Ÿด FINDR

๐Ÿงช FINDR is a blockchain/ AI powered review app which gamifies the restaurant review process and offers incentives for the restaurant goers, reviewers and anyone who are generally interested in this space. It's a decentralized application that uses the scaffold-eth 2 toolkit to interact with the Ethereum blockchain. The app is equipped with features that allow users to find, stake and do other cool stuff that interact with smart contracts.

โš™๏ธ Built using NextJS, RainbowKit, Hardhat, Wagmi, Typescript and Chainlink

Requirements

Before you begin, you need to install the following tools:

Quickstart

To get started with FINDR, follow the steps below:

  1. Clone this repo & install dependencies
git clone https://github.com/Msrikrishna/FINDR-app-frontend.git
cd FINDR-app-frontend
yarn install

Before you deploy the contracts, you need to create a .env file in the packages/hardhat directory. This file should contain the following environment variables:

DEPLOYER_PRIVATE_KEY
ETHERSCAN_API_KEY?
QUICKNODE_API_KEY
GITHUB_API_TOKEN?
OPENAI_API_KEY?

CONSUMER_ADDRESS
LINK_AMOUNT
FUND_ON_SUBSCRIPTION
SUBSCRIPTION_ID
CHAINlINK_REQUEST_SPECIFIC_GAS

The properties with "?" are optional. You might need them for specific purposes like creating encrypted secrets, uploading gists etc

  1. On a second terminal, deploy the contracts
yarn deploy

This project is configured to use Ethereum Sepolia testnet by default. If you want to use a different network, you can change the network configuration in packages/hardhat/hardhat.config.ts. Make sure this network supports ChainLink Functions.

  1. Next, create a subscription for the AI client contract. Make sure you have LINK on the deployer wallet before proceeding and you are whitelisted to use the ChainLink functions.

After successful subscription creation, you can modify hardhat/scripts/constants.js to use the subscription ID you just created. Then you can try executing the custom-chainlink-request.js script to test the AI client contract works as expected.

npx hardhat run scripts/functions-sub.js --network sepolia
npx hardhat run scripts/custom-chainlink-request.js --network sepolia

  1. On a third terminal, start your NextJS app:

Before you start, you need to recheck the nextjs/constants.ts Make sure all the properties are in sync with the contract deployment

yarn start

Visit your app on: http://localhost:3000. You can interact with your smart contract using the contract component or the example ui in the frontend. You can tweak the app config in packages/nextjs/scaffold.config.ts.

Note: This app depends on the FINDR backend. You can find the backend repo Backend Without running this, the review storage and retrieval will be affected.

Contract Summary

RestaurantInfo.sol

Restaurant Management: Each restaurant is represented as a struct, containing information such as ID, the total amount of FINDR tokens staked for the restaurant, total stake rewards, details, and an array of hashes related to reviews.

Staking: Users can stake FINDR tokens on a restaurant. The first staker of a restaurant creates the restaurant on the blockchain. Users can also unstake their tokens, reducing the total amount of staked tokens on a restaurant and having the tokens returned to their address.

Rewards: Users can collect rewards as their reviews are accepted by the ChanLink AI Client

Review Management: Users can propose reviews for restaurants. Reviews are initially proposed, then sent to an AI client for analysis. This AI client eventually provides a response on the review. If the review passes the AI evaluation (with a success probability less than 80%), it is added to the list of approved reviews for the restaurant. If not, it gets rejected. Each review is identified by a hash, and the owner of the review is stored in the contract.

OpenAI Interactions: The contract interacts with an external AI system through an AI client. The AI client sends requests for review analysis, and the contract handles responses from the AI client, updating the status of the proposed review accordingly.

Request Fulfillment: When the oracle completes the evaluation, it calls back the fulfillRequest function of the contract with the request ID, response, and any errors that occurred during execution. The contract stores the latest response and error, and emits an event with these details.

FINDR.sol

Initialization: The constructor takes an initial supply of tokens as input and mints these tokens to the account deploying the contract. The token has a name "Restaurant finder token" and a symbol "FINDR".

Decimals: The decimals function is overridden to return 8 instead of the default 18 that's common for most ERC20 tokens. This means that the smallest fraction of a FINDR token that can be represented is 1e-8 FINDR. This is important for showing balances in user interfaces.

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.