luloxi / quaxwell-dapp

DAO dApp for voting a new moderator with quadratic voting

Home Page:https://quaxwell-dapp.on.fleek.co/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Quaxwell dApp

Quadratic voting DAO dapp for choosing a new Moderator

Index

Quick setup

Clone the repo:

  1. Open a terminal an run git clone https://github.com/luloxi/quaxwell-dapp.git

Smart contracts

  1. Open a terminal on hardhat folder
  2. Run yarn on hardhat folder to install dependencies.
  3. Run yarn hardhat node to start a local blockchain that interacts with the frontend

Backend

  1. Open a terminal on backend folder
  2. Run yarn to install dependencies.
  3. Run node index.js to start the backend

Interface

  1. Open a terminal on interface folder
  2. Run yarn on hardhat folder to install dependencies.
  3. Run yarn dev to start a local hosted interface
  4. Open http://localhost:3000 in your web browser.

Smart contracts

Setting up Hardhat

  1. Open a terminal on hardhat folder
  2. Run yarn on hardhat folder to install dependencies.
  3. (optional) Run yarn hardhat test to run tests

Testing locally

  1. Run yarn hardhat node to start a local blockchain that interacts with the frontend

Scripts

  1. Open scripts/createProposal.js in your code editor and complete the fields with your desired data for the proposal
  2. Run yarn hardhat run scripts/createProposal.js to create a proposal

Deploying

  1. Change name of file .env.example to .env
  2. Fill the .env file with the settings for the blockchain you want to deploy to *
  3. Run the deploy command for your blockchain of choice
  • If you want to skip contracts verification, don't fill out the ETHERSCAN_API_KEY or POLYGONSCAN_API_KEY variables.

Settings for Mainnet

Settings for Goerli Testnet

Settings for Mumbai Testnet

Deploy commands

  • Mainnet: yarn hardhat run scripts/deployAll.js --network mainnet
  • Goerli: yarn hardhat run scripts/deployAll.js --network goerli
  • Mumbai: yarn hardhat run scripts/deployAll.js --network mumbai

Backend

Setting up backend

  1. Open a terminal on backend folder
  2. Run yarn to install dependencies.
  3. Run node index.js to start the backend

Testing backend

  1. Open a terminal on backend folder
  2. Open http://localhost:3001/proposals on your browser to make a call and view the result

Deploying to Fleek

  1. Select to deploy from your repo, then choose the Next type
  2. Input this parameters:
  • Docker image name: node:lts
  • Build command: yarn
  • Base directory: backend
  • Publish directory: /

Frontend

Setting up interface

  1. Open a terminal on interface folder
  2. Run yarn on hardhat folder to install dependencies.
  3. Run yarn dev to start a local hosted interface
  4. Open http://localhost:3000 in your web browser.

Connecting to different chains

  1. Change /constants/CurrentChain.json default value to your desired chain name.
  2. Change/pages/_app.js jsonRpcUrl rpc value to a valid RPC URL)
  3. Change../backend/index.js getDefaultProvider value to a valid RPC URL)
  • Available chain names are hardhat mumbai goerli and mainnet
  • Default value hardhat is for local testing

Deploying to Fleek

  1. Select to deploy from your repo, then choose the Next type
  2. Input this parameters:
  • Build command: yarn && yarn build && yarn export
  • Publish directory: out
  • Base directory: interface

File locations

/ (Root folder)

  • /concept: Reference files for styling.
  • /backend: Backend files. Made using Express.
  • /hardhat: Smart contracts files. Made using Hardhat
  • /interface: Frontend files. Made using Next.js + Wagmi + ChakraUI

/hardhat (Smart contracts)

  • .env: Environment variables. Located on the root folder of the project.
  • contracts/: Contracts and libraries for those contracts.
  • deploy/: Deploy scripts that work according to hardhat-deploy plugin.
  • scripts/: Script to deployAll, and script to Propose as admin.
  • test/: Unit testing for Quaxwell contracts

/interface (Frontend)

  • /components: Custom components for Quaxwell dApp.
  • /constants: ABI and Contract addresses for deployed contracts
  • /hooks: Custom hooks for conditional behavior
  • /pages: Single page base files
  • /styles: CSS modules for styling the dApp

/backend (Backend)

  • index.js: File with setup and functions for REST API

Troubleshooting

Common smart contracts problems

  • Did you set the .env file right?
  • Did you save after changing the .env file?
  • Delete "artifacts" and "cache" folder and try again.

"nonce too low" / Pending transaction stuck:

If you get this error when trying to use your wallet again after using it for interacting with the blockchain with this repo, it's because you used some nonces to send the transactions that deploy or interact with the contracts. In your MetaMask, go to Settings > Advanced > Reset Account

Don't have yarn

  1. Install the LTS version of Node
  2. Open a terminal and run npm install --global yarn

Don't have git

(Bonus) Enable hh shorthand

npm install --global hardhat-shorthand to use commands like hh node instead of yarn hardhat node

Previous versions:

About

DAO dApp for voting a new moderator with quadratic voting

https://quaxwell-dapp.on.fleek.co/


Languages

Language:JavaScript 82.3%Language:Solidity 17.7%