{"id":21715091,"url":"https://github.com/privacy-scaling-explorations/qdh","last_synced_at":"2025-04-12T19:21:51.012Z","repository":{"id":47106424,"uuid":"288965952","full_name":"privacy-scaling-explorations/qdh","owner":"privacy-scaling-explorations","description":"The Quadratic Dollar Homepage is a spin on the Million Dollar Homepage. While it also features a space for images on a webpage, it allows users to vote on how much space each image takes up. Moreover, it employs a quadratic and collusion-resistant voting mechanism on Ethereum called Minimal Anti-Collusion Infrastructure (MACI) to prevent bribery and scale images quadratically.","archived":false,"fork":false,"pushed_at":"2022-04-11T09:36:19.000Z","size":3522,"stargazers_count":11,"open_issues_count":1,"forks_count":7,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-26T13:38:31.656Z","etag":null,"topics":["ethereum","frontend","maci","quadratic-voting"],"latest_commit_sha":null,"homepage":"https://quadratic.page","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/privacy-scaling-explorations.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-08-20T09:40:38.000Z","updated_at":"2024-11-07T03:48:28.000Z","dependencies_parsed_at":"2022-08-25T13:00:30.656Z","dependency_job_id":null,"html_url":"https://github.com/privacy-scaling-explorations/qdh","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/privacy-scaling-explorations%2Fqdh","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/privacy-scaling-explorations%2Fqdh/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/privacy-scaling-explorations%2Fqdh/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/privacy-scaling-explorations%2Fqdh/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/privacy-scaling-explorations","download_url":"https://codeload.github.com/privacy-scaling-explorations/qdh/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248618714,"owners_count":21134285,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ethereum","frontend","maci","quadratic-voting"],"created_at":"2024-11-26T00:41:08.994Z","updated_at":"2025-04-12T19:21:50.979Z","avatar_url":"https://github.com/privacy-scaling-explorations.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"![QDH Logo](https://quadratic.page/ballot-box-emoji.png)\n\n# Quadratic Dollar Homepage\n\nThe Quadratic Dollar Homepage is a spin on the [Million Dollar Homepage](http://www.milliondollarhomepage.com/). While\nit also features a space for images on a webpage, it allows users to vote on how much space each image takes up.\nMoreover, it employs a quadratic and collusion-resistant voting mechanism on Ethereum called Minimal Anti-Collusion\nInfrastructure (MACI) to prevent bribery and scale images quadratically.\n\n**DEMO**: https://www.youtube.com/watch?v=b6VonnS8e1M\n\n## How to run QDH locally\n\nClone this repo. Install dependencies by running `yarn` or `npm install`:\n\n```bash\ngit clone https://github.com/appliedzkp/qdh\ncd qdh\nyarn  # or `npm install`\n```\n\nCopy `.env.sample` and name it `.env`.\n\nIn `.env` set values for all the missing variables, such as `MONGO_URL`, `AZURE_STORAGE_ACCOUNT_NAME`,\n`AZURE_CONTAINER_NAME`, `AZURE_KEY`, `AZURE_CONNECTION_STRING`. You can find detailed guides on setting up [MongoDB](#setting-up-mongodb) and [Azure Storage](#setting-up-azure-storage) towards the end of this doc.\n\n```bash\ncp .env.sample .env\nvim .env  # set `MONGO_URL, AZURE_STORAGE_ACCOUNT_NAME, etc...`\n```\n\nYour `.env` file should looks something like this:\n```bash\nNEXT_PUBLIC_MACI_ADDRESS=0x2C2B9C9a4a25e24B174f26114e8926a9f2128FE4\nNEXT_PUBLIC_POAP_ADDRESS=0x22C1f6050E56d2876009903609a2cC3fEf83B415\n\nNEXT_PUBLIC_STRAPI_URL=https://strapi-admin.quadratic.page\n\nMONGO_URL=mongodb+srv://user:password@mongodb-ip-or-dns.com/database...\n\nAZURE_STORAGE_ACCOUNT_NAME=qdh\nAZURE_CONTAINER_NAME=qdh-user-images\nAZURE_KEY=24f234f234f+24f243f+24f243f/24f234f234f2f24f==...\nAZURE_CONNECTION_STRING=DefaultEndpointsProtocol=https...\n```\n\nNow run `yarn dev` (or `npm run dev`)\n\n\u003e If you are already running `yarn dev` (or `npm run dev`), make sure to kill the process and start it again. Next.js doesn't pick up `.env` changes automatically. Hence you need to restart it manually.\n\nOn the output, you should see something like this:\n\n```bash\nLoaded env from /your-project-path/qdh/.env\nready - started server on 0.0.0.0:3000, url: http://localhost:3000\n```\n\nFrontend is now accessible on http://localhost:3000\n\nNow let's set up and deploy MACI on a local testnet.\n\n## Setting up MACI\n\nIn a separate terminal, clone MACI: https://github.com/appliedzkp/maci\n\nCarefully follow everything in [\"Local development and testing\"](https://github.com/appliedzkp/maci#local-development-and-testing): bootstrap MACI repo, install Rust, build zk-SNARKs, compile contracts... everything up to the [\"Demo\"](https://github.com/appliedzkp/maci#demo) section.\n\nHere is a summary of commands described in detail in the abovementioned guide:\n\n```bash\ngit clone git@github.com:appliedzkp/maci.git\ncd maci\nnpm i \u0026\u0026 npm run bootstrap \u0026\u0026 npm run build\n\ncurl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh  # to install Rust\ncargo install zkutil --version 0.3.2 \u0026\u0026 zkutil --help\n\ncd circuits\nnpm run buildBatchUpdateStateTreeSnark \u0026\u0026 npm run buildQuadVoteTallySnark\n\ncd ../contracts\nnpm run compileSol\n```\n\nFrom the same directory (`maci/contracts`) start a Ganache instance:\n\n```bash\nnpm run ganache\n```\n\nIn a separate terminal, go to `maci/cli` directory and create a new MACI election:\n\n```bash\nnode ./build/index.js create -d 0xc87509a1c067bbde78beb793e6fa76530b6382a4c0241e5e4a9ec0a0f44dc0d3 \\\n\t-sk macisk.8715ab59a3e88a7ceec80f214ec24a95287ef2cb399a329b6964a87f85cf51c \\\n\t-e http://localhost:8545 \\\n\t-s 15 \\\n\t-o 60 \\\n\t-bm 4 \\\n\t-bv 4\n```\n\nOnce you've deployed MACI and created an election, you should have an output like this:\n\n```bash\nMACI: 0x2C2B9C9a4a25e24B174f26114e8926a9f2128FE4\n```\n\nNow you have 15 seconds to go to the frontend http://localhost:3000 and sign up. Then you'll be able to start voting and interacting with MACI. If you didn't signup in time - restart ganache and redeploy MACI (steps above). Also, you can increase MACI signup deadline, by changing `-s 15` to `-s 30` seconds.\n\nDon't forget to connect your Metamask to your local testnet `locahost:8545` and import one of the test wallets into it.\n\nYou can find a detailed guide of this step and other MACI commands in the [MACI Demonstration](https://github.com/appliedzkp/maci/tree/master/cli#demonstration) docs.\n\nYou can also watch \u0026 listen to these great in-depth presentations about MACI by Koh Wei Jie: [Making Sense of MACI](https://www.youtube.com/watch?v=ooxgPzdaZ_s), [ZKPodcast: MACI with Koh Wei Jie](https://www.youtube.com/watch?v=f9nUGPD5I3o) and [Minimum Anti-Collusion Infrastructure (MACI)](https://www.youtube.com/watch?v=sKuNj_IQVYI)\n\n\n## Setting up Admin Dashboard\n\nThe goal of the Admin Dashboard is to simplify moderation of uploaded images, supply basic initial configuration to the QDH frontend (e.g. MACI contract address on the mainnet) and upload `tally.json` once the vote results are tallied.\n\nSetting up and running [Admin Dashboard](https://github.com/appliedzkp/qdh-admin) is not mandatory, but recommended. We've based it on an open source headless\nCMS, called [Strapi](https://strapi.io/).\n\nYou'll be able to find detailed instructions on how to run it in the repo's README, but we'll make a short overview here as well.\n\nClone the repo https://github.com/appliedzkp/qdh-admin and install dependencies with `yarn` (or `npm install`)\n```bash\ngit clone https://github.com/appliedzkp/qdh-admin\ncd qdh-admin\nyarn  # or `npm install`\n```\n\nCopy `.env.example` and name it `.env`.\n\nIn `.env` set values for all the missing variables, such as `MONGO_URL`, `AZURE_STORAGE_ACCOUNT_NAME`,\n`AZURE_CONTAINER_NAME`, `AZURE_KEY`, `AZURE_CONNECTION_STRING` with the same values as used above.\n\n```bash\ncp .env.example .env\nvim .env # set `MONGO_URL`, `AZURE_STORAGE_ACCOUNT_NAME`, `AZURE_CONTAINER_NAME`, `AZURE_KEY`, `AZURE_CONNECTION_STRING`.\n```\n\nRun `yarn develop` to start the server locally.\n\nThe api will be available at `http://localhost:1337` and the admin panel at `http://localhost:1337/admin`\n\nYou might want to update `NEXT_PUBLIC_STRAPI_URL=http://localhost:1337` in the `.env` in _qdh frontend_, so that your local frontend talks to your locally run Strapi Admin api. Don't forget to manually kill and start the frontend server. (Next.js doesn't automatically pick up .env file changes.)\n\n## How to run QDH in production\n\nThis repo is ready for [Vercel](https://vercel.io), [Heroku](https://heroku.com) and [Dokku](https://github.com/dokku/dokku) deployments. Make sure to export enviromental variables from `.env` to the platform you are deploying on.\n\n### Deploying on Vercel\nInstall [Vercel CLI](https://vercel.com/download):\n```bash\nyarn global add vercel\n# or\nnpm i -g vercel\n```\n\nThen from your `qdh/` directory run `vercel` to start the deployment process and follow the steps. Should work automagically:\n\n```bash\nvercel\n```\n\nYou can also auto deploy to Vercel by importing your git repo: https://vercel.com/new\n\n### Deploying on Heroku\nIf you don't have `heroku` cli installed yet, [install it](https://devcenter.heroku.com/articles/heroku-cli): `brew tap heroku/brew \u0026\u0026 brew install heroku` on macOS or `sudo snap install --classic heroku` on Ubuntu 16+. Then run `heroku login` to link your Heroku CLI to your account.\n\nThen from your `qdh/` repo directory run the following:\n\n```bash\nheroku create qdh-frontend\nheroku config:set $(cat .env | sed '/^$/d; /#[[:print:]]*$/d') --app qdh-frontend # this will pick up variables from .env and transport them to your heroku instance\nheroku git:remote --app qdh-frontend\ngit push heroku master\n```\n\nIf name `qdh-frontend` is already taken, try the steps above with a different name.\n\n### Deploying on Dokku\n\n[Dokku](https://github.com/dokku/dokku) is a Docker powered mini-Heroku.\n\nFollow [these instructions](https://github.com/dokku/dokku#installation) to install Dokku on your server. Make sure to add your pub ssh keys to the dokku deployment (not just to  ~/.ssh/authorized_keys on your server). Once you do that, you should be able to run the following from your local machine:\n\n```bash\nssh -t dokku@your-server-ip apps:create qdh-frontend\nssh -t dokku@your-server-ip config:set qdh-frontend $(cat .env | sed '/^$/d; /#[[:print:]]*$/d') # this will pick up variables from .env and transport them to your dokku instance\ngit remote add dokku dokku@your-server-ip:qdh-frontend\ngit push dokku master\n```\n\n\n## Setting up Azure Storage\n1. Create a Storage account. Give it a name. For example `qdh`\n2. Go to Storage account \u003e Overview\n3. Click on Containers. Create a new storage container. Let's name it `qdh-user-images`. Make sure that the \"Public access level\" is set to **Blob (anonymous access for blobs only)**\n4. Click on Settings \u003e Access keys. Copy paste Account Name, Key and Connection String from there.\n5. Tada! You now have `AZURE_STORAGE_ACCOUNT_NAME`, `AZURE_CONTAINER_NAME`, `AZURE_KEY`, `AZURE_CONNECTION_STRING`:\n\n```bash\nAZURE_STORAGE_ACCOUNT_NAME='qdh'\nAZURE_CONTAINER_NAME='qdh-user-images'\nAZURE_KEY='24f234f234f+24f243f+24f243f/24f234f234f2f24f==...'\nAZURE_CONNECTION_STRING='DefaultEndpointsProtocol=https...'\n```\n![Screenshot 2021-02-03 at 3 21 41 PM](https://user-images.githubusercontent.com/936436/106730581-82522780-6649-11eb-88a7-a928e6bbe5bd.png)\n\np.s. We'll eventually try to make this project cloud agnostic. Feel free to contribute!\n\n## Setting up MongoDB\n\n- If you are are looking for a free \u0026 easy MongoDB hosting, try [Mongo Atlas](https://www.mongodb.com/cloud/atlas)\n- If you've used [Dokku](https://github.com/dokku/dokku) before, you can deploy mongo instance on it using [dokku-mongo](https://github.com/dokku/dokku-mongo) plugin.\n- You can also deploy MongoDB on your IaaS or PaaS of choice.\n\n## Translation\n\n- [Korean / 한국어](/i18n/README.ko.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprivacy-scaling-explorations%2Fqdh","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprivacy-scaling-explorations%2Fqdh","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprivacy-scaling-explorations%2Fqdh/lists"}