Files
bandada/README.md
2023-03-24 10:24:26 +05:30

9.7 KiB

Bandada

Github license GitHub Workflow test GitHub Workflow style Coveralls Linter eslint Code style prettier

Groups are an important concept when we speak about privacy and zero knowledge technologies. They can be thought of as anonymity sets, and are a way to establish necessary trust between a set of participants. The goal of this project is to provide a comprehensive infrastructure to allow anyone to create and manage their own groups.

📦 Packages

Package Version Downloads
@bandada/hardhat NPM version Downloads
@bandada/contracts NPM version Downloads
@bandada/utils NPM version Downloads

🛠 Install

Clone this repository:

git clone https://github.com/privacy-scaling-explorations/bandada.git

and install the dependencies:

cd bandada && yarn

📜 Usage

Starting applications

Run the following command to start the applications in a development environment:

yarn dev

or the following command to start the applications in production mode:

yarn start

Building libraries/applications

Run the following command to build the libraries/applications:

yarn build

A dist folder will be created in each library/application.

Code quality and formatting

Run ESLint to analyze the code and catch bugs:

yarn lint

Run Prettier to check formatting rules:

yarn prettier

or to automatically format the code:

yarn prettier:write

Conventional commits

Semaphore uses conventional commits. A command line utility to commit using the correct syntax can be used by running:

yarn commit

It will also automatically check that the modified files comply with ESLint and Prettier rules.

Database

Bandada require a SQL database to work, which is used by the api application. Bandada can work with Postgres and SQLite. Other SQL flavors should work but are not tested. You can pass the connection URL to the database using environment variable (see below).

Testing

Run Jest to test the code with coverage:

yarn test

Running in Docker

You can also run the entire bandada using docker by running below command in the project root:

docker-compose up -d

Local Development

You can start dependencies essential for local development like a local ethereum network (with data persistance) and TheGraph node using the below command:

docker-compose -f docker-compose.dev.yml up -d

The ethereum node (ganache) started on port 8545 will have the following accounts pre-funded with 100 ETH:

0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266
Private Key: 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80

This is the same first account generated by hardhat network as well.

Deploy the contracts to the local network using the below command:

yarn workspace contracts deploy:bandada-semaphore --network local

The addresses of contracts deployed in a fresh local network would be:

Pairing library has been deployed to:               0x5FbDB2315678afecb367f032d93F642f64180aa3
SemaphoreVerifier contract has been deployed to:    0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512
Bandada contract has been deployed to:             0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0
BandadaSemaphore contract has been deployed to:    0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9

These values are set as defaults in libs/utils/src/contract-addresses.ts. If you change the contract and deploy again, new address need to be set here.

To reset the local network or TheGraph node, you can stop the docker containers, and delete the respective folders inside ./.data.

Environment Variables

Below are the ENV variables used by the api:

Key Description
DB_TYPE Type of the SQL database - postgres/sqlite.
DB_URL Connection string for the database. Path to DB file in case of sqlite.
JWT_SECRET_KEY Secret key used for signing JWT auth tokens.
GITHUB_CLIENT_ID Credentials required for sign in with Github.
GITHUB_CLIENT_SECRET Credentials required for sign in with Github.
TWITTER_CONSUMER_KEY Credentials required for sign in with Twitter.
TWITTER_CONSUMER_SECRET Credentials required for sign in with Twitter.
REDDIT_CLIENT_ID Credentials required for sign in with Reddit.
REDDIT_CLIENT_SECRET Credentials required for sign in with Reddit.
INFURA_API_KEY API Key for Infura. This is used for executing blockchain transactions.
BACKEND_PRIVATE_KEY Ethereum wallet private key used for making blockchain transactions.